mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Use rebar_utils:find_files_by_ext/2,3
This commit is contained in:
parent
a04530124f
commit
135e629bc0
5 changed files with 15 additions and 19 deletions
|
@ -69,8 +69,8 @@
|
||||||
{_Added, _Removed, Upgraded} = get_apps(Name, OldVerPath, NewVerPath),
|
{_Added, _Removed, Upgraded} = get_apps(Name, OldVerPath, NewVerPath),
|
||||||
|
|
||||||
%% Get a list of any appup files that exist in the new release
|
%% Get a list of any appup files that exist in the new release
|
||||||
NewAppUpFiles = rebar_utils:find_files(
|
NewAppUpFiles = rebar_utils:find_files_by_ext(
|
||||||
filename:join([NewVerPath, "lib"]), "^[^._].*.appup$"),
|
filename:join([NewVerPath, "lib"]), ".appup"),
|
||||||
|
|
||||||
%% Convert the list of appup files into app names
|
%% Convert the list of appup files into app names
|
||||||
AppUpApps = [file_to_name(File) || File <- NewAppUpFiles],
|
AppUpApps = [file_to_name(File) || File <- NewAppUpFiles],
|
||||||
|
|
|
@ -47,8 +47,6 @@
|
||||||
info = {[], []} :: erlc_info()
|
info = {[], []} :: erlc_info()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-define(RE_PREFIX, "^[^._]").
|
|
||||||
|
|
||||||
-ifdef(namespaced_types).
|
-ifdef(namespaced_types).
|
||||||
%% digraph:graph() exists starting from Erlang 17.
|
%% digraph:graph() exists starting from Erlang 17.
|
||||||
-type rebar_digraph() :: digraph:graph().
|
-type rebar_digraph() :: digraph:graph().
|
||||||
|
@ -112,14 +110,14 @@ compile(Config, _AppFile) ->
|
||||||
|
|
||||||
-spec clean(rebar_config:config(), file:filename()) -> 'ok'.
|
-spec clean(rebar_config:config(), file:filename()) -> 'ok'.
|
||||||
clean(Config, _AppFile) ->
|
clean(Config, _AppFile) ->
|
||||||
MibFiles = rebar_utils:find_files("mibs", ?RE_PREFIX".*\\.mib\$"),
|
MibFiles = rebar_utils:find_files_by_ext("mibs", ".mib"),
|
||||||
MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles],
|
MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles],
|
||||||
rebar_file_utils:delete_each(
|
rebar_file_utils:delete_each(
|
||||||
[filename:join(["include",MIB++".hrl"]) || MIB <- MIBs]),
|
[filename:join(["include",MIB++".hrl"]) || MIB <- MIBs]),
|
||||||
lists:foreach(fun(F) -> ok = rebar_file_utils:rm_rf(F) end,
|
lists:foreach(fun(F) -> ok = rebar_file_utils:rm_rf(F) end,
|
||||||
["ebin/*.beam", "priv/mibs/*.bin"]),
|
["ebin/*.beam", "priv/mibs/*.bin"]),
|
||||||
|
|
||||||
YrlFiles = rebar_utils:find_files("src", ?RE_PREFIX".*\\.[x|y]rl\$"),
|
YrlFiles = rebar_utils:find_files_by_ext("src", ".[x|y]rl"),
|
||||||
rebar_file_utils:delete_each(
|
rebar_file_utils:delete_each(
|
||||||
[ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl")))
|
[ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl")))
|
||||||
|| F <- YrlFiles ]),
|
|| F <- YrlFiles ]),
|
||||||
|
@ -131,7 +129,7 @@ clean(Config, _AppFile) ->
|
||||||
%% directory structure in ebin with .beam files within. As such, we want
|
%% directory structure in ebin with .beam files within. As such, we want
|
||||||
%% to scan whatever is left in the ebin/ directory for sub-dirs which
|
%% to scan whatever is left in the ebin/ directory for sub-dirs which
|
||||||
%% satisfy our criteria.
|
%% satisfy our criteria.
|
||||||
BeamFiles = rebar_utils:find_files("ebin", ?RE_PREFIX".*\\.beam\$"),
|
BeamFiles = rebar_utils:find_files_by_ext("ebin", ".beam"),
|
||||||
rebar_file_utils:delete_each(BeamFiles),
|
rebar_file_utils:delete_each(BeamFiles),
|
||||||
lists:foreach(fun(Dir) -> delete_dir(Dir, dirs(Dir)) end, dirs("ebin")),
|
lists:foreach(fun(Dir) -> delete_dir(Dir, dirs(Dir)) end, dirs("ebin")),
|
||||||
ok.
|
ok.
|
||||||
|
@ -142,7 +140,7 @@ clean(Config, _AppFile) ->
|
||||||
|
|
||||||
test_compile(Config, Cmd, OutDir) ->
|
test_compile(Config, Cmd, OutDir) ->
|
||||||
%% Obtain all the test modules for inclusion in the compile stage.
|
%% Obtain all the test modules for inclusion in the compile stage.
|
||||||
TestErls = rebar_utils:find_files("test", ?RE_PREFIX".*\\.erl\$"),
|
TestErls = rebar_utils:find_files_by_ext("test", ".erl"),
|
||||||
|
|
||||||
ErlOpts = rebar_utils:erl_opts(Config),
|
ErlOpts = rebar_utils:erl_opts(Config),
|
||||||
{Config1, ErlOpts1} = test_compile_config_and_opts(Config, ErlOpts, Cmd),
|
{Config1, ErlOpts1} = test_compile_config_and_opts(Config, ErlOpts, Cmd),
|
||||||
|
@ -153,8 +151,7 @@ test_compile(Config, Cmd, OutDir) ->
|
||||||
SrcDirs = rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts1)),
|
SrcDirs = rebar_utils:src_dirs(proplists:append_values(src_dirs, ErlOpts1)),
|
||||||
SrcErls = lists:foldl(
|
SrcErls = lists:foldl(
|
||||||
fun(Dir, Acc) ->
|
fun(Dir, Acc) ->
|
||||||
Files = rebar_utils:find_files(
|
Files = rebar_utils:find_files_by_ext(Dir, ".erl"),
|
||||||
Dir, ?RE_PREFIX".*\\.erl\$"),
|
|
||||||
lists:append(Acc, Files)
|
lists:append(Acc, Files)
|
||||||
end, [], SrcDirs),
|
end, [], SrcDirs),
|
||||||
|
|
||||||
|
@ -649,7 +646,7 @@ gather_src([], Srcs) ->
|
||||||
Srcs;
|
Srcs;
|
||||||
gather_src([Dir|Rest], Srcs) ->
|
gather_src([Dir|Rest], Srcs) ->
|
||||||
gather_src(
|
gather_src(
|
||||||
Rest, Srcs ++ rebar_utils:find_files(Dir, ?RE_PREFIX".*\\.erl\$")).
|
Rest, Srcs ++ rebar_utils:find_files_by_ext(Dir, ".erl")).
|
||||||
|
|
||||||
-spec dirs(file:filename()) -> [file:filename()].
|
-spec dirs(file:filename()) -> [file:filename()].
|
||||||
dirs(Dir) ->
|
dirs(Dir) ->
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
compile(Config, AppFile) ->
|
compile(Config, AppFile) ->
|
||||||
case rebar_utils:find_files("src", "^[^._].*\\.proto$") of
|
case rebar_utils:find_files_by_ext("src", ".proto", true) of
|
||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
Protos ->
|
Protos ->
|
||||||
|
@ -56,7 +56,7 @@ compile(Config, AppFile) ->
|
||||||
|
|
||||||
clean(Config, AppFile) ->
|
clean(Config, AppFile) ->
|
||||||
%% Get a list of generated .beam and .hrl files and then delete them
|
%% Get a list of generated .beam and .hrl files and then delete them
|
||||||
Protos = rebar_utils:find_files("src", "^[^._].*\\.proto$"),
|
Protos = rebar_utils:find_files_by_ext("src", ".proto", true),
|
||||||
case Protos of
|
case Protos of
|
||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
|
|
|
@ -211,7 +211,7 @@ qc_module(QC=eqc, [], M) -> QC:module(M);
|
||||||
qc_module(QC=eqc, QCOpts, M) -> QC:module(QCOpts, M).
|
qc_module(QC=eqc, QCOpts, M) -> QC:module(QCOpts, M).
|
||||||
|
|
||||||
find_prop_mods() ->
|
find_prop_mods() ->
|
||||||
Beams = rebar_utils:find_files(?QC_DIR, "^[^._].*\\.beam\$"),
|
Beams = rebar_utils:find_files_by_ext(?QC_DIR, ".beam"),
|
||||||
[M || M <- [rebar_utils:erl_to_mod(Beam) || Beam <- Beams], has_prop(M)].
|
[M || M <- [rebar_utils:erl_to_mod(Beam) || Beam <- Beams], has_prop(M)].
|
||||||
|
|
||||||
has_prop(Mod) ->
|
has_prop(Mod) ->
|
||||||
|
|
|
@ -242,11 +242,10 @@ find_escript_templates(Files) ->
|
||||||
|
|
||||||
find_disk_templates(Config) ->
|
find_disk_templates(Config) ->
|
||||||
OtherTemplates = find_other_templates(Config),
|
OtherTemplates = find_other_templates(Config),
|
||||||
HomeFiles = rebar_utils:find_files(filename:join([os:getenv("HOME"),
|
HomeTemplates = filename:join([os:getenv("HOME"), ".rebar", "templates"]),
|
||||||
".rebar", "templates"]),
|
HomeFiles = rebar_utils:find_files_by_ext(HomeTemplates, ".template"),
|
||||||
?TEMPLATE_RE),
|
|
||||||
Recursive = rebar_config:is_recursive(Config),
|
Recursive = rebar_config:is_recursive(Config),
|
||||||
LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE, Recursive),
|
LocalFiles = rebar_utils:find_files_by_ext(".", ".template", Recursive),
|
||||||
[{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles].
|
[{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles].
|
||||||
|
|
||||||
find_other_templates(Config) ->
|
find_other_templates(Config) ->
|
||||||
|
@ -254,7 +253,7 @@ find_other_templates(Config) ->
|
||||||
undefined ->
|
undefined ->
|
||||||
[];
|
[];
|
||||||
TemplateDir ->
|
TemplateDir ->
|
||||||
rebar_utils:find_files(TemplateDir, ?TEMPLATE_RE)
|
rebar_utils:find_files_by_ext(TemplateDir, ".template")
|
||||||
end.
|
end.
|
||||||
|
|
||||||
select_template([], Template) ->
|
select_template([], Template) ->
|
||||||
|
|
Loading…
Reference in a new issue