diff options
author | Eric <[email protected]> | 2013-01-04 10:33:54 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2013-01-04 10:52:19 -0500 |
commit | 3a5cb6adf215e760068c9d3e7a07eb4f971cabf0 (patch) | |
tree | 718eb042995b56fd2145c0d7a932d1aecd53e0d5 | |
parent | 344fa86b23205eebc3233cf9c69a8e9e145714ac (diff) | |
download | relx-3a5cb6adf215e760068c9d3e7a07eb4f971cabf0.tar.gz relx-3a5cb6adf215e760068c9d3e7a07eb4f971cabf0.tar.bz2 relx-3a5cb6adf215e760068c9d3e7a07eb4f971cabf0.zip |
provide the erlang lib dir and cwd as working libraries
This happens for every call unless the user passes
--disable-default-libs to relcool or {disable_default_libs, true} in
the relcool config.
-rw-r--r-- | src/rcl_cmd_args.erl | 9 | ||||
-rw-r--r-- | src/rcl_prv_discover.erl | 29 | ||||
-rw-r--r-- | src/rcl_state.erl | 4 | ||||
-rw-r--r-- | src/relcool.erl | 6 | ||||
-rw-r--r-- | test/rclt_discover_SUITE.erl | 11 |
5 files changed, 29 insertions, 30 deletions
diff --git a/src/rcl_cmd_args.erl b/src/rcl_cmd_args.erl index 9d829d3..6340201 100644 --- a/src/rcl_cmd_args.erl +++ b/src/rcl_cmd_args.erl @@ -170,11 +170,16 @@ create_root_dir(Opts, Acc) -> case Dir of undefined -> {ok, Cwd} = file:get_cwd(), - {ok, [{root_dir, Cwd} | Acc]}; + create_disable_default_libs(Opts, [{root_dir, Cwd} | Acc]); _ -> - {ok, [{root_dir, Dir} | Acc]} + create_disable_default_libs(Opts, [{root_dir, Dir} | Acc]) end. +-spec create_disable_default_libs([getopt:option()], rcl_state:cmd_args()) -> + {ok, rcl_state:cmd_args()} | relcool:error(). +create_disable_default_libs(Opts, Acc) -> + Def = proplists:get_value(disable_default_libs, Opts, false), + {ok, [{disable_default_libs, Def} | Acc]}. -spec check_lib_dirs([string()]) -> ok | relcool:error(). check_lib_dirs([]) -> diff --git a/src/rcl_prv_discover.erl b/src/rcl_prv_discover.erl index 6ff50ed..4e7ce72 100644 --- a/src/rcl_prv_discover.erl +++ b/src/rcl_prv_discover.erl @@ -112,29 +112,20 @@ setup_overrides(State, AppMetas0) -> get_lib_dirs(State) -> LibDirs0 = rcl_state:lib_dirs(State), - add_rebar_deps_dir(State, LibDirs0). - --spec add_rebar_deps_dir(rcl_state:t(), [file:name()]) -> [file:name()]. -add_rebar_deps_dir(State, LibDirs) -> - ExcludeRebar = rcl_state:get(State, discover_exclude_rebar, false), - case ExcludeRebar of + case rcl_state:get(State, disable_default_libs, false) of true -> - add_system_lib_dir(State, LibDirs); + LibDirs0; false -> - %% Check to see if there is a rebar.config. If so then look for a deps - %% dir. If both are there then we add that to the lib dirs. - Root = rcl_state:root_dir(State), - - RebarConfig = filename:join([Root, "rebar.config"]), - DepsDir = filename:join([Root, "deps"]), - case filelib:is_regular(RebarConfig) andalso filelib:is_dir(DepsDir) of - true -> - add_system_lib_dir(State, [filename:absname(Root) | LibDirs]); - false -> - add_system_lib_dir(State, LibDirs) - end + add_current_dir(State, LibDirs0) end. +-spec add_current_dir(rcl_state:t(), [file:name()]) -> [file:name()]. +add_current_dir(State, LibDirs) -> + %% Check to see if there is a rebar.config. If so then look for a deps + %% dir. If both are there then we add that to the lib dirs. + Root = rcl_state:root_dir(State), + add_system_lib_dir(State, [filename:absname(Root) | LibDirs]). + -spec add_system_lib_dir(rcl_state:t(), [file:name()]) -> [file:name()]. add_system_lib_dir(State, LibDirs) -> ExcludeSystem = rcl_state:get(State, discover_exclude_system, false), diff --git a/src/rcl_state.erl b/src/rcl_state.erl index 28effbd..842b635 100644 --- a/src/rcl_state.erl +++ b/src/rcl_state.erl @@ -108,7 +108,9 @@ new(PropList, Target) when erlang:is_list(PropList) -> root_dir = proplists:get_value(root_dir, PropList, Root), default_release={proplists:get_value(relname, PropList, undefined), proplists:get_value(relvsn, PropList, undefined)}}, - create_logic_providers(State0). + rcl_state:put(create_logic_providers(State0), + disable_default_libs, + proplists:get_value(disable_default_libs, PropList, false)). %% @doc the application overrides for the system -spec overrides(t()) -> [{AppName::atom(), Directory::file:filename()}]. diff --git a/src/relcool.erl b/src/relcool.erl index 9fb9240..a6b30a3 100644 --- a/src/relcool.erl +++ b/src/relcool.erl @@ -113,8 +113,7 @@ do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Con -spec opt_spec_list() -> [getopt:option_spec()]. opt_spec_list() -> - [ - {relname, $n, "relname", string, + [{relname, $n, "relname", string, "Specify the name for the release that will be generated"}, {relvsn, $v, "relvsn", string, "Specify the version for the release"}, {goals, $g, "goal", string, @@ -123,6 +122,9 @@ opt_spec_list() -> "The output directory for the release. This is `./` by default."}, {lib_dir, $l, "lib-dir", string, "Additional dirs that should be searched for OTP Apps"}, + {disable_default_libs, undefined, "disable-default-libs", + {boolean, false}, + "Disable the default system added lib dirs (means you must add them all manually"}, {log_level, $V, "verbose", {integer, 0}, "Verbosity level, maybe between 0 and 2"}, {root_dir, $r, "root", string, "The project root directory"}]. diff --git a/test/rclt_discover_SUITE.erl b/test/rclt_discover_SUITE.erl index 63d7841..6b61840 100644 --- a/test/rclt_discover_SUITE.erl +++ b/test/rclt_discover_SUITE.erl @@ -62,8 +62,8 @@ normal_case(Config) -> end)(App) || App <- - [{create_random_name("lib_app1_"), create_random_vsn()} - || _ <- lists:seq(1, 100)]], + [{create_random_name("lib_app1_"), create_random_vsn()} + || _ <- lists:seq(1, 100)]], LibDir2 = proplists:get_value(lib2, Config), Apps2 = [(fun({Name, Vsn}) -> @@ -71,10 +71,9 @@ normal_case(Config) -> end)(App) || App <- [{create_random_name("lib_app2_"), create_random_vsn()} - || _ <- lists:seq(1, 100)]], - State0 = rcl_state:put(rcl_state:put(proplists:get_value(state, Config), - discover_exclude_rebar, true), - discover_exclude_system, true), + || _ <- lists:seq(1, 100)]], + State0 = rcl_state:put(proplists:get_value(state, Config), + disable_default_libs, true), {DiscoverProvider, {ok, State1}} = rcl_provider:new(rcl_prv_discover, State0), {ok, State2} = rcl_provider:do(DiscoverProvider, State1), lists:foreach(fun(App) -> |