]> granicus.if.org Git - ejabberd/commitdiff
Fix compilation of external module with new xmpp lib
authorChristophe Romain <christophe.romain@process-one.net>
Tue, 6 Dec 2016 11:01:04 +0000 (12:01 +0100)
committerChristophe Romain <christophe.romain@process-one.net>
Tue, 6 Dec 2016 11:01:04 +0000 (12:01 +0100)
src/ext_mod.erl
src/mod_admin_extra.erl

index 5b970623b6e63f19574b96e8add1c98f361dd89b..b6fbc64dd39a657df1dfd32861148e6944793fa1 100644 (file)
@@ -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
index 7f618a66d541de38d65ab52d992e58808cae2282..70da82636b1d9cdc172178572b3bf7e106e66311 100644 (file)
@@ -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()).