mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 11:09:55 +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),
|
||||
|
||||
%% Get a list of any appup files that exist in the new release
|
||||
NewAppUpFiles = rebar_utils:find_files(
|
||||
filename:join([NewVerPath, "lib"]), "^[^._].*.appup$"),
|
||||
NewAppUpFiles = rebar_utils:find_files_by_ext(
|
||||
filename:join([NewVerPath, "lib"]), ".appup"),
|
||||
|
||||
%% Convert the list of appup files into app names
|
||||
AppUpApps = [file_to_name(File) || File <- NewAppUpFiles],
|
||||
|
|
|
@ -47,8 +47,6 @@
|
|||
info = {[], []} :: erlc_info()
|
||||
}).
|
||||
|
||||
-define(RE_PREFIX, "^[^._]").
|
||||
|
||||
-ifdef(namespaced_types).
|
||||
%% digraph:graph() exists starting from Erlang 17.
|
||||
-type rebar_digraph() :: digraph:graph().
|
||||
|
@ -112,14 +110,14 @@ compile(Config, _AppFile) ->
|
|||
|
||||
-spec clean(rebar_config:config(), file:filename()) -> 'ok'.
|
||||
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],
|
||||
rebar_file_utils:delete_each(
|
||||
[filename:join(["include",MIB++".hrl"]) || MIB <- MIBs]),
|
||||
lists:foreach(fun(F) -> ok = rebar_file_utils:rm_rf(F) end,
|
||||
["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(
|
||||
[ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl")))
|
||||
|| F <- YrlFiles ]),
|
||||
|
@ -131,7 +129,7 @@ clean(Config, _AppFile) ->
|
|||
%% 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
|
||||
%% 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),
|
||||
lists:foreach(fun(Dir) -> delete_dir(Dir, dirs(Dir)) end, dirs("ebin")),
|
||||
ok.
|
||||
|
@ -142,7 +140,7 @@ clean(Config, _AppFile) ->
|
|||
|
||||
test_compile(Config, Cmd, OutDir) ->
|
||||
%% 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),
|
||||
{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)),
|
||||
SrcErls = lists:foldl(
|
||||
fun(Dir, Acc) ->
|
||||
Files = rebar_utils:find_files(
|
||||
Dir, ?RE_PREFIX".*\\.erl\$"),
|
||||
Files = rebar_utils:find_files_by_ext(Dir, ".erl"),
|
||||
lists:append(Acc, Files)
|
||||
end, [], SrcDirs),
|
||||
|
||||
|
@ -649,7 +646,7 @@ gather_src([], Srcs) ->
|
|||
Srcs;
|
||||
gather_src([Dir|Rest], Srcs) ->
|
||||
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()].
|
||||
dirs(Dir) ->
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
%% ===================================================================
|
||||
|
||||
compile(Config, AppFile) ->
|
||||
case rebar_utils:find_files("src", "^[^._].*\\.proto$") of
|
||||
case rebar_utils:find_files_by_ext("src", ".proto", true) of
|
||||
[] ->
|
||||
ok;
|
||||
Protos ->
|
||||
|
@ -56,7 +56,7 @@ compile(Config, AppFile) ->
|
|||
|
||||
clean(Config, AppFile) ->
|
||||
%% 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
|
||||
[] ->
|
||||
ok;
|
||||
|
|
|
@ -211,7 +211,7 @@ qc_module(QC=eqc, [], M) -> QC:module(M);
|
|||
qc_module(QC=eqc, QCOpts, M) -> QC:module(QCOpts, M).
|
||||
|
||||
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)].
|
||||
|
||||
has_prop(Mod) ->
|
||||
|
|
|
@ -242,11 +242,10 @@ find_escript_templates(Files) ->
|
|||
|
||||
find_disk_templates(Config) ->
|
||||
OtherTemplates = find_other_templates(Config),
|
||||
HomeFiles = rebar_utils:find_files(filename:join([os:getenv("HOME"),
|
||||
".rebar", "templates"]),
|
||||
?TEMPLATE_RE),
|
||||
HomeTemplates = filename:join([os:getenv("HOME"), ".rebar", "templates"]),
|
||||
HomeFiles = rebar_utils:find_files_by_ext(HomeTemplates, ".template"),
|
||||
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].
|
||||
|
||||
find_other_templates(Config) ->
|
||||
|
@ -254,7 +253,7 @@ find_other_templates(Config) ->
|
|||
undefined ->
|
||||
[];
|
||||
TemplateDir ->
|
||||
rebar_utils:find_files(TemplateDir, ?TEMPLATE_RE)
|
||||
rebar_utils:find_files_by_ext(TemplateDir, ".template")
|
||||
end.
|
||||
|
||||
select_template([], Template) ->
|
||||
|
|
Loading…
Reference in a new issue