aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rlx_cmd_args.erl3
-rw-r--r--src/rlx_config.erl2
-rw-r--r--src/rlx_prv_relup.erl37
-rw-r--r--src/rlx_state.erl16
4 files changed, 52 insertions, 6 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index 7f3f39b..b20344c 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -282,6 +282,9 @@ create(include_erts, Opts) ->
Erts when is_list(Erts) ->
{include_erts, Erts}
end;
+create(warnings_as_errors, Opts) ->
+ WarningsAsErrors = proplists:get_value(warnings_as_errors, Opts, false),
+ {warnings_as_errors, WarningsAsErrors};
create(_, _) ->
[].
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index dfcb511..b5ef51b 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -269,6 +269,8 @@ load_terms({overlay_vars, OverlayVars}, {ok, State}) ->
NewOverlayVars0 = list_of_overlay_vars_files(OverlayVars),
NewOverlayVars1 = CurrentOverlayVars ++ NewOverlayVars0,
{ok, rlx_state:put(State, overlay_vars, NewOverlayVars1)};
+load_terms({warnings_as_errors, WarningsAsErrors}, {ok, State}) ->
+ {ok, rlx_state:warnings_as_errors(State, WarningsAsErrors)};
load_terms({Name, Value}, {ok, State})
when erlang:is_atom(Name) ->
{ok, rlx_state:put(State, Name, Value)};
diff --git a/src/rlx_prv_relup.erl b/src/rlx_prv_relup.erl
index 9ac2135..1f8a950 100644
--- a/src/rlx_prv_relup.erl
+++ b/src/rlx_prv_relup.erl
@@ -65,6 +65,15 @@ format_error({relup_script_generation_error,
{missing_sasl, _}}}) ->
"Unfortunately, due to requirements in systools, you need to have the sasl application "
"in both the current release and the release to upgrade from.";
+format_error({relup_script_generation_warn, systools_relup,
+ [{erts_vsn_changed, _},
+ {erts_vsn_changed, _}]}) ->
+ "It has been detected that the ERTS version changed while generating the relup between versions, "
+ "please be aware that an instruction that will automatically restart the VM will be inserted in "
+ "this case";
+format_error({relup_script_generation_warn, Module, Warnings}) ->
+ ["Warnings generating relup \n",
+ rlx_util:indent(2), Module:format_warning(Warnings)];
format_error({relup_script_generation_error, Module, Errors}) ->
["Errors generating relup \n",
rlx_util:indent(2), Module:format_error(Errors)].
@@ -119,10 +128,20 @@ get_up_release(State, Release, Vsn) ->
make_upfrom_script(State, Release, UpFrom) ->
OutputDir = rlx_state:output_dir(State),
+ WarningsAsErrors = rlx_state:warnings_as_errors(State),
Options = [{outdir, OutputDir},
{path, rlx_util:get_code_paths(Release, OutputDir) ++
rlx_util:get_code_paths(UpFrom, OutputDir)},
silent],
+ %% the following block can be uncommented
+ %% when systools:make_relup/4 returns
+ %% {error,Module,Errors} instead of error
+ %% when taking the warnings_as_errors option
+ %% ++
+ %% case WarningsAsErrors of
+ %% true -> [warnings_as_errors];
+ %% false -> []
+ % end,
CurrentRel = strip_rel(rlx_release:relfile(Release)),
UpFromRel = strip_rel(rlx_release:relfile(UpFrom)),
ec_cmd_log:debug(rlx_state:log(State),
@@ -138,14 +157,26 @@ make_upfrom_script(State, Release, UpFrom) ->
[UpFromRel, CurrentRel]),
{ok, State};
error ->
- ?RLX_ERROR({relup_script_generation_error, CurrentRel, UpFromRel});
+ ?RLX_ERROR({relup_generation_error, CurrentRel, UpFromRel});
{ok, RelUp, _, []} ->
write_relup_file(State, Release, RelUp),
ec_cmd_log:info(rlx_state:log(State),
"relup successfully created!"),
{ok, State};
- {ok,_, Module,Warnings} ->
- ?RLX_ERROR({relup_script_generation_warn, Module, Warnings});
+ {ok, RelUp, Module,Warnings} ->
+ case WarningsAsErrors of
+ true ->
+ %% since we don't pass the warnings_as_errors option
+ %% the relup file gets generated anyway, we need to delete
+ %% it
+ file:delete(filename:join([OutputDir, "relup"])),
+ ?RLX_ERROR({relup_script_generation_warn, Module, Warnings});
+ false ->
+ write_relup_file(State, Release, RelUp),
+ ec_cmd_log:warn(rlx_state:log(State),
+ format_error({relup_script_generation_warn, Module, Warnings})),
+ {ok, State}
+ end;
{error,Module,Errors} ->
?RLX_ERROR({relup_script_generation_error, Module, Errors})
end.
diff --git a/src/rlx_state.erl b/src/rlx_state.erl
index 75a5cba..5032628 100644
--- a/src/rlx_state.erl
+++ b/src/rlx_state.erl
@@ -84,8 +84,9 @@
format/1,
format/2,
exclude_modules/1,
- exclude_modules/2]).
-
+ exclude_modules/2,
+ warnings_as_errors/1,
+ warnings_as_errors/2]).
-export_type([t/0,
releases/0,
@@ -117,7 +118,8 @@
include_src=true :: boolean(),
upfrom :: string() | binary() | undefined,
config_values :: ec_dictionary:dictionary(Key::atom(),
- Value::term())}).
+ Value::term()),
+ warnings_as_errors=false :: boolean()}).
%%============================================================================
%% types
@@ -454,6 +456,14 @@ hooks(_State=#state_t{providers=Providers}, Target) ->
Provider = providers:get_provider(Target, Providers),
providers:hooks(Provider).
+-spec warnings_as_errors(t()) -> boolean().
+warnings_as_errors(#state_t{warnings_as_errors=WarningsAsErrors}) ->
+ WarningsAsErrors.
+
+-spec warnings_as_errors(t(), boolean()) -> t().
+warnings_as_errors(State, WarningsAsErrors) ->
+ State#state_t{warnings_as_errors=WarningsAsErrors}.
+
%% ===================================================================
%% Internal functions
%% ===================================================================