{erl_opts, [
    debug_info,
    warnings_as_errors,
    warn_export_vars,
    warn_unused_import,
    warn_missing_spec_all
]}.

{deps, []}.

{minimum_otp_vsn, "27"}.

{erlfmt, [
    write,
    {files, ["{src,include,test}/*.{hrl,erl,app.src}", "rebar.config"]},
    {exclude_files, []},
    {print_width, 120}
]}.

{project_plugins, [
    erlfmt
]}.

{profiles, [
    {test, [
        {erl_opts, [
            nowarn_export_all,
            nowarn_missing_spec_all
        ]}
    ]}
]}.

{dialyzer, [
    {warnings, [unknown]},
    {plt_apps, all_deps},
    {plt_extra_apps, []}
]}.

{xref_checks, [
    undefined_function_calls,
    undefined_functions,
    locals_not_used,
    deprecated_function_calls,
    deprecated_functions
]}.

{escript_name, edb}.
% +sbwt* none               - By default the Erlang VM is optimised for latency, with schedulers spinning in busy loops fairly frequently
%                             to avoid cost of OS sleep + wake cycle.
%                             This is not necessary for us. The escript exists alongside other programs on the machine, so
%                             we should give all the flexibility to the OS to schedule resources as necessary.
% +A0                       - Async threads are used only for old-style async port drivers. We don't use them, so save a thread
% -noinput                  - Do not try to read any input. Required to be able to access stdin/out via a port
% -kernel connect_all false - Do not actively connect to all nodes that you become aware of
% -escript main edb_main    - Specify the entry point for the Escript
{escript_emu_args,
    "%%! +sbwt none +sbwtdcpu none +sbwtdio none +A0 -noinput -kernel connect_all false -escript main edb_main\n"}.

% Some of the test suites perform E2E tests on the edb Escript, so
% ensure the Escript is produced and copied to the appropriate data directories.
% Ideally we'd only execute this for the relevant test suites, but this is a simple enough approximation
{pre_hooks, [
    {ct, "rebar3 escriptize"},
    {ct, "mkdir -p _build/test/lib/edb/test/edb_attachment_SUITE_data"},
    {ct, "cp _build/default/bin/edb _build/test/lib/edb/test/edb_attachment_SUITE_data"},
    {ct, "mkdir -p _build/test/lib/edb/test/edb_main_SUITE_data"},
    {ct, "cp _build/default/bin/edb _build/test/lib/edb/test/edb_main_SUITE_data"},
    {ct, "mkdir -p _build/test/lib/edb/test/edb_dap_scopes_SUITE_data"},
    {ct, "cp _build/default/bin/edb _build/test/lib/edb/test/edb_dap_scopes_SUITE_data"},
    {ct, "mkdir -p _build/test/lib/edb/test/edb_dap_session_SUITE_data"},
    {ct, "cp _build/default/bin/edb _build/test/lib/edb/test/edb_dap_session_SUITE_data"},
    {ct, "mkdir -p _build/test/lib/edb/test/edb_dap_steps_SUITE_data"},
    {ct, "cp _build/default/bin/edb _build/test/lib/edb/test/edb_dap_steps_SUITE_data"}
]}.

{project_plugins, [rebar3_ex_doc]}.

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

{ex_doc, [
          {source_url, <<"https://github.com/WhatsApp/edb">>},
          {extras, [<<"README.md">>, <<"LICENSE.md">>]},
          {main, <<"README.md">>}]}.
