diff --git a/rebar.config.sample b/rebar.config.sample index c255e49b0..aa1575f03 100644 --- a/rebar.config.sample +++ b/rebar.config.sample @@ -122,6 +122,8 @@ {root_dir, "."}. %% where checkout dependencies are to be located {checkouts_dir, "_checkouts"}. +%% where, under / checkout dependencies are to be built +{checkouts_out_dir, "checkouts"}. %% directory in '//' where plugins go {plugins_dir, "plugins"}. %% directories where OTP applications for the project can be located diff --git a/src/rebar.hrl b/src/rebar.hrl index edc821620..c03a2c8fa 100644 --- a/src/rebar.hrl +++ b/src/rebar.hrl @@ -18,6 +18,7 @@ -define(DEFAULT_ROOT_DIR, "."). -define(DEFAULT_PROJECT_APP_DIRS, ["apps/*", "lib/*", "."]). -define(DEFAULT_CHECKOUTS_DIR, "_checkouts"). +-define(DEFAULT_CHECKOUTS_OUT_DIR, "checkouts"). -define(DEFAULT_DEPS_DIR, "lib"). -define(DEFAULT_PLUGINS_DIR, "plugins"). -define(DEFAULT_TEST_DEPS_DIR, "test/lib"). diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 0b16ae056..619a34e88 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -255,7 +255,10 @@ dep_to_app(Parent, DepsDir, Name, Vsn, Source, IsLock, State) -> CheckoutsDir = rebar_utils:to_list(rebar_dir:checkouts_dir(State, Name)), AppInfo = case rebar_app_info:discover(CheckoutsDir) of {ok, App} -> - rebar_app_info:source(rebar_app_info:is_checkout(App, true), checkout); + OutDir = filename:join(rebar_dir:checkouts_out_dir(State), Name), + rebar_app_info:out_dir( + rebar_app_info:source( + rebar_app_info:is_checkout(App, true), checkout), OutDir); not_found -> Dir = rebar_utils:to_list(filename:join(DepsDir, Name)), {ok, AppInfo0} = diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl index 9e2a540c1..80f9294fa 100644 --- a/src/rebar_dir.erl +++ b/src/rebar_dir.erl @@ -9,6 +9,8 @@ root_dir/1, checkouts_dir/1, checkouts_dir/2, + checkouts_out_dir/1, + checkouts_out_dir/2, plugins_dir/1, lib_dirs/1, home_dir/0, @@ -97,6 +99,17 @@ checkouts_dir(State) -> checkouts_dir(State, App) -> filename:join(checkouts_dir(State), App). +%% @doc returns the location of the directory checkouts are built to +-spec checkouts_out_dir(rebar_state:t()) -> file:filename_all(). +checkouts_out_dir(State) -> + filename:join(base_dir(State), rebar_state:get(State, checkouts_out_dir, ?DEFAULT_CHECKOUTS_OUT_DIR)). + +%% @doc returns the expected location of a given app in the checkouts +%% directory for the project. +-spec checkouts_out_dir(rebar_state:t(), file:filename_all()) -> file:filename_all(). +checkouts_out_dir(State, App) -> + filename:join(checkouts_out_dir(State), App). + %% @doc Returns the directory where plugins are located. -spec plugins_dir(rebar_state:t()) -> file:filename_all(). plugins_dir(State) -> diff --git a/src/rebar_env.erl b/src/rebar_env.erl index e9adafbb8..0291a5e6a 100644 --- a/src/rebar_env.erl +++ b/src/rebar_env.erl @@ -12,6 +12,7 @@ %% REBAR_BUILD_DIR = rebar_dir:base_dir/1 %% REBAR_ROOT_DIR = rebar_dir:root_dir/1 %% REBAR_CHECKOUTS_DIR = rebar_dir:checkouts_dir/1 +%% REBAR_CHECKOUTS_OUT_DIR = rebar_dir:checkouts_out_dir/1 %% REBAR_PLUGINS_DIR = rebar_dir:plugins_dir/1 %% REBAR_GLOBAL_CONFIG_DIR = rebar_dir:global_config_dir/1 %% REBAR_GLOBAL_CACHE_DIR = rebar_dir:global_cache_dir/1 @@ -42,6 +43,7 @@ create_env(State, Opts) -> {"REBAR_BUILD_DIR", filename:absname(rebar_dir:base_dir(State))}, {"REBAR_ROOT_DIR", filename:absname(rebar_dir:root_dir(State))}, {"REBAR_CHECKOUTS_DIR", filename:absname(rebar_dir:checkouts_dir(State))}, + {"REBAR_CHECKOUTS_OUT_DIR", filename:absname(rebar_dir:checkouts_out_dir(State))}, {"REBAR_PLUGINS_DIR", filename:absname(rebar_dir:plugins_dir(State))}, {"REBAR_GLOBAL_CONFIG_DIR", filename:absname(rebar_dir:global_config_dir(State))}, {"REBAR_GLOBAL_CACHE_DIR", filename:absname(rebar_dir:global_cache_dir(Opts))}, diff --git a/src/rebar_prv_plugins.erl b/src/rebar_prv_plugins.erl index 00457a7a0..d9abe9159 100644 --- a/src/rebar_prv_plugins.erl +++ b/src/rebar_prv_plugins.erl @@ -44,6 +44,10 @@ do(State) -> Plugins = rebar_state:get(State, plugins, []), ProjectPlugins = rebar_state:get(State, project_plugins, []), PluginsDirs = filelib:wildcard(filename:join(rebar_dir:plugins_dir(State), "*")), + + %% use `checkouts_dir' and not `checkouts_out_dir'. Since we use `all' in `find_apps' + %% so it doesn't need to be built and the apps in `checkouts_dir' could be old + %% because the user removing from `_checkouts/' doesn't cause removal of the output CheckoutsDirs = filelib:wildcard(filename:join(rebar_dir:checkouts_dir(State), "*")), Apps = rebar_app_discover:find_apps(CheckoutsDirs++PluginsDirs, SrcDirs, all, State), display_plugins("Local plugins", Apps, Plugins ++ ProjectPlugins), diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 55e0cda5c..3ec818f41 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -48,7 +48,7 @@ all() -> groups() -> [{basic_app, [], [build_basic_app, paths_basic_app, clean_basic_app]}, {release_apps, [], [build_release_apps, paths_release_apps, clean_release_apps]}, - {checkout_apps, [], [build_checkout_apps, paths_checkout_apps]}, + {checkout_apps, [], [paths_checkout_apps]}, {checkout_deps, [], [build_checkout_deps, paths_checkout_deps]}, {basic_srcdirs, [], [build_basic_srcdirs, paths_basic_srcdirs]}, {release_srcdirs, [], [build_release_srcdirs, @@ -264,13 +264,6 @@ build_release_apps(Config) -> {ok, [{app, Name1}, {app, Name2}]} ). -build_checkout_apps(Config) -> - [Name1, Name2] = ?config(app_names, Config), - rebar_test_utils:run_and_check( - Config, [], ["compile"], - {ok, [{app, Name1}, {checkout, Name2}]} - ). - build_checkout_deps(Config) -> AppDir = ?config(apps, Config), [Name1, Name2] = ?config(app_names, Config), diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 0f5948d24..d47f0859b 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -248,7 +248,7 @@ check_results(AppDir, Expected, ProfileRun) -> BuildDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "lib", "*"])), PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "plugins", "*"])), GlobalPluginDirs = filelib:wildcard(filename:join([AppDir, "global", "plugins", "*"])), - CheckoutsDirs = filelib:wildcard(filename:join([AppDir, "_checkouts", "*"])), + CheckoutsDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "checkouts", "*"])), LockFile = filename:join([AppDir, "rebar.lock"]), Locks = lists:flatten(rebar_config:consult_lock_file(LockFile)),