Skip to content

Commit

Permalink
conditionally add options
Browse files Browse the repository at this point in the history
  • Loading branch information
davydog187 committed Sep 29, 2024
1 parent 770d126 commit 7db0e8b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
4 changes: 0 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
{erl_opts, [debug_info]}.
{deps, []}.

%% Prevent build directories being used in output files
{xrl_opts, [{deterministic, true}]}.
{yrl_opts, [{deterministic, true}]}.

{shell, [
% {config, "config/sys.config"},
{apps, [luerl]}
Expand Down
33 changes: 28 additions & 5 deletions rebar.config.script
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%% -*- mode: erlang; indent-tabs-mode: nil -*-

Conf0 = CONFIG, %The original config
Conf0 = CONFIG, % The original config

%% Do a deep set stepping down a list of keys replacing/adding last
%% with value. Named funs would be nicer but not always available.
Expand Down Expand Up @@ -78,19 +78,42 @@ Copts = Copts0 ++ AppendCopts(Version,
%% Ensure they are in erl_opts.

Conf1 = case lists:keyfind(erl_opts, 1, Conf0) of
{erl_opts,Opts} -> %Existing erl_opts
{erl_opts,Opts} -> % Existing erl_opts
NewOpts = {erl_opts,Opts ++ Copts},
lists:keyreplace(erl_opts, 1, Conf0, NewOpts);
false -> %No erl_opts
false -> % No erl_opts
Conf0 ++ [{erl_opts,Copts}]
end,

%% Prevent build directories being used in output files

XrlYrlOpts = if Version > "24" ->
[
{xrl_opts, [{deterministic, true}]},
{yrl_opts, [{deterministic, true}]}
];
true ->
[]
end,

%% Append the new options to the configuration.

Conf2 = lists:foldl(fun({Key, Val}, Acc) ->
case lists:keyfind(Key, 1, Acc) of
{Key, OldVal} ->
NewVal = {Key, OldVal ++ Val},
lists:keyreplace(Key, 1, Acc, NewVal);
false ->
Acc ++ [{Key, Val}]
end
end, Conf1, XrlYrlOpts),

%% TestConfig = [{cover_enabled, true}, {cover_opts, [verbose]}],

%% Aliases = [{alias, [
%% {test, [eunit, {ct, "--cover"}, cover]}
%% ]}],

%% Conf1 ++ TestConfig ++ Aliases.
%% Conf2 ++ TestConfig ++ Aliases.

Conf1.
Conf2.

0 comments on commit 7db0e8b

Please sign in to comment.