Skip to content

Commit

Permalink
Add support for arch-specific hooks
Browse files Browse the repository at this point in the history
{pre_hooks,  [{"linux", compile, "c_src/build_linux.sh"}]}.
{post_hooks, [{"linux", compile, "c_src/build_linux.sh clean"}]}.
  • Loading branch information
Tuncer Ayaz committed Dec 5, 2011
1 parent 54259c5 commit 8de2c84
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/rebar_core.erl
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,17 @@ run_modules([Module | Rest], Command, Config, File) ->
apply_hooks(Mode, Config, Command, Env) ->
Hooks = rebar_config:get_local(Config, Mode, []),
lists:foreach(fun apply_hook/1,
[{Env, Hook} || Hook <- Hooks, element(1, Hook) =:= Command]).
[{Env, Hook} || Hook <- Hooks,
element(1, Hook) =:= Command orelse
element(2, Hook) =:= Command]).

apply_hook({Env, {Arch, Command, Hook}}) ->
case rebar_utils:is_arch(Arch) of
true ->
apply_hook({Env, {Command, Hook}});
false ->
ok
end;
apply_hook({Env, {Command, Hook}}) ->
Msg = lists:flatten(io_lib:format("Command [~p] failed!~n", [Command])),
rebar_utils:sh(Hook, [{env, Env}, {abort_on_error, Msg}]).
Expand Down

0 comments on commit 8de2c84

Please sign in to comment.