mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
External modules: compile C files and install them in ejabberd's priv
This commit is contained in:
parent
5d38143c3f
commit
5c1b72853f
@ -565,12 +565,21 @@ compile(LibDir) ->
|
|||||||
Options = [{outdir, Bin}, {i, Inc} | compile_options()],
|
Options = [{outdir, Bin}, {i, Inc} | compile_options()],
|
||||||
filelib:ensure_dir(filename:join(Bin, ".")),
|
filelib:ensure_dir(filename:join(Bin, ".")),
|
||||||
[copy(App, Bin) || App <- filelib:wildcard(Src++"/*.app")],
|
[copy(App, Bin) || App <- filelib:wildcard(Src++"/*.app")],
|
||||||
|
compile_c_files(LibDir),
|
||||||
Er = [compile_erlang_file(Bin, File, Options)
|
Er = [compile_erlang_file(Bin, File, Options)
|
||||||
|| File <- filelib:wildcard(Src++"/*.erl")],
|
|| File <- filelib:wildcard(Src++"/*.erl")],
|
||||||
Ex = [compile_elixir_file(Bin, File)
|
Ex = [compile_elixir_file(Bin, File)
|
||||||
|| File <- filelib:wildcard(Lib ++ "/*.ex")],
|
|| File <- filelib:wildcard(Lib ++ "/*.ex")],
|
||||||
compile_result(Er++Ex).
|
compile_result(Er++Ex).
|
||||||
|
|
||||||
|
compile_c_files(LibDir) ->
|
||||||
|
case file:read_file_info(filename:join(LibDir, "c_src/Makefile")) of
|
||||||
|
{ok, _} ->
|
||||||
|
os:cmd("cd "++LibDir++"; make -C c_src");
|
||||||
|
{error, _} ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
compile_result(Results) ->
|
compile_result(Results) ->
|
||||||
case lists:dropwhile(
|
case lists:dropwhile(
|
||||||
fun({ok, _}) -> true;
|
fun({ok, _}) -> true;
|
||||||
@ -649,6 +658,7 @@ install(Module, Spec, SrcDir, LibDir) ->
|
|||||||
Errors = lists:dropwhile(fun({_, ok}) -> true;
|
Errors = lists:dropwhile(fun({_, ok}) -> true;
|
||||||
(_) -> false
|
(_) -> false
|
||||||
end, Files1++Files2),
|
end, Files1++Files2),
|
||||||
|
copy_priv_files(LibDir),
|
||||||
inform_module_configuration(Module, LibDir, Files1),
|
inform_module_configuration(Module, LibDir, Files1),
|
||||||
Result = case Errors of
|
Result = case Errors of
|
||||||
[{F, {error, E}}|_] ->
|
[{F, {error, E}}|_] ->
|
||||||
@ -661,6 +671,12 @@ install(Module, Spec, SrcDir, LibDir) ->
|
|||||||
file:set_cwd(CurDir),
|
file:set_cwd(CurDir),
|
||||||
Result.
|
Result.
|
||||||
|
|
||||||
|
copy_priv_files(LibDir) ->
|
||||||
|
file:set_cwd(LibDir),
|
||||||
|
EjabberdLibDir = code:lib_dir(ejabberd),
|
||||||
|
[{File, copy(File, filename:join(EjabberdLibDir, File))}
|
||||||
|
|| File <- filelib:wildcard("{priv}/**")].
|
||||||
|
|
||||||
inform_module_configuration(Module, LibDir, Files1) ->
|
inform_module_configuration(Module, LibDir, Files1) ->
|
||||||
Res = lists:filter(fun({[$c, $o, $n, $f |_], ok}) -> true;
|
Res = lists:filter(fun({[$c, $o, $n, $f |_], ok}) -> true;
|
||||||
(_) -> false
|
(_) -> false
|
||||||
|
Loading…
Reference in New Issue
Block a user