diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/relx.erl | 4 | ||||
-rw-r--r-- | src/rlx_cmd_args.erl | 30 | ||||
-rw-r--r-- | src/rlx_state.erl | 2 |
4 files changed, 28 insertions, 9 deletions
@@ -55,6 +55,7 @@ Options | -u | --upfrom | string | | The release to upgrade from. Only valid with relup target | | -o | --output-dir | string | ./ | The output directory for the release | | -l | --lib-dir | string | | Additional dirs to search for OTP apps | +| -p | --path | string | | Additional dirs to add to Erlang code path | | | --disable-default-libs | boolean | false | Disable use of the default system added lib dirs | | -V | --verbose | integer | 0 | The verbosity level between 0 and 2 | | -a | --override_app | string | | An app name and a directory to override in the form appname:dir | diff --git a/src/relx.erl b/src/relx.erl index bc3fbaa..bc311f5 100644 --- a/src/relx.erl +++ b/src/relx.erl @@ -182,7 +182,9 @@ opt_spec_list() -> {help, $h, "help", undefined, "Print usage"}, {lib_dir, $l, "lib-dir", string, - "Additional dirs that should be searched for OTP Apps"}, + "Additional dir that should be searched for OTP Apps"}, + {path, $p, "path", string, + "Additional dir to add to the code path"}, {disable_default_libs, undefined, "disable-default-libs", {boolean, false}, "Disable the default system added lib dirs (means you must add them all manually"}, diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl index d144953..619163a 100644 --- a/src/rlx_cmd_args.erl +++ b/src/rlx_cmd_args.erl @@ -64,7 +64,9 @@ format_error({invalid_option_arg, Arg}) -> {lib_dir, LibDir} -> io_lib:format("Invalid Library Directory argument -n ~p~n", [LibDir]); {log_level, LogLevel} -> - io_lib:format("Invalid Library Directory argument -n ~p~n", [LogLevel]) + io_lib:format("Invalid Log Level argument -n ~p~n", [LogLevel]); + {path, Path} -> + io_lib:format("Invalid code path argument -n ~p~n", [Path]) end; format_error({invalid_config_file, Config}) -> io_lib:format("Invalid configuration file specified: ~s", [Config]); @@ -261,20 +263,34 @@ create_upfrom(Opts, Acc) -> create_caller(Opts, Acc) -> case proplists:get_value(caller, Opts, api) of "command_line" -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); "commandline" -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); "api" -> - {ok, [{caller, api} | Acc]}; + create_paths(Opts, [{caller, api} | Acc]); api -> - {ok, [{caller, api} | Acc]}; + create_paths(Opts, [{caller, api} | Acc]); commandline -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); command_line -> - {ok, [{caller, command_line} | Acc]}; + create_paths(Opts, [{caller, command_line} | Acc]); Caller -> ?RLX_ERROR({invalid_caller, Caller}) end. + +-spec create_paths([getopt:option()], rlx_state:cmd_args()) -> + {ok, rlx_state:cmd_args()} | relx:error(). +create_paths(Opts, Acc) -> + Dirs = proplists:get_all_values(path, Opts) ++ + proplists:get_value(paths, Opts, []), + case check_lib_dirs(Dirs) of + Error = {error, _} -> + Error; + ok -> + code:add_pathsa([filename:absname(Path) || Path <- Dirs]), + {ok, Acc} + end. + -spec check_lib_dirs([string()]) -> ok | relx:error(). check_lib_dirs([]) -> ok; diff --git a/src/rlx_state.erl b/src/rlx_state.erl index 138705c..b35baf3 100644 --- a/src/rlx_state.erl +++ b/src/rlx_state.erl @@ -177,7 +177,7 @@ lib_dirs(#state_t{lib_dirs=LibDir}) -> -spec add_lib_dirs(t(), [file:name()]) -> t(). add_lib_dirs(State=#state_t{lib_dirs=LibDir}, Dirs) -> - State#state_t{lib_dirs=lists:merge(lists:sort(LibDir), lists:sort(Dirs))}. + State#state_t{lib_dirs=lists:umerge(lists:sort(LibDir), lists:sort(Dirs))}. -spec goals(t()) -> [rlx_depsolver:constraint()]. goals(#state_t{goals=TS}) -> |