Make proper and neotoma dev-only dependencies
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.
This commit is contained in:
parent
38cd7a4d62
commit
d9c6ec1d28
7 changed files with 286 additions and 20 deletions
|
@ -1,15 +1,42 @@
|
|||
%% 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),
|
||||
Opts1 = case lists:keysearch(erl_opts, 1, CONFIG) of
|
||||
{value, {erl_opts, Opts0}} ->
|
||||
Opts0;
|
||||
false ->
|
||||
[]
|
||||
end,
|
||||
Opts2 = if
|
||||
ErtsVsn >= 15 ->
|
||||
[{d, have_callback_support} | Opts1];
|
||||
true ->
|
||||
Opts1
|
||||
end,
|
||||
lists:keystore(erl_opts, 1, CONFIG, {erl_opts, Opts2}).
|
||||
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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue