diff options
author | Eric <[email protected]> | 2012-12-30 20:01:39 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2012-12-30 20:01:39 -0500 |
commit | 60e04b48942a8d2e0d401ae5deb84e4dc61d05f5 (patch) | |
tree | f904aa417d628c4b2183099995ea0b28c478bbc6 | |
parent | 7313be05d2805a3cf699e25d160401fd95635e33 (diff) | |
download | relx-60e04b48942a8d2e0d401ae5deb84e4dc61d05f5.tar.gz relx-60e04b48942a8d2e0d401ae5deb84e4dc61d05f5.tar.bz2 relx-60e04b48942a8d2e0d401ae5deb84e4dc61d05f5.zip |
support the ability to specify a root directory
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/rcl_cmd_args.erl | 15 | ||||
-rw-r--r-- | src/relcool.erl | 25 | ||||
-rw-r--r-- | test/rclt_release_SUITE.erl | 8 |
4 files changed, 43 insertions, 8 deletions
@@ -21,6 +21,9 @@ additional specification information for releases. # OPTIONS +-r *STRING*, \--root *STRING* +: Specify the root directory for the project (if different from cwd) + -n *STRING*, \--relname *STRING* : Specify the name for the release that will be generated diff --git a/src/rcl_cmd_args.erl b/src/rcl_cmd_args.erl index 3bb9f41..9d829d3 100644 --- a/src/rcl_cmd_args.erl +++ b/src/rcl_cmd_args.erl @@ -160,9 +160,22 @@ create_lib_dirs(Opts, Acc) -> Error = {error, _} -> Error; ok -> - {ok, [{lib_dirs, [filename:absname(Dir) || Dir <- Dirs]} | Acc]} + create_root_dir(Opts, [{lib_dirs, [filename:absname(Dir) || Dir <- Dirs]} | Acc]) end. +-spec create_root_dir([getopt:option()], rcl_state:cmd_args()) -> + {ok, rcl_state:cmd_args()} | relcool:error(). +create_root_dir(Opts, Acc) -> + Dir = proplists:get_value(root_dir, Opts, undefined), + case Dir of + undefined -> + {ok, Cwd} = file:get_cwd(), + {ok, [{root_dir, Cwd} | Acc]}; + _ -> + {ok, [{root_dir, Dir} | Acc]} + end. + + -spec check_lib_dirs([string()]) -> ok | relcool:error(). check_lib_dirs([]) -> ok; diff --git a/src/relcool.erl b/src/relcool.erl index 9babdb2..f240553 100644 --- a/src/relcool.erl +++ b/src/relcool.erl @@ -23,6 +23,7 @@ -export([main/1, do/7, do/8, + do/9, format_error/1, opt_spec_list/0]). @@ -60,10 +61,25 @@ main(Args) -> %% @param OutputDir - The directory where the release should be built to %% @param Configs - The list of config files for the system do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) -> - do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs). + {ok, Cwd} = file:get_cwd(), + do(Cwd, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs). %% @doc provides an API to run the Relcool process from erlang applications %% +%% @param RootDir - The root directory for the project +%% @param RelName - The release name to build (maybe `undefined`) +%% @param RelVsn - The release version to build (maybe `undefined`) +%% @param Goals - The release goals for the system in depsolver or Relcool goal +%% format +%% @param LibDirs - The library dirs that should be used for the system +%% @param OutputDir - The directory where the release should be built to +%% @param Configs - The list of config files for the system +do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) -> + do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, [], Configs). + +%% @doc provides an API to run the Relcool process from erlang applications +%% +%% @param RootDir - The root directory for the system %% @param RelName - The release name to build (maybe `undefined`) %% @param RelVsn - The release version to build (maybe `undefined`) %% @param Goals - The release goals for the system in depsolver or Relcool goal @@ -72,13 +88,14 @@ do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Configs) -> %% @param OutputDir - The directory where the release should be built to %% @param Overrides - A list of overrides for the system %% @param Configs - The list of config files for the system -do(RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Config) -> +do(RootDir, RelName, RelVsn, Goals, LibDirs, LogLevel, OutputDir, Overrides, Config) -> State = rcl_state:new([{relname, RelName}, {relvsn, RelVsn}, {goals, Goals}, {overrides, Overrides}, {output_dir, OutputDir}, {lib_dirs, LibDirs}, + {root_dir, RootDir}, {log, rcl_log:new(LogLevel)}], Config), run_relcool_process(rcl_state:caller(State, api)). @@ -93,8 +110,8 @@ opt_spec_list() -> "usually the OTP"}, {output_dir, $o, "output-dir", string, "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"}, - {log_level, $V, "verbose", {integer, 0}, "Verbosity level, maybe between 0 and 2"} - ]. + {log_level, $V, "verbose", {integer, 0}, "Verbosity level, maybe between 0 and 2"}, + {root_dir, $r, "root", string, "The project root directory"}]. -spec format_error(Reason::term()) -> iolist(). format_error({invalid_return_value, Provider, Value}) -> diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl index bcdf354..e92772e 100644 --- a/test/rclt_release_SUITE.erl +++ b/test/rclt_release_SUITE.erl @@ -166,7 +166,8 @@ make_overridden_release(Config) -> goal_app_2]}]), OutputDir = filename:join([proplists:get_value(data_dir, Config), create_random_name("relcool-output")]), - {ok, State} = relcool:do(undefined, undefined, [], [LibDir1], 2, + {ok, Cwd} = file:get_cwd(), + {ok, State} = relcool:do(Cwd, undefined, undefined, [], [LibDir1], 2, OutputDir, [{OverrideAppName, OverrideAppDir}], [ConfigFile]), [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rcl_state:releases(State)), @@ -255,12 +256,13 @@ make_rerun_overridden_release(Config) -> goal_app_2]}]), OutputDir = filename:join([proplists:get_value(data_dir, Config), create_random_name("relcool-output")]), - {ok, State} = relcool:do(undefined, undefined, [], [LibDir1], 2, + {ok, Cwd} = file:get_cwd(), + {ok, State} = relcool:do(Cwd, undefined, undefined, [], [LibDir1], 2, OutputDir, [{OverrideAppName, OverrideAppDir}], [ConfigFile]), %% Now we run it again to see if it failse. - {ok, State} = relcool:do(undefined, undefined, [], [LibDir1], 2, + {ok, State} = relcool:do(Cwd, undefined, undefined, [], [LibDir1], 2, OutputDir, [{OverrideAppName, OverrideAppDir}], [ConfigFile]), |