%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
%%

%% We will add the location of the OTP patched modules based on the
%% OTP version
OTPVersion = erlang:system_info(otp_release),

%% The existing configuration from rebar3. CONFIG is a special variable
%% injected by rebar3
SrcDirs0 =
    case lists:keyfind(src_dirs, 1, CONFIG) of
        {src_dirs, Val} ->
            Val;
        false ->
            ["src"]
    end,

FindDir = fun
    FindDir(V) when V >= "24" ->
        SrcDirs = SrcDirs0 ++ ["priv/otp/24"],
        lists:keystore(src_dirs, 1, CONFIG, {src_dirs, SrcDirs});
    FindDir(V) ->
        exit("OTP version " ++ V ++ " not supported by partisan")
end,

FindDir(OTPVersion).
