% This file is part of Jiffy released under the MIT license.
|
|
% See the LICENSE file for more information.
|
|
|
|
% Only include PropEr as a dependency when the JIFFY_DEV
|
|
% environment variable is defined. This allows downstream
|
|
% applications to avoid requiring PropEr.
|
|
%
|
|
% This script is based on the example provided with Rebar.
|
|
|
|
IsRebar3 = erlang:function_exported(rebar3, main, 1),
|
|
|
|
PropErUrl = "git://github.com/manopapad/proper.git",
|
|
|
|
|
|
IsDevEnv = begin
|
|
ConfigPath = filename:dirname(SCRIPT),
|
|
DevMarker = filename:join([ConfigPath, ".jiffy.dev"]),
|
|
filelib:is_file(DevMarker)
|
|
end.
|
|
|
|
Deps = if not IsDevEnv -> []; true ->
|
|
case IsRebar3 of
|
|
true -> [proper];
|
|
false -> [{proper, ".*", {git, PropErUrl, {branch, "master"}}}]
|
|
end
|
|
end,
|
|
|
|
ErlOpts = if not IsDevEnv -> []; true ->
|
|
[{d, 'JIFFY_DEV'}]
|
|
end,
|
|
|
|
Plugins = case IsRebar3 of
|
|
true -> [pc];
|
|
false -> [rebar_gdb_plugin]
|
|
end,
|
|
|
|
ProviderHooks = if not IsRebar3 -> []; true ->
|
|
[{pre, [
|
|
{compile, {pc, compile}},
|
|
{clean, {pc, clean}}
|
|
]}]
|
|
end,
|
|
|
|
OptsToAdd = [
|
|
{deps, Deps},
|
|
{erl_opts, ErlOpts},
|
|
{plugins, Plugins},
|
|
{provider_hooks, ProviderHooks}
|
|
],
|
|
|
|
AddOpt = fun(Name, Value, Config) when is_list(Value) ->
|
|
case lists:keyfind(Name, 1, Config) of
|
|
{Name, CurrVal} when is_list(CurrVal) ->
|
|
lists:keyreplace(Name, 1, Config, {Name, CurrVal ++ Value});
|
|
false ->
|
|
Config ++ [{Name, Value}];
|
|
_ ->
|
|
Config
|
|
end
|
|
end,
|
|
|
|
lists:foldl(fun({Name, Value}, CfgAcc) ->
|
|
AddOpt(Name, Value, CfgAcc)
|
|
end, CONFIG, OptsToAdd).
|