summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Morrow <jared@basho.com>2014-04-11 09:19:01 -0600
committerJared Morrow <jared@basho.com>2014-04-11 09:19:01 -0600
commit75f1383f669e0ce16324e3ada53e805e500bda71 (patch)
tree432eb1f766057a199c581b945e26578cae91e67f
parent0c7fe5fc7b0296a8d18da66234f78fe67ca7f738 (diff)
parent883decce3d8599762fc7267948ceb33acd7a1278 (diff)
downloadrebar-75f1383f669e0ce16324e3ada53e805e500bda71.tar.gz
Merge pull request #254 from tuncer/fix-generate
Fix 'rebar generate' regression (#253)
-rw-r--r--src/rebar_core.erl22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 81b9a6d..f54147f 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -152,14 +152,34 @@ maybe_process_dir(Dir, ParentConfig, Command, DirSet) ->
should_cd_into_dir(Dir, Config, Command) ->
rebar_utils:processing_base_dir(Config, Dir) orelse
rebar_config:is_recursive(Config) orelse
- is_recursive_command(Config, Command).
+ is_recursive_command(Config, Command) orelse
+ is_generate_in_rel_dir(Command, Dir).
+%% Check whether the command is part of the built-in (or extended via
+%% rebar.config) list of default-recursive commands.
is_recursive_command(Config, Command) ->
{ok, AppCmds} = application:get_env(rebar, recursive_cmds),
ConfCmds = rebar_config:get_local(Config, recursive_cmds, []),
RecursiveCmds = AppCmds ++ ConfCmds,
lists:member(Command, RecursiveCmds).
+%% If the directory we're about to process contains
+%% reltool.config[.script] and the command to be applied is
+%% 'generate', then it's safe to process. We do this to retain the
+%% behavior of specifying {sub_dirs, ["rel"]} and have "rebar generate"
+%% pick up rel/reltool.config[.script]. Without this workaround you'd
+%% have to run "rebar -r generate" (which you don't want to do if you
+%% have deps or other sub_dirs) or "cd rel && rebar generate".
+is_generate_in_rel_dir(generate, Dir) ->
+ case rebar_rel_utils:is_rel_dir(Dir) of
+ {true, _} ->
+ true;
+ false ->
+ false
+ end;
+is_generate_in_rel_dir(_, _) ->
+ false.
+
skip_or_process_dir({[], undefined}=ModuleSet, Config, CurrentCodePath,
Dir, Command, DirSet) ->
process_dir1(Dir, Command, DirSet, Config, CurrentCodePath, ModuleSet);