]> granicus.if.org Git - ejabberd/commitdiff
Generate ejabberd lib dir when not available in code server (#1665)
authorChristophe Romain <christophe.romain@process-one.net>
Fri, 7 Apr 2017 10:09:43 +0000 (12:09 +0200)
committerChristophe Romain <christophe.romain@process-one.net>
Fri, 7 Apr 2017 10:09:43 +0000 (12:09 +0200)
This is the case if running ejabberd from development directory
when code:lib_dir(ejabberd) returns {error, nad_name}.

src/ext_mod.erl

index bff9781ff762e5e27382a82bdfda1ed6f5a89502..fe68136325acb2eaa5efcb0244f6c986592b53c3 100644 (file)
@@ -541,9 +541,22 @@ compile_result(Results) ->
 
 compile_options() ->
     [verbose, report_errors, report_warnings]
-    ++ [{i, filename:join(code:lib_dir(App), "include")}
+    ++ [{i, filename:join(app_dir(App), "include")}
         || App <- [fast_xml, xmpp, ejabberd]].
 
+app_dir(App) ->
+    case code:lib_dir(App) of
+        {error, bad_name} ->
+            case code:which(App) of
+                Beam when is_list(Beam) ->
+                    filename:dirname(filename:dirname(Beam));
+                _ ->
+                    "."
+            end;
+        Dir ->
+            Dir
+    end.
+
 compile_erlang_file(Dest, File) ->
     compile_erlang_file(Dest, File, compile_options()).