% This file is part of Jiffy released under the MIT license.
% See the LICENSE file for more information.
%

IsRebar2 = case lists:keyfind(rebar, 1, application:loaded_applications()) of
    {rebar, _Desc, Vsn} ->
        case string:split(Vsn, ".") of
            ["2" | _] -> true;
            _ -> false
        end;
    false ->
        false
end,

case IsRebar2 of
    true ->
        CONFIG;
    false ->
        CONFIG ++ [
            {plugins, [{pc, "~> 1.15"}]},
            case os:type() of
                {win32, _} -> {artifacts, ["priv/jiffy.dll"]};
                {_, _} -> {artifacts, ["priv/jiffy.so"]}
            end,
            {provider_hooks, [
                {post, [
                    {compile, {pc, compile}},
                    {clean, {pc, clean}}
                ]}
            ]}
        ]
end.
