mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Ignore beams compiled by Elixir
This commit is contained in:
parent
56a0e736c7
commit
ea76b87461
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env escript
|
#!/usr/bin/env escript
|
||||||
%% -*- erlang -*-
|
%% -*- erlang -*-
|
||||||
%%! -pa ebin
|
|
||||||
|
|
||||||
-record(state, {run_hooks = dict:new(),
|
-record(state, {run_hooks = dict:new(),
|
||||||
run_fold_hooks = dict:new(),
|
run_fold_hooks = dict:new(),
|
||||||
@ -342,12 +341,16 @@ fold_beams(Fun, State, Paths) ->
|
|||||||
fun(File, {I, Acc}) ->
|
fun(File, {I, Acc}) ->
|
||||||
io:format("Progress: ~B% (~B/~B)\r",
|
io:format("Progress: ~B% (~B/~B)\r",
|
||||||
[round(I*100/Total), I, Total]),
|
[round(I*100/Total), I, Total]),
|
||||||
|
case is_elixir_beam(File) of
|
||||||
|
true -> {I+1, Acc};
|
||||||
|
false ->
|
||||||
AbsCode = get_code_from_beam(File),
|
AbsCode = get_code_from_beam(File),
|
||||||
Acc2 = lists:foldl(
|
Acc2 = lists:foldl(
|
||||||
fun(Form, Acc1) ->
|
fun(Form, Acc1) ->
|
||||||
Fun(File, Form, Acc1)
|
Fun(File, Form, Acc1)
|
||||||
end, Acc, AbsCode),
|
end, Acc, AbsCode),
|
||||||
{I+1, Acc2}
|
{I+1, Acc2}
|
||||||
|
end
|
||||||
end, {0, State}, Paths1),
|
end, {0, State}, Paths1),
|
||||||
State1.
|
State1.
|
||||||
|
|
||||||
@ -356,17 +359,28 @@ fold_paths(Paths) ->
|
|||||||
fun(Path) ->
|
fun(Path) ->
|
||||||
case filelib:is_dir(Path) of
|
case filelib:is_dir(Path) of
|
||||||
true ->
|
true ->
|
||||||
lists:reverse(
|
Beams = lists:reverse(
|
||||||
filelib:fold_files(
|
filelib:fold_files(
|
||||||
Path, ".+\.beam\$", false,
|
Path, ".+\.beam\$", false,
|
||||||
fun(File, Acc) ->
|
fun(File, Acc) ->
|
||||||
[File|Acc]
|
[File|Acc]
|
||||||
end, []));
|
end, [])),
|
||||||
|
case Beams of
|
||||||
|
[] -> ok;
|
||||||
|
_ -> code:add_path(Path)
|
||||||
|
end,
|
||||||
|
Beams;
|
||||||
false ->
|
false ->
|
||||||
[Path]
|
[Path]
|
||||||
end
|
end
|
||||||
end, Paths).
|
end, Paths).
|
||||||
|
|
||||||
|
is_elixir_beam(File) ->
|
||||||
|
case filename:basename(File) of
|
||||||
|
"Elixir" ++ _ -> true;
|
||||||
|
_ -> false
|
||||||
|
end.
|
||||||
|
|
||||||
get_code_from_beam(File) ->
|
get_code_from_beam(File) ->
|
||||||
try
|
try
|
||||||
{ok, {_, List}} = beam_lib:chunks(File, [abstract_code]),
|
{ok, {_, List}} = beam_lib:chunks(File, [abstract_code]),
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env escript
|
#!/usr/bin/env escript
|
||||||
%% -*- erlang -*-
|
%% -*- erlang -*-
|
||||||
%%! -pa ebin
|
|
||||||
|
|
||||||
-compile([nowarn_unused_function]).
|
-compile([nowarn_unused_function]).
|
||||||
-record(state, {g_opts = #{} :: map(),
|
-record(state, {g_opts = #{} :: map(),
|
||||||
@ -495,6 +494,9 @@ fold_beams(Fun, State, Paths) ->
|
|||||||
fun(File, {I, Acc}) ->
|
fun(File, {I, Acc}) ->
|
||||||
io:format("Progress: ~B% (~B/~B)\r",
|
io:format("Progress: ~B% (~B/~B)\r",
|
||||||
[round(I*100/Total), I, Total]),
|
[round(I*100/Total), I, Total]),
|
||||||
|
case is_elixir_beam(File) of
|
||||||
|
true -> {I+1, Acc};
|
||||||
|
false ->
|
||||||
AbsCode = get_code_from_beam(File),
|
AbsCode = get_code_from_beam(File),
|
||||||
Acc2 = case is_behaviour(AbsCode, ejabberd_config) of
|
Acc2 = case is_behaviour(AbsCode, ejabberd_config) of
|
||||||
true ->
|
true ->
|
||||||
@ -503,6 +505,7 @@ fold_beams(Fun, State, Paths) ->
|
|||||||
fold_mod_opt(File, Fun, Acc, AbsCode)
|
fold_mod_opt(File, Fun, Acc, AbsCode)
|
||||||
end,
|
end,
|
||||||
{I+1, Acc2}
|
{I+1, Acc2}
|
||||||
|
end
|
||||||
end, {0, State}, Paths1),
|
end, {0, State}, Paths1),
|
||||||
State1.
|
State1.
|
||||||
|
|
||||||
@ -543,12 +546,17 @@ fold_paths(Paths) ->
|
|||||||
fun(Path) ->
|
fun(Path) ->
|
||||||
case filelib:is_dir(Path) of
|
case filelib:is_dir(Path) of
|
||||||
true ->
|
true ->
|
||||||
lists:reverse(
|
Beams = lists:reverse(
|
||||||
filelib:fold_files(
|
filelib:fold_files(
|
||||||
Path, ".+\.beam\$", false,
|
Path, ".+\.beam\$", false,
|
||||||
fun(File, Acc) ->
|
fun(File, Acc) ->
|
||||||
[File|Acc]
|
[File|Acc]
|
||||||
end, []));
|
end, [])),
|
||||||
|
case Beams of
|
||||||
|
[] -> ok;
|
||||||
|
_ -> code:add_path(Path)
|
||||||
|
end,
|
||||||
|
Beams;
|
||||||
false ->
|
false ->
|
||||||
[Path]
|
[Path]
|
||||||
end
|
end
|
||||||
@ -566,6 +574,12 @@ is_behaviour(AbsCode, Mod) ->
|
|||||||
end
|
end
|
||||||
end, AbsCode).
|
end, AbsCode).
|
||||||
|
|
||||||
|
is_elixir_beam(File) ->
|
||||||
|
case filename:basename(File) of
|
||||||
|
"Elixir" ++ _ -> true;
|
||||||
|
_ -> false
|
||||||
|
end.
|
||||||
|
|
||||||
get_code_from_beam(File) ->
|
get_code_from_beam(File) ->
|
||||||
try
|
try
|
||||||
{ok, {_, List}} = beam_lib:chunks(File, [abstract_code]),
|
{ok, {_, List}} = beam_lib:chunks(File, [abstract_code]),
|
||||||
|
Loading…
Reference in New Issue
Block a user