chore(build): fix rebar dependency and add a script to ensure integrity
This commit is contained in:
parent
6fb5c9de42
commit
e3407b9556
|
@ -1,5 +1,5 @@
|
||||||
{deps,
|
{deps,
|
||||||
[{pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.3"}}}
|
[{pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{edoc_opts, [{preprocess, true}]}.
|
{edoc_opts, [{preprocess, true}]}.
|
||||||
|
|
|
@ -1,14 +1 @@
|
||||||
{edoc_opts, [{preprocess, true}]}.
|
{deps, []}.
|
||||||
{erl_opts, [warn_unused_vars,
|
|
||||||
warn_shadow_vars,
|
|
||||||
warn_unused_import,
|
|
||||||
warn_obsolete_guard,
|
|
||||||
debug_info,
|
|
||||||
{parse_transform}]}.
|
|
||||||
|
|
||||||
{xref_checks, [undefined_function_calls, undefined_functions,
|
|
||||||
locals_not_used, deprecated_function_calls,
|
|
||||||
warnings_as_errors, deprecated_functions]}.
|
|
||||||
{cover_enabled, true}.
|
|
||||||
{cover_opts, [verbose]}.
|
|
||||||
{cover_export_enabled, true}.
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/env escript
|
||||||
|
|
||||||
|
%% NOTE: this script should be executed at project root.
|
||||||
|
|
||||||
|
-mode(compile).
|
||||||
|
|
||||||
|
main([]) ->
|
||||||
|
AppsDir = case filelib:is_file("EMQX_ENTERPRISE") of
|
||||||
|
true -> "lib-ee";
|
||||||
|
false -> "lib-ce"
|
||||||
|
end,
|
||||||
|
true = filelib:is_dir(AppsDir),
|
||||||
|
Files = ["rebar.config"] ++
|
||||||
|
apps_rebar_config("apps") ++
|
||||||
|
apps_rebar_config(AppsDir),
|
||||||
|
Deps = collect_deps(Files, #{}),
|
||||||
|
case count_bad_deps(Deps) of
|
||||||
|
0 ->
|
||||||
|
io:format("OK~n");
|
||||||
|
N ->
|
||||||
|
io:format(standard_error, "~p dependency discrepancies", [N]),
|
||||||
|
halt(1)
|
||||||
|
end.
|
||||||
|
|
||||||
|
apps_rebar_config(Dir) ->
|
||||||
|
filelib:wildcard(filename:join([Dir, "*", "rebar.config"])).
|
||||||
|
|
||||||
|
%% collect a kv-list of {DepName, [{DepReference, RebarConfigFile}]}
|
||||||
|
%% the value part should have unique DepReference
|
||||||
|
collect_deps([], Acc) -> maps:to_list(Acc);
|
||||||
|
collect_deps([File | Files], Acc) ->
|
||||||
|
Deps =
|
||||||
|
try
|
||||||
|
{ok, Config} = file:consult(File),
|
||||||
|
{deps, Deps0} = lists:keyfind(deps, 1, Config),
|
||||||
|
Deps0
|
||||||
|
catch
|
||||||
|
C : E : St ->
|
||||||
|
erlang:raise(C, {E, {failed_to_find_deps_in_rebar_config, File}}, St)
|
||||||
|
end,
|
||||||
|
collect_deps(Files, do_collect_deps(Deps, File, Acc)).
|
||||||
|
|
||||||
|
do_collect_deps([], _File, Acc) -> Acc;
|
||||||
|
do_collect_deps([{Name, Ref} | Deps], File, Acc) ->
|
||||||
|
Refs = maps:get(Name, Acc, []),
|
||||||
|
do_collect_deps(Deps, File, Acc#{Name => [{Ref, File} | Refs]}).
|
||||||
|
|
||||||
|
count_bad_deps([]) -> 0;
|
||||||
|
count_bad_deps([{Name, Refs0} | Rest]) ->
|
||||||
|
Refs = lists:keysort(1, Refs0),
|
||||||
|
case is_unique_ref(Refs) of
|
||||||
|
true ->
|
||||||
|
count_bad_deps(Rest);
|
||||||
|
false ->
|
||||||
|
io:format(standard_error, "~p:~n~p~n", [Name, Refs]),
|
||||||
|
1 + count_bad_deps(Rest)
|
||||||
|
end.
|
||||||
|
|
||||||
|
is_unique_ref([_]) -> true;
|
||||||
|
is_unique_ref([{Ref, _File1}, {Ref, File2} | Rest]) ->
|
||||||
|
is_unique_ref([{Ref, File2} | Rest]);
|
||||||
|
is_unique_ref(_) ->
|
||||||
|
false.
|
Loading…
Reference in New Issue