25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

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
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 defp erlc_options do
# Use our own includes + includes from all dependencies # Use our own includes + includes from all dependencies
includes = ["include"] ++ deps_include(["fast_xml", "xmpp", "p1_utils"]) includes = ["include"] ++ deps_include(["fast_xml", "xmpp", "p1_utils"])
[:debug_info, {:d, :ELIXIR_ENABLED}] ++ cond_options() ++ Enum.map(includes, fn(path) -> {:i, path} end) ++ result = [:debug_info, {:d, :ELIXIR_ENABLED}] ++
if_version_above('20', [{:d, :DEPRECATED_GET_STACKTRACE}]) ++ cond_options() ++
if_function_exported(:erl_error, :format_exception, 6, [{:d, :HAVE_ERL_ERROR}]) 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 end
defp cond_options do defp cond_options do

View File

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

View File

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