diff --git a/bootstrap b/bootstrap index b58f1e52..aef49b81 100755 --- a/bootstrap +++ b/bootstrap @@ -26,10 +26,10 @@ main(_) -> rm_rf("_build/default/lib/rebar"), rm_rf("_build/test/lib/rebar"), - %% We fetch a few deps from hex for boostraping, - %% so we must compile r3_safe_erl_term.xrl which - %% is part of hex_core. - compile_xrl_file("src/r3_safe_erl_term.xrl"), + mkdir_p("_build/bootstrap/lib/rebar/ebin"), + + os:putenv("REBAR_PROFILE", "bootstrap"), + compile_vendored(), %% Fetch and build deps required to build rebar3 BaseDeps = [{providers, []} @@ -176,6 +176,15 @@ maybe_set_ipfamily({ok, _}, Family) -> maybe_set_ipfamily(_, _Family) -> ok. +compile_vendored() -> + compile_xrl_file("src/vendored/r3_safe_erl_term.xrl"), + Sources = filelib:wildcard(filename:join(["src/vendored", "*.erl"])), + Dir = filename:absname("_build/bootstrap/lib/rebar/ebin"), + code:add_patha(Dir), + Ebin = "_build/bootstrap/lib/rebar/ebin", + Opts = [debug_info,{outdir, filename:absname(Ebin)}, return | additional_defines()], + [compile_erl_file(X, Opts) || X <- Sources]. + compile(App, FirstFiles) -> Dir = filename:join(filename:absname("_build/default/lib/"), App), filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])), @@ -278,6 +287,14 @@ rm_rf(Target) -> ok end. +mkdir_p(Target) -> + Pred = fun (Dir, Acc) -> + NewAcc = filename:join(filename:absname(Acc), Dir), + file:make_dir(NewAcc), + NewAcc + end, + lists:foldl(Pred, "", filename:split(Target)). + -spec cp_r(list(string()), file:filename()) -> 'ok'. cp_r([], _Dest) -> ok; diff --git a/src/r3_hex_api.erl b/src/vendored/r3_hex_api.erl similarity index 100% rename from src/r3_hex_api.erl rename to src/vendored/r3_hex_api.erl diff --git a/src/r3_hex_api_key.erl b/src/vendored/r3_hex_api_key.erl similarity index 100% rename from src/r3_hex_api_key.erl rename to src/vendored/r3_hex_api_key.erl diff --git a/src/r3_hex_api_package.erl b/src/vendored/r3_hex_api_package.erl similarity index 100% rename from src/r3_hex_api_package.erl rename to src/vendored/r3_hex_api_package.erl diff --git a/src/r3_hex_api_package_owner.erl b/src/vendored/r3_hex_api_package_owner.erl similarity index 100% rename from src/r3_hex_api_package_owner.erl rename to src/vendored/r3_hex_api_package_owner.erl diff --git a/src/r3_hex_api_release.erl b/src/vendored/r3_hex_api_release.erl similarity index 100% rename from src/r3_hex_api_release.erl rename to src/vendored/r3_hex_api_release.erl diff --git a/src/r3_hex_api_user.erl b/src/vendored/r3_hex_api_user.erl similarity index 100% rename from src/r3_hex_api_user.erl rename to src/vendored/r3_hex_api_user.erl diff --git a/src/r3_hex_core.erl b/src/vendored/r3_hex_core.erl similarity index 100% rename from src/r3_hex_core.erl rename to src/vendored/r3_hex_core.erl diff --git a/src/r3_hex_core.hrl b/src/vendored/r3_hex_core.hrl similarity index 100% rename from src/r3_hex_core.hrl rename to src/vendored/r3_hex_core.hrl diff --git a/src/r3_hex_erl_tar.erl b/src/vendored/r3_hex_erl_tar.erl similarity index 100% rename from src/r3_hex_erl_tar.erl rename to src/vendored/r3_hex_erl_tar.erl diff --git a/src/r3_hex_erl_tar.hrl b/src/vendored/r3_hex_erl_tar.hrl similarity index 100% rename from src/r3_hex_erl_tar.hrl rename to src/vendored/r3_hex_erl_tar.hrl diff --git a/src/r3_hex_filename.erl b/src/vendored/r3_hex_filename.erl similarity index 100% rename from src/r3_hex_filename.erl rename to src/vendored/r3_hex_filename.erl diff --git a/src/r3_hex_http.erl b/src/vendored/r3_hex_http.erl similarity index 100% rename from src/r3_hex_http.erl rename to src/vendored/r3_hex_http.erl diff --git a/src/r3_hex_http_httpc.erl b/src/vendored/r3_hex_http_httpc.erl similarity index 100% rename from src/r3_hex_http_httpc.erl rename to src/vendored/r3_hex_http_httpc.erl diff --git a/src/r3_hex_pb_names.erl b/src/vendored/r3_hex_pb_names.erl similarity index 100% rename from src/r3_hex_pb_names.erl rename to src/vendored/r3_hex_pb_names.erl diff --git a/src/r3_hex_pb_package.erl b/src/vendored/r3_hex_pb_package.erl similarity index 100% rename from src/r3_hex_pb_package.erl rename to src/vendored/r3_hex_pb_package.erl diff --git a/src/r3_hex_pb_signed.erl b/src/vendored/r3_hex_pb_signed.erl similarity index 100% rename from src/r3_hex_pb_signed.erl rename to src/vendored/r3_hex_pb_signed.erl diff --git a/src/r3_hex_pb_versions.erl b/src/vendored/r3_hex_pb_versions.erl similarity index 100% rename from src/r3_hex_pb_versions.erl rename to src/vendored/r3_hex_pb_versions.erl diff --git a/src/r3_hex_registry.erl b/src/vendored/r3_hex_registry.erl similarity index 100% rename from src/r3_hex_registry.erl rename to src/vendored/r3_hex_registry.erl diff --git a/src/r3_hex_repo.erl b/src/vendored/r3_hex_repo.erl similarity index 100% rename from src/r3_hex_repo.erl rename to src/vendored/r3_hex_repo.erl diff --git a/src/r3_hex_tarball.erl b/src/vendored/r3_hex_tarball.erl similarity index 100% rename from src/r3_hex_tarball.erl rename to src/vendored/r3_hex_tarball.erl diff --git a/src/r3_safe_erl_term.xrl b/src/vendored/r3_safe_erl_term.xrl similarity index 100% rename from src/r3_safe_erl_term.xrl rename to src/vendored/r3_safe_erl_term.xrl diff --git a/vendor_hex_core.sh b/vendor_hex_core.sh index d95261b9..fe78b677 100755 --- a/vendor_hex_core.sh +++ b/vendor_hex_core.sh @@ -7,7 +7,7 @@ if [[ -z "$1" ]]; then fi source_dir=$1/src -target_dir=src +target_dir=src/vendored prefix=r3_ hex_core_version=`cat $source_dir/hex_core.hrl | grep HEX_CORE_VERSION | cut -d'"' -f2`