Use compilation flags used during build to compile modules in ext_mod

This fixes issue #3178
This commit is contained in:
Paweł Chmielowski 2020-03-03 11:18:07 +01:00
parent df47e2a93f
commit 151b818af4
3 changed files with 21 additions and 6 deletions

19
mix.exs
View File

@ -51,12 +51,25 @@ defmodule Ejabberd.Mixfile do
end
end
defp if_version_below(ver, okResult) do
if :erlang.system_info(:otp_release) < ver do
okResult
else
[]
end
end
defp erlc_options do
# Use our own includes + includes from all dependencies
includes = ["include"] ++ deps_include(["fast_xml", "xmpp", "p1_utils"])
[:debug_info, {:d, :ELIXIR_ENABLED}] ++ cond_options() ++ Enum.map(includes, fn(path) -> {:i, path} end) ++
if_version_above('20', [{:d, :DEPRECATED_GET_STACKTRACE}]) ++
if_function_exported(:erl_error, :format_exception, 6, [{:d, :HAVE_ERL_ERROR}])
result = [:debug_info, {:d, :ELIXIR_ENABLED}] ++
cond_options() ++
Enum.map(includes, fn (path) -> {:i, path} end) ++
if_version_above('20', [{:d, :DEPRECATED_GET_STACKTRACE}]) ++
if_version_below('22', [{:d, :LAGER}]) ++
if_function_exported(:erl_error, :format_exception, 6, [{:d, :HAVE_ERL_ERROR}])
defines = for {:d, value} <- result, do: {:d, value}
result ++ [{:d, :ALL_DEFS, defines}]
end
defp cond_options do

View File

@ -304,12 +304,14 @@ fun(Hooks) ->
end,
ProcessErlOpt = fun(Vals) ->
lists:map(
R = lists:map(
fun({i, Path}) ->
{i, ResolveDepPath(Path)};
(ErlOpt) ->
ErlOpt
end, Vals)
end, Vals),
M = lists:filter(fun({d, M}) -> true; (_) -> false end, R),
[{d, 'ALL_DEFS', M} | R]
end,
ProcssXrefExclusions = fun(Items) ->

View File

@ -570,7 +570,7 @@ compile_result(Results) ->
end.
compile_options() ->
[verbose, report_errors, report_warnings]
[verbose, report_errors, report_warnings, ?ALL_DEFS]
++ [{i, filename:join(app_dir(App), "include")}
|| App <- [fast_xml, xmpp, p1_utils, ejabberd]]
++ [{i, filename:join(mod_dir(Mod), "include")}