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

{erl_opts, [debug_info,
            {platform_define, "R14", no_callback_support},
            {platform_define, "^[0-9]+", namespaced_types},
            {platform_define, "^R", no_proxy_sni_support},
            {platform_define, "^(1|(20))", no_customize_hostname_check},
            {platform_define, "^20\.3", buggy_chacha_ciphers}
           ]}.

{erl_first_files,
 ["src/hackney_ssl_certificate.erl" % required by `hackney_ssl' at compile time
 ]}.

{xref_checks, [undefined_function_calls]}.
%% Ignore xref warnings for optional dependencies (prometheus, quic)
{xref_ignores, [
  %% prometheus (optional metrics backend)
  {prometheus_counter, inc, 3},
  {prometheus_counter, declare, 1},
  {prometheus_gauge, set, 3},
  {prometheus_gauge, inc, 2},
  {prometheus_gauge, dec, 2},
  {prometheus_gauge, declare, 1},
  {prometheus_histogram, observe, 3},
  {prometheus_histogram, declare, 1},
  %% quic (HTTP/3 support)
  {quic, connect, 4},
  {quic, open_stream, 1},
  {quic, open_unidirectional_stream, 1},
  {quic, send_data, 4},
  {quic, reset_stream, 3},
  {quic, peername, 1},
  {quic, sockname, 1},
  {quic, close, 2},
  {quic_connection, lookup, 1},
  %% hackney_quic wrapper functions called by hackney_conn
  {hackney_quic, connect, 4},
  {hackney_quic, close, 2},
  {hackney_quic, process, 1},
  {hackney_quic, peername, 1},
  {hackney_quic, sockname, 1},
  {hackney_quic, setopts, 2},
  %% hackney_h3 functions called by hackney_conn
  {hackney_h3, send_request, 6},
  {hackney_h3, send_request_headers, 5},
  {hackney_h3, send_body_chunk, 4},
  {hackney_h3, finish_send_body, 3},
  {hackney_h3, parse_response_headers, 1}
]}.

{cover_enabled, true}.
{eunit_opts, [verbose]}.

{pre_hooks, [{clean, "rm -rf *~ */*~ */*.xfm test/*.beam"}]}.

{deps, [
        %% Pure Erlang QUIC for HTTP/3 support
        {quic, "~>0.10.1"},
        {idna, "~>7.1.0"},
        {mimerl, "~>1.4"},
        {certifi, "~>2.16.0"},
        {parse_trans, "3.4.1"},
        {ssl_verify_fun, "~>1.1.0"}
       ]}.

{profiles, [{test, [
               {deps, [{cowboy, "2.12.0"}, {jsx, "3.1.0"}]}
             ]}
           ]}.

{hex, [
       {doc, #{provider => ex_doc}}
      ]}.



{project_plugins, [rebar3_ex_doc]}.

{ex_doc, [
    {extras, [
        {"README.md", #{title => "Overview"}},
        {"GETTING_STARTED.md", #{title => "Getting Started"}},
        {"guides/http_guide.md", #{title => "HTTP Guide"}},
        {"guides/http2_guide.md", #{title => "HTTP/2 Guide"}},
        {"guides/http3_guide.md", #{title => "HTTP/3 Guide"}},
        {"guides/websocket_guide.md", #{title => "WebSocket Guide"}},
        {"guides/design.md", #{title => "Design Guide"}},
        {"guides/MIGRATION.md", #{title => "Migration Guide"}},
        {"NEWS.md", #{title => "Changelog"}},
        {"CONTRIBUTING.md", #{title => "Contributing"}},
        {"DEVELOPMENT.md", #{title => "Development"}},
        {"LICENSE", #{title => "License"}},
        {"NOTICE", #{title => "Notice"}}
    ]},
    {main, "README.md"},
    {source_url, "https://github.com/benoitc/hackney"},
    {source_ref, <<"master">>}
]}.

%% == Dialyzer ==
%%
{dialyzer, [
  {warnings, [
%   race_conditions,
    no_return,
    unmatched_returns,
    error_handling%,
    %unknown
  ]},
  %% Exclude modules with optional dependencies
  %% - hackney_metrics_prometheus: prometheus is optional
  {exclude_mods, [hackney_metrics_prometheus]},
  {base_plt_apps, [erts, stdlib, kernel, crypto, runtime_tools]},
  {plt_apps, top_level_deps},
  {plt_extra_apps, [quic]},
  {plt_location, local},
  {plt_prefix, "hackney"},
  {base_plt_location, "."},
  {base_plt_prefix, "hackney"}
]}.
