From 571c62f7326491dc739a914f1dbaed9af459278e Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 12:38:21 -0600 Subject: output message when starting install_deps provider --- src/rebar_prv_install_deps.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 1be094c..9a3703c 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -65,6 +65,7 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> + ?INFO("Verifying dependencies...", []), Profile = rebar_state:current_profile(State), ProjectApps = rebar_state:project_apps(State), try -- cgit v1.1 From a39041924783f901cf24a53991d8fbdc59977dd6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 15:23:53 -0600 Subject: don't store global state variables in opts dict --- src/rebar3.erl | 2 +- src/rebar_state.erl | 42 +++++++++++++++++++++++++++++------------- src/rebar_templater.erl | 2 +- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/rebar3.erl b/src/rebar3.erl index 9d419d1..f6a2b78 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -167,7 +167,7 @@ init_config() -> %% resources out of the escript State1 = try ScriptName = filename:absname(escript:script_name()), - rebar_state:set(State, escript, ScriptName) + rebar_state:escript_path(State, ScriptName) catch _:_ -> State diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 77004a7..1f522ef 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -6,6 +6,8 @@ opts/1, default/1, default/2, + escript_path/1, escript_path/2, + lock/1, lock/2, current_profile/1, @@ -34,6 +36,8 @@ opts = dict:new() :: rebar_dict(), default = dict:new() :: rebar_dict(), + escript_path :: undefined | file:filename_all(), + lock = [], current_profile = default :: atom(), @@ -129,6 +133,12 @@ lock(#state_t{lock=Lock}) -> lock(State=#state_t{lock=Lock}, App) -> State#state_t{lock=[App | Lock]}. +escript_path(#state_t{escript_path=EscriptPath}) -> + EscriptPath. + +escript_path(State, EscriptPath) -> + State#state_t{escript_path=EscriptPath}. + command_args(#state_t{command_args=CmdArgs}) -> CmdArgs. @@ -149,22 +159,28 @@ apply_profile(State=#state_t{default=Opts}, Profile) -> ProfileOpts = dict:from_list(proplists:get_value(Profile, ConfigProfiles, [])), State#state_t{opts=merge_opts(Profile, ProfileOpts, Opts1)}. -merge_opts(Profile, Opts1, Opts2) -> - dict:fold(fun(deps, Value, OptsAcc) -> - dict:store({deps, Profile}, Value, OptsAcc); - (Key, Value, OptsAcc) -> - case dict:fetch(Key, Opts2) of - OldValue when is_list(OldValue) -> - case io_lib:printable_list(Value) of +merge_opts(Profile, NewOpts, OldOpts) -> + io:format("Keys ~p~n", [dict:fetch_keys(NewOpts)]), + io:format("Keys ~p~n", [dict:fetch_keys(OldOpts)]), + Dict = dict:merge(fun(_Key, NewValue, OldValue) when is_list(NewValue) -> + case io_lib:printable_list(NewValue) of true -> - dict:store(Key, Value, OptsAcc); + NewValue; false -> - dict:store(Key, lists:keymerge(1, lists:keysort(1, OldValue), lists:keysort(1, Value)), OptsAcc) + lists:keymerge(1 + ,lists:keysort(1, OldValue) + ,lists:keysort(1, NewValue)) end; - _ -> - dict:store(Key, Value, OptsAcc) - end - end, Opts2, Opts1). + (_Key, NewValue, _OldValue) -> + NewValue + end, NewOpts, OldOpts), + case dict:find(deps, NewOpts) of + error -> + dict:store({deps, Profile}, [], Dict); + Deps -> + dict:store({deps, Profile}, Deps, Dict) + end. + dir(#state_t{dir=Dir}) -> Dir. diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index 7fe9241..ca35b26 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -258,7 +258,7 @@ cache_escript_files(State) -> fun(Name, _, GetBin, Acc) -> [{Name, GetBin()} | Acc] end, - [], rebar_state:get(State, escript)), + [], rebar_state:escript_path(State)), Files. %% Find all the template indexes hiding in the rebar3 escript. -- cgit v1.1 From 63461b45b53bae01b650b90924bc65f4bd9f46d3 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 15:36:57 -0600 Subject: don't use lock file for non-defualt profile deps --- src/rebar_prv_install_deps.erl | 13 +++++++------ src/rebar_state.erl | 4 +--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 9a3703c..692beaf 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -65,15 +65,16 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> - ?INFO("Verifying dependencies...", []), Profile = rebar_state:current_profile(State), + ?INFO("Verifying ~p dependencies...", [Profile]), ProjectApps = rebar_state:project_apps(State), try - {ok, SrcApps, State1} = case rebar_state:get(State, locks, []) of - [] -> - handle_deps(State, rebar_state:get(State, {deps, Profile}, [])); - Locks -> - handle_deps(State, Locks) + {ok, SrcApps, State1} = case {Profile, rebar_state:get(State, locks, [])} of + {default, Locks} -> + handle_deps(State, Locks); + _ -> + %% If not the default profile, ignore locks file + handle_deps(State, rebar_state:get(State, {deps, Profile}, [])) end, Source = ProjectApps ++ SrcApps, diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 1f522ef..7cdfd9a 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -160,8 +160,6 @@ apply_profile(State=#state_t{default=Opts}, Profile) -> State#state_t{opts=merge_opts(Profile, ProfileOpts, Opts1)}. merge_opts(Profile, NewOpts, OldOpts) -> - io:format("Keys ~p~n", [dict:fetch_keys(NewOpts)]), - io:format("Keys ~p~n", [dict:fetch_keys(OldOpts)]), Dict = dict:merge(fun(_Key, NewValue, OldValue) when is_list(NewValue) -> case io_lib:printable_list(NewValue) of true -> @@ -177,7 +175,7 @@ merge_opts(Profile, NewOpts, OldOpts) -> case dict:find(deps, NewOpts) of error -> dict:store({deps, Profile}, [], Dict); - Deps -> + {ok, Deps} -> dict:store({deps, Profile}, Deps, Dict) end. -- cgit v1.1 From cd46f5e28c611b330ea311022931325e45a8884c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 16:24:46 -0600 Subject: remove relx.config from release template --- priv/templates/release.template | 1 - 1 file changed, 1 deletion(-) diff --git a/priv/templates/release.template b/priv/templates/release.template index 0fe7918..e350130 100644 --- a/priv/templates/release.template +++ b/priv/templates/release.template @@ -7,7 +7,6 @@ {template, "sup.erl.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_sup.erl"}. {template, "otp_app.app.src.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}.app.src"}. {template, "relx_rebar.config.dtl", "{{name}}/rebar.config"}. -{template, "relx.config.dtl", "{{name}}/relx.config"}. {template, "sys.config.dtl", "{{name}}/config/sys.config"}. {template, "vm.args.dtl", "{{name}}/config/vm.args"}. {template, "gitignore.dtl", "{{name}}/.gitignore"}. -- cgit v1.1 From 90438fb1a33d273ae1c97dfa97f32d7357521a99 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 16:46:29 -0600 Subject: fix relx included rebar config typo --- priv/templates/relx_rebar.config.dtl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/templates/relx_rebar.config.dtl b/priv/templates/relx_rebar.config.dtl index 53ad24a..e7cb1fe 100644 --- a/priv/templates/relx_rebar.config.dtl +++ b/priv/templates/relx_rebar.config.dtl @@ -15,6 +15,6 @@ }. {profiles, [{prod, [{relx, [{dev_mode, true}, - {include_erts, false},]}] + {include_erts, false}]}] }] }. -- cgit v1.1 From cf8d63d860a55e97d8400845805c819ff341213a Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 17:00:01 -0600 Subject: in relx call only include deps dirs if they exist --- src/rebar_prv_release.erl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rebar_prv_release.erl b/src/rebar_prv_release.erl index d9cc40f..d382ab5 100644 --- a/src/rebar_prv_release.erl +++ b/src/rebar_prv_release.erl @@ -33,16 +33,18 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> Options = rebar_state:command_args(State), - DepsDir = [rebar_dir:default_deps_dir(State)], % rebar_dir:deps_dir(State)], + DepsDir = rebar_dir:default_deps_dir(State), + ProfileDepsDir = rebar_dir:deps_dir(State), + LibDirs = lists:usort(rebar_utils:filtermap(fun ec_file:exists/1, [DepsDir, ProfileDepsDir])), OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR), AllOptions = string:join(["release" | Options], " "), try case rebar_state:get(State, relx, []) of [] -> - relx:main([{lib_dirs, DepsDir} + relx:main([{lib_dirs, LibDirs} ,{output_dir, OutputDir}], AllOptions); Config -> - relx:main([{lib_dirs, DepsDir} + relx:main([{lib_dirs, LibDirs} ,{config, Config} ,{output_dir, OutputDir}], AllOptions) end, -- cgit v1.1 From 50f384715bf7452b0083d0392694a2f980173fd1 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 17:02:39 -0600 Subject: in relx tar call only include deps dirs if they exist --- src/rebar_prv_tar.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl index ae1942b..40a84e3 100644 --- a/src/rebar_prv_tar.erl +++ b/src/rebar_prv_tar.erl @@ -32,16 +32,18 @@ init(State) -> -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}. do(State) -> - OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR), Options = rebar_state:command_args(State), - DepsDir = rebar_dir:deps_dir(State), + DepsDir = rebar_dir:default_deps_dir(State), + ProfileDepsDir = rebar_dir:deps_dir(State), + LibDirs = lists:usort(rebar_utils:filtermap(fun ec_file:exists/1, [DepsDir, ProfileDepsDir])), + OutputDir = filename:join(rebar_dir:profile_dir(State), ?DEFAULT_RELEASE_DIR), AllOptions = string:join(["release", "tar" | Options], " "), case rebar_state:get(State, relx, []) of [] -> - relx:main([{lib_dirs, [DepsDir] + relx:main([{lib_dirs, LibDirs ,{output_dir, OutputDir}}], AllOptions); Config -> - relx:main([{lib_dirs, [DepsDir]} + relx:main([{lib_dirs, LibDirs} ,{config, Config} ,{output_dir, OutputDir}], AllOptions) end, -- cgit v1.1 From 2da9be88802e83a6cd577af6c3f1c1c804d3eadb Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 17:19:59 -0600 Subject: fix defaults for relx template --- priv/templates/relx_rebar.config.dtl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/priv/templates/relx_rebar.config.dtl b/priv/templates/relx_rebar.config.dtl index e7cb1fe..e7505eb 100644 --- a/priv/templates/relx_rebar.config.dtl +++ b/priv/templates/relx_rebar.config.dtl @@ -14,7 +14,7 @@ {extended_start_script, true}] }. -{profiles, [{prod, [{relx, [{dev_mode, true}, - {include_erts, false}]}] +{profiles, [{prod, [{relx, [{dev_mode, false}, + {include_erts, true}]}] }] }. -- cgit v1.1 From f77cbb7f508345c1352b957d75e0e350725f707c Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 17:47:41 -0600 Subject: don't lose defualt deps when creating current profile --- src/rebar_prv_install_deps.erl | 2 ++ src/rebar_prv_tar.erl | 2 +- src/rebar_state.erl | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 692beaf..20e7808 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -70,6 +70,8 @@ do(State) -> ProjectApps = rebar_state:project_apps(State), try {ok, SrcApps, State1} = case {Profile, rebar_state:get(State, locks, [])} of + {default, []} -> + handle_deps(State, rebar_state:get(State, {deps, Profile}, [])); {default, Locks} -> handle_deps(State, Locks); _ -> diff --git a/src/rebar_prv_tar.erl b/src/rebar_prv_tar.erl index 40a84e3..0225e19 100644 --- a/src/rebar_prv_tar.erl +++ b/src/rebar_prv_tar.erl @@ -12,7 +12,7 @@ -include("rebar.hrl"). -define(PROVIDER, tar). --define(DEPS, [compile]). +-define(DEPS, [{compile, default}, compile]). %% =================================================================== %% Public API diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 7cdfd9a..b412c27 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -152,6 +152,10 @@ command_parsed_args(State, CmdArgs) -> State#state_t{command_parsed_args=CmdArgs}. %% Only apply profiles to the default profile +apply_profile(State=#state_t{default=Opts}, default) -> + Deps = rebar_state:get(State, deps, []), + Opts1 = dict:store({deps, default}, Deps, Opts), + State#state_t{opts=Opts1}; apply_profile(State=#state_t{default=Opts}, Profile) -> ConfigProfiles = rebar_state:get(State, profiles, []), Deps = rebar_state:get(State, deps, []), @@ -172,6 +176,7 @@ merge_opts(Profile, NewOpts, OldOpts) -> (_Key, NewValue, _OldValue) -> NewValue end, NewOpts, OldOpts), + case dict:find(deps, NewOpts) of error -> dict:store({deps, Profile}, [], Dict); -- cgit v1.1 From b849b36b5ecabe83d9c72f4370d7bc44c57f84e6 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 6 Dec 2014 19:58:24 -0600 Subject: only add lock if default profile --- src/rebar_prv_install_deps.erl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 20e7808..5375f4b 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -174,11 +174,16 @@ update_pkg_deps(Pkgs, Packages, Update, Seen, State) -> maybe_lock(AppInfo, Seen, State) -> Name = rebar_app_info:name(AppInfo), - case sets:is_element(Name, Seen) of - false -> - {sets:add_element(Name, Seen), - rebar_state:lock(State, AppInfo)}; - true -> + case rebar_state:current_profile(State) of + default -> + case sets:is_element(Name, Seen) of + false -> + {sets:add_element(Name, Seen), + rebar_state:lock(State, AppInfo)}; + true -> + {Seen, State} + end; + _ -> {Seen, State} end. -- cgit v1.1