From d67ea4a51130a47df397264881ed6b8d774195ad Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 22 Nov 2015 11:46:13 -0600 Subject: just delete erlware_commons rebar.config.script, it isn't needed for rebar3 --- bootstrap | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bootstrap') diff --git a/bootstrap b/bootstrap index 25bd658..a26ebff 100755 --- a/bootstrap +++ b/bootstrap @@ -15,6 +15,7 @@ main(_Args) -> %% Fetch and build deps required to build rebar3 BaseDeps = [{providers, []} ,{getopt, []} + ,{cf, []} ,{erlware_commons, ["ec_dictionary.erl", "ec_vsn.erl"]} ,{certifi, []}], Deps = get_deps(), @@ -68,6 +69,12 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) -> {Name, _, Source} -> ok = fetch(Source, Name) end, + + %% Hack: erlware_commons depends on a .script file to check if it is being built with + %% rebar2 or rebar3. But since rebar3 isn't built yet it can't get the vsn with get_key. + %% So we simply make sure that file is deleted before compiling + file:delete("_build/default/lib/erlware_commons/rebar.config.script"), + compile(Name, ErlFirstFiles). fetch({pkg, Name, Vsn}, App) -> -- cgit v1.1 From cde592150b2ec4e850bbac94b6a145402c022e25 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Tue, 15 Dec 2015 14:28:07 +0100 Subject: Skip update and compilation if possible. This detects existence of Hex registry at $HOME/.cache/rebar3/hex/default/registry and skips "rebar3 update" step. It also detect presence of bootstrap dependencies in _build/default/lib/ and skips fetching them. --- bootstrap | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'bootstrap') diff --git a/bootstrap b/bootstrap index a26ebff..b20d0d3 100755 --- a/bootstrap +++ b/bootstrap @@ -2,8 +2,7 @@ %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ft=erlang ts=4 sw=4 et - -main(_Args) -> +main(_) -> application:start(crypto), application:start(asn1), application:start(public_key), @@ -34,7 +33,14 @@ main(_Args) -> setup_env(), os:putenv("REBAR_PROFILE", "bootstrap"), - rebar3:run(["update"]), + RegistryFile = default_registry_file(), + case filelib:is_file(RegistryFile) of + true -> + ok; + false -> + rebar3:run(["update"]) + end, + {ok, State} = rebar3:run(["compile"]), reset_env(), os:putenv("REBAR_PROFILE", ""), @@ -62,6 +68,11 @@ main(_Args) -> ok end. +default_registry_file() -> + {ok, [[Home]]} = init:get_argument(home), + CacheDir = filename:join([Home, ".cache", "rebar3"]), + filename:join([CacheDir, "hex", "default", "registry"]). + fetch_and_compile({Name, ErlFirstFiles}, Deps) -> case lists:keyfind(Name, 1, Deps) of {Name, Vsn} -> @@ -79,15 +90,20 @@ fetch_and_compile({Name, ErlFirstFiles}, Deps) -> fetch({pkg, Name, Vsn}, App) -> Dir = filename:join([filename:absname("_build/default/lib/"), App]), - CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs", - Package = binary_to_list(<>), - Url = string:join([CDN, Package], "/"), - case request(Url) of - {ok, Binary} -> - {ok, Contents} = extract(Binary), - ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]); - _ -> - io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn]) + case filelib:is_dir(Dir) of + false -> + CDN = "https://s3.amazonaws.com/s3.hex.pm/tarballs", + Package = binary_to_list(<>), + Url = string:join([CDN, Package], "/"), + case request(Url) of + {ok, Binary} -> + {ok, Contents} = extract(Binary), + ok = erl_tar:extract({binary, Contents}, [{cwd, Dir}, compressed]); + _ -> + io:format("Error: Unable to fetch package ~p ~p~n", [Name, Vsn]) + end; + true -> + io:format("Dependency ~s already exists~n", [Name]) end. extract(Binary) -> -- cgit v1.1