diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-02-25 09:49:45 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-02-28 09:56:19 -0600 |
commit | d4c2332aabb4337b49bb3ef03793408c58afd5d4 (patch) | |
tree | 48f1e012bc761e3fa8d257511e4da3c073fff65a | |
parent | 71d70fca1f1182b8f4919e2b3f5a7ff277700271 (diff) |
make base_dir for a run include the profiles in path, link to shared deps
-rw-r--r-- | src/rebar.hrl | 1 | ||||
-rw-r--r-- | src/rebar3.erl | 2 | ||||
-rw-r--r-- | src/rebar_dir.erl | 5 | ||||
-rw-r--r-- | src/rebar_prv_install_deps.erl | 14 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 6 |
5 files changed, 21 insertions, 7 deletions
diff --git a/src/rebar.hrl b/src/rebar.hrl index bbd9a2f..0dfcad0 100644 --- a/src/rebar.hrl +++ b/src/rebar.hrl @@ -14,7 +14,6 @@ -define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))). -define(DEFAULT_BASE_DIR, "_build"). --define(DEFAULT_PROFILE_DIR, "default"). -define(DEFAULT_PROJECT_APP_DIRS, ["_checkouts", "apps", "lib", "."]). -define(DEFAULT_DEPS_DIR, "lib"). -define(DEFAULT_PLUGINS_DIR, "plugins"). diff --git a/src/rebar3.erl b/src/rebar3.erl index bd52fee..d7597cd 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -120,7 +120,7 @@ run_aux(State, GlobalPluginProviders, RawArgs) -> end, %% Process each command, resetting any state between each one - BaseDir = rebar_dir:base_dir(State2), + BaseDir = rebar_state:get(State, base_dir, ?DEFAULT_BASE_DIR), State3 = rebar_state:set(State2, base_dir, filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)), diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl index 3962bf8..388b4c6 100644 --- a/src/rebar_dir.erl +++ b/src/rebar_dir.erl @@ -23,7 +23,10 @@ -spec base_dir(rebar_state:t()) -> file:filename_all(). base_dir(State) -> - rebar_state:get(State, base_dir, ?DEFAULT_BASE_DIR). + Profiles = rebar_state:current_profiles(State), + ProfilesStrings = [ec_cnv:to_list(P) || P <- Profiles], + ProfilesDir = string:join(ProfilesStrings, "+"), + filename:join(rebar_state:get(State, base_dir, ?DEFAULT_BASE_DIR), ProfilesDir). -spec deps_dir(rebar_state:t()) -> file:filename_all(). deps_dir(State) -> diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index ab4cca1..952043e 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -374,7 +374,15 @@ maybe_fetch(AppInfo, Upgrade, Seen, State) -> false -> case rebar_app_discover:find_app(AppDir, all) of false -> - fetch_app(AppInfo, AppDir, State); + case in_default(AppInfo, State) of + false -> + fetch_app(AppInfo, AppDir, State); + {true, FoundApp} -> + ?INFO("Linking ~s to ~s", [rebar_app_info:dir(FoundApp), AppDir]), + filelib:ensure_dir(AppDir), + ok = file:make_symlink(rebar_app_info:dir(FoundApp), AppDir), + true + end; {true, _} -> case sets:is_element(rebar_app_info:name(AppInfo), Seen) of true -> @@ -392,6 +400,10 @@ in_checkouts(AppInfo) -> error -> false end. +in_default(AppInfo, State) -> + Name = ec_cnv:to_list(rebar_app_info:name(AppInfo)), + DefaultAppDir = filename:join([rebar_state:get(State, base_dir), "default", "lib", Name]), + rebar_app_discover:find_app(DefaultAppDir, all). -spec parse_deps(binary(), list(), list(), list(), integer()) -> {[rebar_app_info:t()], [pkg_dep()]}. parse_deps(DepsDir, Deps, State, Locks, Level) -> diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index a036619..8dfb7ad 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -142,7 +142,7 @@ top_level_deps([{{Name, Vsn, Ref}, _} | Deps]) -> %%% Helpers %%% %%%%%%%%%%%%%%% check_results(AppDir, Expected) -> - BuildDir = filename:join([AppDir, "_build", "lib"]), + BuildDirs = filelib:wildcard(filename:join([AppDir, "_build", "*", "lib"])), CheckoutsDir = filename:join([AppDir, "_checkouts"]), LockFile = filename:join([AppDir, "rebar.lock"]), Locks = lists:flatten(rebar_config:consult_file(LockFile)), @@ -152,7 +152,7 @@ check_results(AppDir, Expected) -> AppsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- Apps], InvalidAppsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- InvalidApps], ValidAppsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- ValidApps], - Deps = rebar_app_discover:find_apps([BuildDir], all), + Deps = rebar_app_discover:find_apps(BuildDirs, all), DepsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- Deps], Checkouts = rebar_app_discover:find_apps([CheckoutsDir], all), CheckoutsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- Checkouts], @@ -217,7 +217,7 @@ check_results(AppDir, Expected) -> {ok, Cwd} = file:get_cwd(), try file:set_cwd(AppDir), - ReleaseDir = filename:join([AppDir, "_build", "rel"]), + [ReleaseDir] = filelib:wildcard(filename:join([AppDir, "_build", "*", "rel"])), RelxState = rlx_state:new("", [], []), RelxState1 = rlx_state:base_output_dir(RelxState, ReleaseDir), {ok, RelxState2} = rlx_prv_app_discover:do(RelxState1), |