From e9b58f2775704226b514e967097e902a232081f3 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 22 Nov 2014 19:36:49 -0600 Subject: set REBAR_DEPS_DIR in hooks env and run pre_compile hooks before deps compile --- src/rebar_hooks.erl | 5 +++-- src/rebar_prv_compile.erl | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl index 2599d8e..3e6d533 100644 --- a/src/rebar_hooks.erl +++ b/src/rebar_hooks.erl @@ -4,10 +4,11 @@ run_compile_hooks(Dir, Type, Command, State) -> Hooks = rebar_state:get(State, Type, []), + Env = [{"REBAR_DEPS_DIR", rebar_prv_install_deps:get_deps_dir(State)}], lists:foreach(fun({_, C, _}=Hook) when C =:= Command -> - apply_hook(Dir, [], Hook); + apply_hook(Dir, Env, Hook); ({C, _}=Hook) when C =:= Command -> - apply_hook(Dir, [], Hook); + apply_hook(Dir, Env, Hook); (_) -> continue end, Hooks). diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index b53742d..893fd76 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -43,6 +43,8 @@ do(State) -> ProjectApps = rebar_state:project_apps(State1), Deps = rebar_state:get(State1, deps_to_build, []), + Cwd = rebar_utils:get_cwd(), + rebar_hooks:run_compile_hooks(Cwd, pre_hooks, compile, State1), %% Need to allow global config vars used on deps %% Right now no way to differeniate and just give deps a new state @@ -51,8 +53,6 @@ do(State) -> build_apps(EmptyState1, Deps), %% Use the project State for building project apps - Cwd = rebar_utils:get_cwd(), - rebar_hooks:run_compile_hooks(Cwd, pre_hooks, compile, State1), %% Set hooks to empty so top-level hooks aren't run for each project app State2 = rebar_state:set(rebar_state:set(State1, post_hooks, []), pre_hooks, []), build_apps(State2, ProjectApps), -- cgit v1.1