From 1883a98d1cdc853bb61b44da9e32e1e7d89303b0 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Tue, 6 Dec 2016 12:01:04 +0100 Subject: [PATCH] Fix compilation of external module with new xmpp lib --- src/ext_mod.erl | 11 ++++++----- src/mod_admin_extra.erl | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ext_mod.erl b/src/ext_mod.erl index 5b970623b..b6fbc64dd 100644 --- a/src/ext_mod.erl +++ b/src/ext_mod.erl @@ -493,7 +493,8 @@ compile_deps(_Module, _Spec, DestDir) -> Inc = filename:join(Dep, "include"), Lib = filename:join(Dep, "lib"), Src = filename:join(Dep, "src"), - Options = [{outdir, Ebin}, {i, Inc}], + Options = [verbose, report_errors, report_warnings, + {outdir, Ebin}, {i, Inc}], [file:copy(App, Ebin) || App <- filelib:wildcard(Src++"/*.app")], %% Compile erlang files @@ -525,10 +526,10 @@ compile_deps(_Module, _Spec, DestDir) -> compile(_Module, _Spec, DestDir) -> Ebin = filename:join(DestDir, "ebin"), filelib:ensure_dir(filename:join(Ebin, ".")), - EjabBin = filename:dirname(code:which(ejabberd)), - EjabInc = filename:join(filename:dirname(EjabBin), "include"), - Options = [{outdir, Ebin}, {i, "include"}, {i, EjabInc}, - verbose, report_errors, report_warnings], + Includes = [{i, filename:join(code:lib_dir(App), "include")} + || App <- [fast_xml, xmpp, ejabberd]], + Options = [verbose, report_errors, report_warnings, + {outdir, Ebin}, {i, "include"} | Includes], [file:copy(App, Ebin) || App <- filelib:wildcard("src/*.app")], %% Compile erlang files diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index 7f618a66d..70da82636 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -639,11 +639,22 @@ get_commands_spec() -> %%% -%%% Node +%%% Adminsys %%% compile(File) -> - compile:file(File). + Includes = [{i, filename:join(code:lib_dir(App), "include")} + || App <- [fast_xml, xmpp, ejabberd]], + Ebin = filename:join(code:lib_dir(ejabberd), "ebin"), + case compile:file(File, [{outdir, Ebin}|Includes]) of + error -> error; + {error, _, _} -> error; + OK -> + [ok, ModuleName | _] = tuple_to_list(OK), + code:purge(ModuleName), + code:load_file(ModuleName), + ok + end. get_cookie() -> atom_to_list(erlang:get_cookie()).