
This patch makes erlware_commons easier to include as a dependency by removing depedencies that are not needed at run time. The top-level Makefile creates a .DEV_MODE marker file which is detected by rebar.config.script. When the marker file is present, the development only dependencies proper and neotoma are included and a macro 'DEV_ONLY' is defined. The macro is used to only enable the proper tests for development mode. The ec_semver_parser.peg is now located in priv/ and is moved into src/ by the Makefile. The generated ec_semver_parser.erl is now under version control; it need not be rebuilt by all projects wishing to include erlware_commons. It will be rebuilt, as before this change, on every make invocation.
42 lines
1.6 KiB
Text
42 lines
1.6 KiB
Text
%% Merge the list values in `ToAdd' into the list found at key `Key'
|
|
%% in proplist `C'. Don't duplicate items. New Items are added to the
|
|
%% front of existing items. It is an error if the value at `Key' is
|
|
%% not a list in `C'.
|
|
MergeConfig = fun({Key, ToAdd}, C) ->
|
|
case lists:keyfind(Key, 1, C) of
|
|
false ->
|
|
lists:keystore(Key, 1, C, {Key, ToAdd});
|
|
{Key, List} when is_list(List) ->
|
|
%% remove items in ToAdd already in List
|
|
ToAdd1 = [ I || I <- ToAdd, not lists:member(I, List) ],
|
|
lists:keystore(Key, 1, C, {Key, ToAdd1 ++ List })
|
|
end
|
|
end.
|
|
|
|
{match, [ErtsNumber]} = re:run(erlang:system_info(otp_release), "R(\\d+).+", [{capture, [1], list}]),
|
|
ErtsVsn = erlang:list_to_integer(ErtsNumber),
|
|
AddErlOpts = if
|
|
ErtsVsn >= 15 ->
|
|
[{d, have_callback_support}];
|
|
true ->
|
|
[]
|
|
end,
|
|
|
|
DevOnlyDeps = [{neotoma, "",
|
|
{git, "https://github.com/seancribbs/neotoma.git", {branch, master}}},
|
|
{proper, "",
|
|
{git, "https://github.com/bkearns/proper.git", {branch, master}}}],
|
|
|
|
Config1 = MergeConfig({erl_opts, AddErlOpts}, CONFIG),
|
|
|
|
ConfigPath = filename:dirname(SCRIPT),
|
|
DevMarker = filename:join([ConfigPath, ".DEV_MODE"]),
|
|
case filelib:is_file(DevMarker) of
|
|
true ->
|
|
lists:foldl(MergeConfig, Config1,
|
|
[{deps, DevOnlyDeps},
|
|
{erl_opts, [{d, 'DEV_ONLY'}]}]);
|
|
false ->
|
|
Config1
|
|
end.
|
|
|