aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/relx.config34
-rw-r--r--examples/relx_simple.config6
-rw-r--r--src/rlx_cmd_args.erl5
-rw-r--r--src/rlx_prv_config.erl2
-rw-r--r--src/rlx_util.erl20
-rw-r--r--test/rlx_command_SUITE.erl15
-rw-r--r--test/rlx_release_SUITE.erl3
7 files changed, 59 insertions, 26 deletions
diff --git a/examples/relx.config b/examples/relx.config
index 77d7acf..f328c32 100644
--- a/examples/relx.config
+++ b/examples/relx.config
@@ -1,11 +1,11 @@
%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
-%% Example Relcool Config
+%% Example Relx Config
%% ======================
%%
-%% This is an example relcool config whose purpose is to demonstrate all of the
-%% options available in relcool. Its not expected that you will use all of the
-%% things here. In fact, there is a high likely hood that *your* relcool.config
-%% will be extremely minimal, as relcool does a very good job of figuring out
+%% This is an example relx config whose purpose is to demonstrate all of the
+%% options available in relx. Its not expected that you will use all of the
+%% things here. In fact, there is a high likely hood that *your* relx.config
+%% will be extremely minimal, as relx does a very good job of figuring out
%% things on its own.
%%
%% The Release We Are Building
@@ -17,10 +17,10 @@
%% neotoma (any version). We also do not want neotoma to be loaded. We also want
%% our default release. the one we build in the common case to be sexper 0.0.2.
-%% You can tell relcool about additional directories that you want searched for
+%% You can tell relx about additional directories that you want searched for
%% otp apps during the discovery process. You do that in the 'paths' config. You
%% can also specify these paths on the command line with `-p`. Be aware that
-%% relcool plays well with rebar so if you have a deps directory in the current
+%% relx plays well with rebar so if you have a deps directory in the current
%% directory it will be automatically added.
{paths, ["/opt/erlang_apps"]}.
@@ -28,13 +28,13 @@
%% one automatically generated by relx.
{vm_args, "./config/vm.args"}.
-%% If you have a sys.config file you need to tell relcool where it is. If you do
-%% that relcool will include the sys.config in the appropriate place
+%% If you have a sys.config file you need to tell relx where it is. If you do
+%% that relx will include the sys.config in the appropriate place
%% automatically.
{sys_config, "./config/sys.config"}.
%% relcool will include erts by default. However, if you don't want to include
-%% erts you can add the `include_erts` tuple to the config and tell relcool not
+%% erts you can add the `include_erts` tuple to the config and tell relx not
%% to include it.
{include_erts, false}.
@@ -42,9 +42,9 @@
%% script add the extended_start_script option.
{extended_start_script, true}.
-%% When we have multiple releases relcool needs to know which one to build. You
+%% When we have multiple releases relx needs to know which one to build. You
%% can specify that on the command line with the `-n` and `-v` arguments to
-%% relcool. However, it is often more convenient to do it in the config.
+%% relx. However, it is often more convenient to do it in the config.
{default_release, sexpr, "0.0.2"}.
{release, {sexpr, "0.0.1"},
@@ -67,15 +67,15 @@
%% During development its often the case that you want to substitute the app
%% that you are working on for a 'production' version of an app. You can
-%% explicitly tell relcool to override all versions of an app that you specify
-%% with an app in an arbitrary directory. Relcool will then symlink that app
-%% into the release in place of the specified app. be aware though that relcool
+%% explicitly tell relx to override all versions of an app that you specify
+%% with an app in an arbitrary directory. relx will then symlink that app
+%% into the release in place of the specified app. be aware though that relx
%% will check your app for consistancy so it should be a normal OTP app and
%% already be built.
{overrides, [{sexpr, "../sexpr"}]}.
-%% In some cases you might want to add additional functionality to relcool. You
-%% can do this via a 'provider'. A provider is an implementation of the relcool
+%% In some cases you might want to add additional functionality to relx. You
+%% can do this via a 'provider'. A provider is an implementation of the relx
%% provider behaviour. This probably shouldn't be needed very often.
{add_providers, [my_custom_functionality]}.
diff --git a/examples/relx_simple.config b/examples/relx_simple.config
index 88e9e8d..70c41b2 100644
--- a/examples/relx_simple.config
+++ b/examples/relx_simple.config
@@ -1,9 +1,9 @@
%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
-%% Example Relcool Simple Config
+%% Example Relx Simple Config
%% =============================
%%
-%% This is an example relcool config whose purpose demonstrate the minimal
-%% config needed for relcool. For a more complete example see the relcool.config
+%% This is an example relx config whose purpose demonstrate the minimal
+%% config needed for relx. For a more complete example see the relx.config
%% in the examples directory.
%%
%% The Release We Are Building
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index f592474..d2402ce 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -223,11 +223,12 @@ create_output_dir(Opts, Acc) ->
create_lib_dirs(Opts, Acc) ->
Dirs = proplists:get_all_values(lib_dir, Opts) ++
proplists:get_value(lib_dirs, Opts, []),
- case check_lib_dirs(Dirs) of
+ ExpDirs = rlx_util:wildcard_paths(Dirs),
+ case check_lib_dirs(ExpDirs) of
Error = {error, _} ->
Error;
ok ->
- create_root_dir(Opts, [{lib_dirs, [filename:absname(Dir) || Dir <- Dirs]} | Acc])
+ create_root_dir(Opts, [{lib_dirs, ExpDirs} | Acc])
end.
-spec create_root_dir([getopt:option()], rlx_state:cmd_args()) ->
diff --git a/src/rlx_prv_config.erl b/src/rlx_prv_config.erl
index 19aa576..aa2e79c 100644
--- a/src/rlx_prv_config.erl
+++ b/src/rlx_prv_config.erl
@@ -129,7 +129,7 @@ load_terms({paths, Paths}, {ok, State}) ->
load_terms({lib_dirs, Dirs}, {ok, State}) ->
State2 =
rlx_state:add_lib_dirs(State,
- [list_to_binary(filename:absname(Dir)) || Dir <- Dirs]),
+ [list_to_binary(Dir) || Dir <- rlx_util:wildcard_paths(Dirs)]),
{ok, State2};
load_terms({providers, Providers0}, {ok, State0}) ->
Providers1 = gen_providers(Providers0, State0),
diff --git a/src/rlx_util.erl b/src/rlx_util.erl
index 53e9122..48e2ee1 100644
--- a/src/rlx_util.erl
+++ b/src/rlx_util.erl
@@ -28,7 +28,8 @@
is_error/1,
error_reason/1,
indent/1,
- optional_to_string/1]).
+ optional_to_string/1,
+ wildcard_paths/1]).
-define(ONE_LEVEL_INDENT, " ").
%%============================================================================
@@ -96,6 +97,23 @@ optional_to_string(undefined) ->
optional_to_string(Value) when is_list(Value) ->
Value.
+%% @doc expand wildcards and names in the given paths
+-spec wildcard_paths([file:filename_all()]) -> [string()].
+wildcard_paths(Paths) ->
+ [filename:absname(Expanded) || Path <- Paths, Expanded <- wildcard(Path)].
+
+%% In case the given directory does not expand,
+%% we return it back in a list so we trigger the
+%% proper error reportings.
+-spec wildcard(file:filename_all()) -> [string()].
+wildcard(Path) when is_binary(Path) ->
+ wildcard(binary_to_list(Path));
+wildcard(Path) when is_list(Path) ->
+ case filelib:wildcard(Path) of
+ [] -> [Path];
+ Paths -> Paths
+ end.
+
%%%===================================================================
%%% Test Functions
%%%===================================================================
diff --git a/test/rlx_command_SUITE.erl b/test/rlx_command_SUITE.erl
index 6f726b4..5ea4769 100644
--- a/test/rlx_command_SUITE.erl
+++ b/test/rlx_command_SUITE.erl
@@ -24,6 +24,7 @@
end_per_suite/1,
all/0,
normal_passing_case/1,
+ lib_expansion_case/1,
lib_fail_case/1,
spec_parse_fail_case/1,
config_fail_case/1]).
@@ -41,7 +42,7 @@ end_per_suite(_Config) ->
ok.
all() ->
- [normal_passing_case, lib_fail_case, config_fail_case].
+ [normal_passing_case, lib_expansion_case, lib_fail_case, config_fail_case].
normal_passing_case(Config) ->
DataDir = proplists:get_value(data_dir, Config),
@@ -70,6 +71,18 @@ normal_passing_case(Config) ->
{{45,22},{[],[<<"build">>,21]}}, between}],
rlx_state:goals(State)).
+lib_expansion_case(Config) ->
+ DataDir = proplists:get_value(data_dir, Config),
+ Lib1 = filename:join(DataDir, <<"lib1">>),
+ Lib2 = filename:join(DataDir, <<"lib2">>),
+ ok = rlx_util:mkdir_p(Lib1),
+ ok = rlx_util:mkdir_p(Lib2),
+
+ CmdLine = ["-l", filename:join(DataDir, "*")],
+ {ok, {Opts, Targets}} = getopt:parse(relx:opt_spec_list(), CmdLine),
+ {ok, State} = rlx_cmd_args:args2state(Opts, Targets),
+ ?assertMatch([Lib1, Lib2],
+ rlx_state:lib_dirs(State)).
lib_fail_case(Config) ->
DataDir = proplists:get_value(data_dir, Config),
diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl
index ae38928..c2ed984 100644
--- a/test/rlx_release_SUITE.erl
+++ b/test/rlx_release_SUITE.erl
@@ -133,7 +133,8 @@ make_extend_release(Config) ->
[goal_app_1,
goal_app_2]},
{release, {foo_test, "0.0.1", {extend, foo}},
- [goal_app_2]}]),
+ [goal_app_2]},
+ {lib_dirs, [filename:join(LibDir1, "*")]}]),
OutputDir = filename:join([proplists:get_value(data_dir, Config),
create_random_name("relx-output")]),