From 770d126a6d4a756f67ccdbf6e0931cc7cc85c5fd Mon Sep 17 00:00:00 2001 From: Dave Lucia Date: Sun, 29 Sep 2024 08:16:07 -0400 Subject: [PATCH 1/2] Prevent build machine paths being used in published artifacts --- rebar.config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rebar.config b/rebar.config index 857a9a9..b4d28cd 100644 --- a/rebar.config +++ b/rebar.config @@ -3,6 +3,10 @@ {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]} From 7db0e8b8709579c52837309acdcba6b68833cfb9 Mon Sep 17 00:00:00 2001 From: Dave Lucia Date: Sun, 29 Sep 2024 08:47:27 -0400 Subject: [PATCH 2/2] conditionally add options --- rebar.config | 4 ---- rebar.config.script | 33 ++++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/rebar.config b/rebar.config index b4d28cd..857a9a9 100644 --- a/rebar.config +++ b/rebar.config @@ -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]} diff --git a/rebar.config.script b/rebar.config.script index bf7898c..aff1fb2 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -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. @@ -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.