aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/relx.erl2
-rw-r--r--src/rlx_cmd_args.erl8
-rw-r--r--src/rlx_prv_assembler.erl35
-rw-r--r--src/rlx_prv_config.erl28
-rw-r--r--src/rlx_state.erl11
5 files changed, 68 insertions, 16 deletions
diff --git a/src/relx.erl b/src/relx.erl
index d61f426..359d47d 100644
--- a/src/relx.erl
+++ b/src/relx.erl
@@ -204,7 +204,7 @@ opt_spec_list() ->
{config, $c, "config", {string, ""}, "The path to a config file"},
{overlay_vars, undefined, "overlay_vars", string, "Path to a file of overlay variables"},
{system_libs, undefined, "system_libs", string, "Path to dir of Erlang system libs"},
- {version, $v, "version", undefined, "Print relx version"},
+ {version, undefined, "version", undefined, "Print relx version"},
{root_dir, $r, "root", string, "The project root directory"}].
-spec format_error(Reason::term()) -> string().
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index d6bf0bb..f592474 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -300,9 +300,15 @@ create_paths(Opts, Acc) ->
Error;
ok ->
code:add_pathsa([filename:absname(Path) || Path <- Dirs]),
- {ok, Acc}
+ create_dev_mode(Opts, Acc)
end.
+-spec create_dev_mode([getopt:option()], rlx_state:cmd_args()) ->
+ {ok, rlx_state:cmd_args()} | relx:error().
+create_dev_mode(Opts, Acc) ->
+ DevMode = proplists:get_value(dev_mode, Opts, false),
+ {ok, [{dev_mode, DevMode} | Acc]}.
+
-spec check_lib_dirs([string()]) -> ok | relx:error().
check_lib_dirs([]) ->
ok;
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl
index ee5854a..fba21ca 100644
--- a/src/rlx_prv_assembler.erl
+++ b/src/rlx_prv_assembler.erl
@@ -115,6 +115,10 @@ format_error({relup_generation_error, CurrentName, UpFromName}) ->
format_error({relup_generation_warning, Module, Warnings}) ->
["Warnings generating relup \s",
rlx_util:indent(2), Module:format_warning(Warnings)];
+format_error({no_upfrom_release_found, undefined}) ->
+ io_lib:format("No earlier release for relup found", []);
+format_error({no_upfrom_release_found, Vsn}) ->
+ io_lib:format("Upfrom release version (~s) for relup not found", [Vsn]);
format_error({relup_script_generation_error,
{relup_script_generation_error, systools_relup,
{missing_sasl, _}}}) ->
@@ -167,6 +171,7 @@ create_output_dir(OutputDir) ->
copy_app_directories_to_output(State, Release, OutputDir) ->
LibDir = filename:join([OutputDir, "lib"]),
ok = ec_file:mkdir_p(LibDir),
+ IncludeSrc = rlx_state:include_src(State),
Apps = prepare_applications(State, rlx_release:application_details(Release)),
Result = lists:filter(fun({error, _}) ->
true;
@@ -174,7 +179,7 @@ copy_app_directories_to_output(State, Release, OutputDir) ->
false
end,
lists:flatten(ec_plists:map(fun(App) ->
- copy_app(LibDir, App)
+ copy_app(LibDir, App, IncludeSrc)
end, Apps))),
case Result of
[E | _] ->
@@ -191,7 +196,7 @@ prepare_applications(State, Apps) ->
Apps
end.
-copy_app(LibDir, App) ->
+copy_app(LibDir, App, IncludeSrc) ->
AppName = erlang:atom_to_list(rlx_app_info:name(App)),
AppVsn = rlx_app_info:original_vsn(App),
AppDir = rlx_app_info:dir(App),
@@ -202,16 +207,16 @@ copy_app(LibDir, App) ->
%% a release dir
ok;
true ->
- copy_app(App, AppDir, TargetDir)
+ copy_app(App, AppDir, TargetDir, IncludeSrc)
end.
-copy_app(App, AppDir, TargetDir) ->
+copy_app(App, AppDir, TargetDir, IncludeSrc) ->
remove_symlink_or_directory(TargetDir),
case rlx_app_info:link(App) of
true ->
link_directory(AppDir, TargetDir);
false ->
- copy_directory(AppDir, TargetDir)
+ copy_directory(AppDir, TargetDir, IncludeSrc)
end.
remove_symlink_or_directory(TargetDir) ->
@@ -235,16 +240,21 @@ link_directory(AppDir, TargetDir) ->
ok
end.
-copy_directory(AppDir, TargetDir) ->
+copy_directory(AppDir, TargetDir, IncludeSrc) ->
ec_plists:map(fun(SubDir) ->
copy_dir(AppDir, TargetDir, SubDir)
end, ["ebin",
"include",
"priv",
- "src",
- "c_src",
"README",
- "LICENSE"]).
+ "LICENSE" |
+ case IncludeSrc of
+ true ->
+ ["src",
+ "c_src"];
+ false ->
+ []
+ end]).
copy_dir(AppDir, TargetDir, SubDir) ->
SubSource = filename:join(AppDir, SubDir),
@@ -447,8 +457,9 @@ make_script(Options, RunFun) ->
end.
make_relup(State, Release) ->
+ Vsn = rlx_state:upfrom(State),
UpFrom =
- case rlx_state:upfrom(State) of
+ case Vsn of
undefined ->
get_last_release(State, Release);
Vsn ->
@@ -456,7 +467,7 @@ make_relup(State, Release) ->
end,
case UpFrom of
undefined ->
- ?RLX_ERROR(no_upfrom_release_found);
+ ?RLX_ERROR({no_upfrom_release_found, Vsn});
_ ->
make_upfrom_script(State, Release, UpFrom)
end.
@@ -574,7 +585,7 @@ get_up_release(State, Release, Vsn) ->
try
ec_dictionary:get({Name, Vsn}, rlx_state:realized_releases(State))
catch
- throw:notfound ->
+ throw:not_found ->
undefined
end.
diff --git a/src/rlx_prv_config.erl b/src/rlx_prv_config.erl
index b223bce..19aa576 100644
--- a/src/rlx_prv_config.erl
+++ b/src/rlx_prv_config.erl
@@ -154,6 +154,20 @@ load_terms({overrides, Overrides0}, {ok, State0}) ->
{ok, rlx_state:overrides(State0, Overrides0)};
load_terms({dev_mode, DevMode}, {ok, State0}) ->
{ok, rlx_state:dev_mode(State0, DevMode)};
+load_terms({include_src, IncludeSrc}, {ok, State0}) ->
+ {ok, rlx_state:include_src(State0, IncludeSrc)};
+load_terms({release, {RelName, Vsn, {extend, RelName2}}, Applications}, {ok, State0}) ->
+ Release0 = rlx_release:new(RelName, Vsn),
+ ExtendRelease = rlx_state:get_configured_release(State0, RelName2, Vsn),
+ Applications1 = rlx_release:goals(ExtendRelease),
+ case rlx_release:goals(Release0,
+ lists:umerge(lists:usort(Applications),
+ lists:usort(Applications1))) of
+ E={error, _} ->
+ E;
+ {ok, Release1} ->
+ {ok, rlx_state:add_configured_release(State0, Release1)}
+ end;
load_terms({release, {RelName, Vsn}, Applications}, {ok, State0}) ->
Release0 = rlx_release:new(RelName, Vsn),
case rlx_release:goals(Release0, Applications) of
@@ -177,8 +191,9 @@ load_terms({sys_config, SysConfig}, {ok, State}) ->
{ok, rlx_state:sys_config(State, filename:absname(SysConfig))};
load_terms({overlay_vars, OverlayVars}, {ok, State}) ->
CurrentOverlayVars = rlx_state:get(State, overlay_vars),
- NewOverlayVars = lists:umerge(lists:usort(OverlayVars), lists:usort(CurrentOverlayVars)),
- {ok, rlx_state:put(State, overlay_vars, NewOverlayVars)};
+ NewOverlayVars0 = list_of_overlay_vars_files(OverlayVars),
+ NewOverlayVars1 = lists:umerge(lists:usort(NewOverlayVars0), lists:usort(CurrentOverlayVars)),
+ {ok, rlx_state:put(State, overlay_vars, NewOverlayVars1)};
load_terms({Name, Value}, {ok, State})
when erlang:is_atom(Name) ->
{ok, rlx_state:put(State, Name, Value)};
@@ -196,3 +211,12 @@ gen_providers(Providers, State) ->
(_, E={_, {error, _}}) ->
E
end, {[], {ok, State}}, Providers).
+
+list_of_overlay_vars_files(undefined) ->
+ [];
+list_of_overlay_vars_files([]) ->
+ [];
+list_of_overlay_vars_files([H | _]=FileNames) when erlang:is_list(H) ->
+ FileNames;
+list_of_overlay_vars_files(FileName) when is_list(FileName) ->
+ [FileName].
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 81f9fca..bc4af5b 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -63,6 +63,8 @@
caller/2,
dev_mode/1,
dev_mode/2,
+ include_src/1,
+ include_src/2,
upfrom/1,
format/1,
format/2]).
@@ -91,6 +93,7 @@
configured_releases :: releases(),
realized_releases :: releases(),
dev_mode=false :: boolean(),
+ include_src=true :: boolean(),
upfrom :: string() | binary() | undefined,
config_values :: ec_dictionary:dictionary(Key::atom(),
Value::term())}).
@@ -125,6 +128,7 @@ new(PropList, Targets)
output_dir=proplists:get_value(output_dir, PropList, ""),
lib_dirs=[to_binary(Dir) || Dir <- proplists:get_value(lib_dirs, PropList, [])],
config_file=proplists:get_value(config, PropList, undefined),
+ dev_mode = proplists:get_value(dev_mode, PropList),
actions = Targets,
caller = Caller,
goals=proplists:get_value(goals, PropList, []),
@@ -328,6 +332,13 @@ dev_mode(#state_t{dev_mode=DevMode}) ->
dev_mode(S, DevMode) ->
S#state_t{dev_mode=DevMode}.
+-spec include_src(t()) -> boolean().
+include_src(#state_t{include_src=IncludeSrc}) ->
+ IncludeSrc.
+
+-spec include_src(t(), boolean()) -> t().
+include_src(S, IncludeSrc) ->
+ S#state_t{include_src=IncludeSrc}.
-spec upfrom(t()) -> string() | binary() | undefined.
upfrom(#state_t{upfrom=UpFrom}) ->