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()],
|
||||
filelib:ensure_dir(filename:join(Bin, ".")),
|
||||
[copy(App, Bin) || App <- filelib:wildcard(Src++"/*.app")],
|
||||
compile_c_files(LibDir),
|
||||
Er = [compile_erlang_file(Bin, File, Options)
|
||||
|| File <- filelib:wildcard(Src++"/*.erl")],
|
||||
Ex = [compile_elixir_file(Bin, File)
|
||||
|| File <- filelib:wildcard(Lib ++ "/*.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) ->
|
||||
case lists:dropwhile(
|
||||
fun({ok, _}) -> true;
|
||||
@ -649,6 +658,7 @@ install(Module, Spec, SrcDir, LibDir) ->
|
||||
Errors = lists:dropwhile(fun({_, ok}) -> true;
|
||||
(_) -> false
|
||||
end, Files1++Files2),
|
||||
copy_priv_files(LibDir),
|
||||
inform_module_configuration(Module, LibDir, Files1),
|
||||
Result = case Errors of
|
||||
[{F, {error, E}}|_] ->
|
||||
@ -661,6 +671,12 @@ install(Module, Spec, SrcDir, LibDir) ->
|
||||
file:set_cwd(CurDir),
|
||||
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) ->
|
||||
Res = lists:filter(fun({[$c, $o, $n, $f |_], ok}) -> true;
|
||||
(_) -> false
|
||||
|
Loading…
Reference in New Issue
Block a user