mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Adding support for subdirs
This commit is contained in:
parent
d885b1c04c
commit
3765b86653
1 changed files with 23 additions and 2 deletions
|
@ -162,7 +162,7 @@ apply_commands(Targets, [CommandStr | Rest]) ->
|
||||||
%% Filter out all the targets, based on the specified command.
|
%% Filter out all the targets, based on the specified command.
|
||||||
FilteredTargets = [{Type, Dir, Filename} || {Type, Dir, Filename} <- Targets,
|
FilteredTargets = [{Type, Dir, Filename} || {Type, Dir, Filename} <- Targets,
|
||||||
valid_command(Command, Type) == true],
|
valid_command(Command, Type) == true],
|
||||||
case apply_command(FilteredTargets, Command) of
|
case catch(apply_command(FilteredTargets, Command)) of
|
||||||
ok ->
|
ok ->
|
||||||
apply_commands(Targets, Rest);
|
apply_commands(Targets, Rest);
|
||||||
Other ->
|
Other ->
|
||||||
|
@ -175,6 +175,20 @@ apply_command([{Type, Dir, File} | Rest], Command) ->
|
||||||
ok = file:set_cwd(Dir),
|
ok = file:set_cwd(Dir),
|
||||||
Config = rebar_config:new(Dir),
|
Config = rebar_config:new(Dir),
|
||||||
|
|
||||||
|
%% Look for subdirs configuration list -- if it exists, we're going to process those first
|
||||||
|
case subdirs(rebar_config:get_list(Config, subdirs, []), []) of
|
||||||
|
[] ->
|
||||||
|
ok;
|
||||||
|
Subdirs ->
|
||||||
|
update_code_path(Subdirs),
|
||||||
|
case apply_command(Subdirs, Command) of
|
||||||
|
ok ->
|
||||||
|
ok = file:set_cwd(Dir);
|
||||||
|
error ->
|
||||||
|
?FAIL
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
%% Provide some info on where we are
|
%% Provide some info on where we are
|
||||||
?CONSOLE("==> ~s (~s)\n", [filename:basename(Dir), Command]),
|
?CONSOLE("==> ~s (~s)\n", [filename:basename(Dir), Command]),
|
||||||
|
|
||||||
|
@ -185,9 +199,16 @@ apply_command([{Type, Dir, File} | Rest], Command) ->
|
||||||
ok ->
|
ok ->
|
||||||
apply_command(Rest, Command);
|
apply_command(Rest, Command);
|
||||||
Other ->
|
Other ->
|
||||||
?ERROR("~p failed while processing ~s: ~p", [Command, Dir, Other])
|
?ERROR("~p failed while processing ~s: ~p", [Command, Dir, Other]),
|
||||||
|
error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
subdirs([], Acc) ->
|
||||||
|
Acc;
|
||||||
|
subdirs([Dir | Rest], Acc) ->
|
||||||
|
Subdir = filename:join([rebar_utils:get_cwd(), Dir]),
|
||||||
|
subdirs(Rest, Acc ++ find_targets(Subdir)).
|
||||||
|
|
||||||
|
|
||||||
run_modules([], _Command, _Config, _File) ->
|
run_modules([], _Command, _Config, _File) ->
|
||||||
ok;
|
ok;
|
||||||
|
|
Loading…
Reference in a new issue