Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output checkouts compilation to _build/<profile>/checkouts/ #2276

Merged
merged 5 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rebar.config.sample
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
{root_dir, "."}.
%% where checkout dependencies are to be located
{checkouts_dir, "_checkouts"}.
%% where, under <base_dir>/<profile> checkout dependencies are to be built
{checkouts_out_dir, "checkouts"}.
%% directory in '<base_dir>/<profile>/' where plugins go
{plugins_dir, "plugins"}.
%% directories where OTP applications for the project can be located
Expand Down
1 change: 1 addition & 0 deletions src/rebar.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down
5 changes: 4 additions & 1 deletion src/rebar_app_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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} =
Expand Down
13 changes: 13 additions & 0 deletions src/rebar_dir.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) ->
Expand Down
2 changes: 2 additions & 0 deletions src/rebar_env.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))},
Expand Down
4 changes: 4 additions & 0 deletions src/rebar_prv_plugins.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 1 addition & 8 deletions test/rebar_compile_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion test/rebar_test_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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)),

Expand Down