mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-14 22:00:16 +02:00
Merge pull request #1193 from gabrielgatu/support-elixir-module-installer
Fix issue #625: Writing Elixir modules
This commit is contained in:
commit
fad088a3c4
|
@ -45,6 +45,7 @@ start(normal, _Args) ->
|
||||||
write_pid_file(),
|
write_pid_file(),
|
||||||
jid:start(),
|
jid:start(),
|
||||||
start_apps(),
|
start_apps(),
|
||||||
|
start_elixir_application(),
|
||||||
ejabberd:check_app(ejabberd),
|
ejabberd:check_app(ejabberd),
|
||||||
randoms:start(),
|
randoms:start(),
|
||||||
db_init(),
|
db_init(),
|
||||||
|
@ -237,3 +238,9 @@ opt_type(modules) ->
|
||||||
Mods)
|
Mods)
|
||||||
end;
|
end;
|
||||||
opt_type(_) -> [cluster_nodes, loglevel, modules, net_ticktime].
|
opt_type(_) -> [cluster_nodes, loglevel, modules, net_ticktime].
|
||||||
|
|
||||||
|
start_elixir_application() ->
|
||||||
|
case application:ensure_started(elixir) of
|
||||||
|
ok -> ok;
|
||||||
|
{error, Msg} -> ?ERROR_MSG("Elixir application not started.", [])
|
||||||
|
end.
|
||||||
|
|
|
@ -484,17 +484,28 @@ compile_deps(_Module, _Spec, DestDir) ->
|
||||||
filelib:ensure_dir(filename:join(Ebin, ".")),
|
filelib:ensure_dir(filename:join(Ebin, ".")),
|
||||||
Result = lists:foldl(fun(Dep, Acc) ->
|
Result = lists:foldl(fun(Dep, Acc) ->
|
||||||
Inc = filename:join(Dep, "include"),
|
Inc = filename:join(Dep, "include"),
|
||||||
|
Lib = filename:join(Dep, "lib"),
|
||||||
Src = filename:join(Dep, "src"),
|
Src = filename:join(Dep, "src"),
|
||||||
Options = [{outdir, Ebin}, {i, Inc}],
|
Options = [{outdir, Ebin}, {i, Inc}],
|
||||||
[file:copy(App, Ebin) || App <- filelib:wildcard(Src++"/*.app")],
|
[file:copy(App, Ebin) || App <- filelib:wildcard(Src++"/*.app")],
|
||||||
Acc++[case compile:file(File, Options) of
|
|
||||||
|
%% Compile erlang files
|
||||||
|
Acc1 = Acc ++ [case compile:file(File, Options) of
|
||||||
{ok, _} -> ok;
|
{ok, _} -> ok;
|
||||||
{ok, _, _} -> ok;
|
{ok, _, _} -> ok;
|
||||||
{ok, _, _, _} -> ok;
|
{ok, _, _, _} -> ok;
|
||||||
error -> {error, {compilation_failed, File}};
|
error -> {error, {compilation_failed, File}};
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end
|
end
|
||||||
|| File <- filelib:wildcard(Src++"/*.erl")]
|
|| File <- filelib:wildcard(Src++"/*.erl")],
|
||||||
|
|
||||||
|
%% Compile elixir files
|
||||||
|
Acc1 ++ [case compile_elixir_file(Ebin, File) of
|
||||||
|
{ok, _} -> ok;
|
||||||
|
{error, File} -> {error, {compilation_failed, File}}
|
||||||
|
end
|
||||||
|
|| File <- filelib:wildcard(Lib ++ "/*.ex")]
|
||||||
|
|
||||||
end, [], filelib:wildcard("deps/*")),
|
end, [], filelib:wildcard("deps/*")),
|
||||||
case lists:dropwhile(
|
case lists:dropwhile(
|
||||||
fun(ok) -> true;
|
fun(ok) -> true;
|
||||||
|
@ -515,6 +526,8 @@ compile(_Module, _Spec, DestDir) ->
|
||||||
verbose, report_errors, report_warnings]
|
verbose, report_errors, report_warnings]
|
||||||
++ ExtLib,
|
++ ExtLib,
|
||||||
[file:copy(App, Ebin) || App <- filelib:wildcard("src/*.app")],
|
[file:copy(App, Ebin) || App <- filelib:wildcard("src/*.app")],
|
||||||
|
|
||||||
|
%% Compile erlang files
|
||||||
Result = [case compile:file(File, Options) of
|
Result = [case compile:file(File, Options) of
|
||||||
{ok, _} -> ok;
|
{ok, _} -> ok;
|
||||||
{ok, _, _} -> ok;
|
{ok, _, _} -> ok;
|
||||||
|
@ -523,14 +536,32 @@ compile(_Module, _Spec, DestDir) ->
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end
|
end
|
||||||
|| File <- filelib:wildcard("src/*.erl")],
|
|| File <- filelib:wildcard("src/*.erl")],
|
||||||
|
|
||||||
|
%% Compile elixir files
|
||||||
|
Result1 = Result ++ [case compile_elixir_file(Ebin, File) of
|
||||||
|
{ok, _} -> ok;
|
||||||
|
{error, File} -> {error, {compilation_failed, File}}
|
||||||
|
end
|
||||||
|
|| File <- filelib:wildcard("lib/*.ex")],
|
||||||
|
|
||||||
case lists:dropwhile(
|
case lists:dropwhile(
|
||||||
fun(ok) -> true;
|
fun(ok) -> true;
|
||||||
(_) -> false
|
(_) -> false
|
||||||
end, Result) of
|
end, Result1) of
|
||||||
[] -> ok;
|
[] -> ok;
|
||||||
[Error|_] -> Error
|
[Error|_] -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
compile_elixir_file(Dest, File) when is_list(Dest) and is_list(File) ->
|
||||||
|
compile_elixir_file(list_to_binary(Dest), list_to_binary(File));
|
||||||
|
|
||||||
|
compile_elixir_file(Dest, File) ->
|
||||||
|
try 'Elixir.Kernel.ParallelCompiler':files_to_path([File], Dest, []) of
|
||||||
|
[Module] -> {ok, Module}
|
||||||
|
catch
|
||||||
|
_ -> {error, File}
|
||||||
|
end.
|
||||||
|
|
||||||
install(Module, Spec, DestDir) ->
|
install(Module, Spec, DestDir) ->
|
||||||
Errors = lists:dropwhile(fun({_, {ok, _}}) -> true;
|
Errors = lists:dropwhile(fun({_, {ok, _}}) -> true;
|
||||||
(_) -> false
|
(_) -> false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user