Browse Source

Merge pull request #2276 from tsloughter/checkouts-dir

output checkouts compilation to _build/<profile>/checkouts/
pull/2281/head
Tristan Sloughter 5 years ago
committed by GitHub
parent
commit
2e5c2c9cfd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 10 deletions
  1. +2
    -0
      rebar.config.sample
  2. +1
    -0
      src/rebar.hrl
  3. +4
    -1
      src/rebar_app_utils.erl
  4. +13
    -0
      src/rebar_dir.erl
  5. +2
    -0
      src/rebar_env.erl
  6. +4
    -0
      src/rebar_prv_plugins.erl
  7. +1
    -8
      test/rebar_compile_SUITE.erl
  8. +1
    -1
      test/rebar_test_utils.erl

+ 2
- 0
rebar.config.sample View File

@ -122,6 +122,8 @@
{root_dir, "."}. {root_dir, "."}.
%% where checkout dependencies are to be located %% where checkout dependencies are to be located
{checkouts_dir, "_checkouts"}. {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 %% directory in '<base_dir>/<profile>/' where plugins go
{plugins_dir, "plugins"}. {plugins_dir, "plugins"}.
%% directories where OTP applications for the project can be located %% directories where OTP applications for the project can be located

+ 1
- 0
src/rebar.hrl View File

@ -18,6 +18,7 @@
-define(DEFAULT_ROOT_DIR, "."). -define(DEFAULT_ROOT_DIR, ".").
-define(DEFAULT_PROJECT_APP_DIRS, ["apps/*", "lib/*", "."]). -define(DEFAULT_PROJECT_APP_DIRS, ["apps/*", "lib/*", "."]).
-define(DEFAULT_CHECKOUTS_DIR, "_checkouts"). -define(DEFAULT_CHECKOUTS_DIR, "_checkouts").
-define(DEFAULT_CHECKOUTS_OUT_DIR, "checkouts").
-define(DEFAULT_DEPS_DIR, "lib"). -define(DEFAULT_DEPS_DIR, "lib").
-define(DEFAULT_PLUGINS_DIR, "plugins"). -define(DEFAULT_PLUGINS_DIR, "plugins").
-define(DEFAULT_TEST_DEPS_DIR, "test/lib"). -define(DEFAULT_TEST_DEPS_DIR, "test/lib").

+ 4
- 1
src/rebar_app_utils.erl View File

@ -257,7 +257,10 @@ dep_to_app(Parent, DepsDir, Name, Vsn, Source0, IsLock, State) ->
CheckoutsDir = rebar_utils:to_list(rebar_dir:checkouts_dir(State, Name)), CheckoutsDir = rebar_utils:to_list(rebar_dir:checkouts_dir(State, Name)),
AppInfo = case rebar_app_info:discover(CheckoutsDir) of AppInfo = case rebar_app_info:discover(CheckoutsDir) of
{ok, App} -> {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 -> not_found ->
Dir = rebar_utils:to_list(filename:join([DepsDir, Name, SubDir])), Dir = rebar_utils:to_list(filename:join([DepsDir, Name, SubDir])),
{ok, AppInfo0} = {ok, AppInfo0} =

+ 13
- 0
src/rebar_dir.erl View File

@ -9,6 +9,8 @@
root_dir/1, root_dir/1,
checkouts_dir/1, checkouts_dir/1,
checkouts_dir/2, checkouts_dir/2,
checkouts_out_dir/1,
checkouts_out_dir/2,
plugins_dir/1, plugins_dir/1,
lib_dirs/1, lib_dirs/1,
home_dir/0, home_dir/0,
@ -97,6 +99,17 @@ checkouts_dir(State) ->
checkouts_dir(State, App) -> checkouts_dir(State, App) ->
filename:join(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. %% @doc Returns the directory where plugins are located.
-spec plugins_dir(rebar_state:t()) -> file:filename_all(). -spec plugins_dir(rebar_state:t()) -> file:filename_all().
plugins_dir(State) -> plugins_dir(State) ->

+ 2
- 0
src/rebar_env.erl View File

@ -12,6 +12,7 @@
%% REBAR_BUILD_DIR = rebar_dir:base_dir/1 %% REBAR_BUILD_DIR = rebar_dir:base_dir/1
%% REBAR_ROOT_DIR = rebar_dir:root_dir/1 %% REBAR_ROOT_DIR = rebar_dir:root_dir/1
%% REBAR_CHECKOUTS_DIR = rebar_dir:checkouts_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_PLUGINS_DIR = rebar_dir:plugins_dir/1
%% REBAR_GLOBAL_CONFIG_DIR = rebar_dir:global_config_dir/1 %% REBAR_GLOBAL_CONFIG_DIR = rebar_dir:global_config_dir/1
%% REBAR_GLOBAL_CACHE_DIR = rebar_dir:global_cache_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_BUILD_DIR", filename:absname(rebar_dir:base_dir(State))},
{"REBAR_ROOT_DIR", filename:absname(rebar_dir:root_dir(State))}, {"REBAR_ROOT_DIR", filename:absname(rebar_dir:root_dir(State))},
{"REBAR_CHECKOUTS_DIR", filename:absname(rebar_dir:checkouts_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_PLUGINS_DIR", filename:absname(rebar_dir:plugins_dir(State))},
{"REBAR_GLOBAL_CONFIG_DIR", filename:absname(rebar_dir:global_config_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))}, {"REBAR_GLOBAL_CACHE_DIR", filename:absname(rebar_dir:global_cache_dir(Opts))},

+ 4
- 0
src/rebar_prv_plugins.erl View File

@ -44,6 +44,10 @@ do(State) ->
Plugins = rebar_state:get(State, plugins, []), Plugins = rebar_state:get(State, plugins, []),
ProjectPlugins = rebar_state:get(State, project_plugins, []), ProjectPlugins = rebar_state:get(State, project_plugins, []),
PluginsDirs = filelib:wildcard(filename:join(rebar_dir:plugins_dir(State), "*")), 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), "*")), CheckoutsDirs = filelib:wildcard(filename:join(rebar_dir:checkouts_dir(State), "*")),
Apps = rebar_app_discover:find_apps(CheckoutsDirs++PluginsDirs, SrcDirs, all, State), Apps = rebar_app_discover:find_apps(CheckoutsDirs++PluginsDirs, SrcDirs, all, State),
display_plugins("Local plugins", Apps, Plugins ++ ProjectPlugins), display_plugins("Local plugins", Apps, Plugins ++ ProjectPlugins),

+ 1
- 8
test/rebar_compile_SUITE.erl View File

@ -48,7 +48,7 @@ all() ->
groups() -> groups() ->
[{basic_app, [], [build_basic_app, paths_basic_app, clean_basic_app]}, [{basic_app, [], [build_basic_app, paths_basic_app, clean_basic_app]},
{release_apps, [], [build_release_apps, paths_release_apps, clean_release_apps]}, {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]}, {checkout_deps, [], [build_checkout_deps, paths_checkout_deps]},
{basic_srcdirs, [], [build_basic_srcdirs, paths_basic_srcdirs]}, {basic_srcdirs, [], [build_basic_srcdirs, paths_basic_srcdirs]},
{release_srcdirs, [], [build_release_srcdirs, {release_srcdirs, [], [build_release_srcdirs,
@ -264,13 +264,6 @@ build_release_apps(Config) ->
{ok, [{app, Name1}, {app, Name2}]} {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) -> build_checkout_deps(Config) ->
AppDir = ?config(apps, Config), AppDir = ?config(apps, Config),
[Name1, Name2] = ?config(app_names, Config), [Name1, Name2] = ?config(app_names, Config),

+ 1
- 1
test/rebar_test_utils.erl View File

@ -264,7 +264,7 @@ check_results(AppDir, Expected, ProfileRun) ->
filelib:is_dir(D)], filelib:is_dir(D)],
PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "plugins", "*"])), PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "plugins", "*"])),
GlobalPluginDirs = filelib:wildcard(filename:join([AppDir, "global", "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"]), LockFile = filename:join([AppDir, "rebar.lock"]),
Locks = lists:flatten(rebar_config:consult_lock_file(LockFile)), Locks = lists:flatten(rebar_config:consult_lock_file(LockFile)),

Loading…
Cancel
Save