{eunit_opts, [verbose]}.
{deps, []}.

{project_plugins, [
    rebar3_ex_doc
]}.

{hex, [{doc, ex_doc}]}.

{ex_doc, [
    {source_url, <<"https://github.com/benoitc/erlang-quickjs">>},
    {extras, [
        <<"README.md">>,
        <<"guides/getting-started.md">>,
        <<"guides/event-framework.md">>,
        <<"guides/erlang-functions.md">>,
        <<"guides/cbor-encoding.md">>,
        <<"guides/metrics.md">>,
        <<"CHANGELOG.md">>,
        <<"LICENSE">>
    ]},
    {main, <<"readme">>},
    {api_reference, true},
    {groups_for_extras, [
        {<<"Guides">>, [
            <<"guides/getting-started.md">>,
            <<"guides/event-framework.md">>,
            <<"guides/erlang-functions.md">>,
            <<"guides/cbor-encoding.md">>,
            <<"guides/metrics.md">>
        ]},
        {<<"About">>, [<<"CHANGELOG.md">>, <<"LICENSE">>]}
    ]}
]}.

{pre_hooks, [
    {clean, "rm -f priv/*.so priv/*.dylib priv/*.dll"},
    {clean, "rm -rf _build/cmake"},
    %% Populate the submodule on a fresh clone only. An unconditional
    %% `git submodule update` resets the checkout to the recorded commit on
    %% every compile, silently discarding a deliberate version bump before it
    %% can be staged. Run `make submodules` to sync to the recorded commit.
    %% The interpreter has to be explicit: rebar3 does not run hook commands
    %% through a shell, so a bare `test ... || ...` reaches test(1) as
    %% arguments instead of being interpreted.
    {"(linux|darwin|solaris|freebsd|netbsd|openbsd)", compile,
     "sh -c 'test -f c_src/quickjs-ng/quickjs.c || "
     "git submodule update --init c_src/quickjs-ng'"},
    {"win32", compile,
     "cmd /c \"if not exist c_src\\quickjs-ng\\quickjs.c "
     "git submodule update --init c_src/quickjs-ng\""},
    {"(linux|darwin|solaris)", compile, "./do_cmake.sh $QUICKJS_OPTS"},
    {"(freebsd|netbsd|openbsd)", compile, "./do_cmake.sh $QUICKJS_OPTS"},
    {"win32", compile, "mkdir _build\\cmake & cd _build\\cmake & cmake ..\\..\\c_src"}
]}.

{post_hooks, [
    {"(linux|darwin|solaris)", compile, "./do_build.sh $QUICKJS_BUILDOPTS"},
    {"(freebsd|netbsd|openbsd)", compile, "./do_build.sh $QUICKJS_BUILDOPTS"},
    {"win32", compile, "cmake --build _build\\cmake --config Release --parallel"}
]}.

{dialyzer, [
    {warnings, [
        unmatched_returns,
        error_handling,
        unknown
    ]}
]}.

{profiles, [
    {bench, [
        {erl_opts, [debug_info, {d, 'BENCHMARK'}]},
        {extra_src_dirs, ["bench"]}
    ]}
]}.
