From 8de2c84d89acab7702825d4fb784d414225902d7 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Sun, 4 Dec 2011 18:29:11 +0100 Subject: [PATCH] Add support for arch-specific hooks {pre_hooks, [{"linux", compile, "c_src/build_linux.sh"}]}. {post_hooks, [{"linux", compile, "c_src/build_linux.sh clean"}]}. --- src/rebar_core.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rebar_core.erl b/src/rebar_core.erl index e457f1f..56f0aca 100644 --- a/src/rebar_core.erl +++ b/src/rebar_core.erl @@ -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}]).