aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Rascao <[email protected]>2017-01-04 19:21:33 +0000
committerLuis Rascao <[email protected]>2017-01-28 00:40:46 +0000
commit4314d778176225b6caecd354d6fddbdc5a1f7e17 (patch)
treebf76a452163442bb5f26642b29f21fbe6bdc180e
parent2640387cf1ba24682690b5d6f488df3d8ded5501 (diff)
downloadrelx-4314d778176225b6caecd354d6fddbdc5a1f7e17.tar.gz
relx-4314d778176225b6caecd354d6fddbdc5a1f7e17.tar.bz2
relx-4314d778176225b6caecd354d6fddbdc5a1f7e17.zip
Expose warnings as errors option
Obtained from command line and saved in the state to be used on situations where we want to error out on warnings explicitly.
-rw-r--r--src/rlx_cmd_args.erl3
-rw-r--r--src/rlx_config.erl2
-rw-r--r--src/rlx_state.erl16
3 files changed, 18 insertions, 3 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_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
%% ===================================================================