From 7b90cc47075bfd35dd757d6db6202adf4a72bbe0 Mon Sep 17 00:00:00 2001 From: Anton Lavrik Date: Sun, 8 May 2011 23:46:44 -0500 Subject: [PATCH] Export $REBAR_DEPS_DIR and $ERL_LIBS variables Export two extra environment variables when executing shell commands. These variables are useful for rebar hooks that rely on Erlang applications installed as rebar dependencies. $REBAR_DEPS_DIR contains a fully-qualified name of the directory where rebar stores dependencies. $ERL_LIBS is set to $REBAR_DEPS_DIR or to "$REBAR_DEPS_DIR:$ERL_LIBS", if $ERL_LIBS was defined before. --- src/rebar_deps.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl index 63f12d5..21313e3 100644 --- a/src/rebar_deps.erl +++ b/src/rebar_deps.erl @@ -31,6 +31,7 @@ -export([preprocess/2, postprocess/2, compile/2, + setup_env/1, 'check-deps'/2, 'get-deps'/2, 'update-deps'/2, @@ -92,6 +93,18 @@ postprocess(_Config, _) -> compile(Config, AppFile) -> 'check-deps'(Config, AppFile). +%% set REBAR_DEPS_DIR and ERL_LIBS environment variables +setup_env(_Config) -> + {true, DepsDir} = get_deps_dir(), + %% include rebar's DepsDir in ERL_LIBS + ERL_LIBS = case os:getenv("ERL_LIBS") of + false -> + {"ERL_LIBS", DepsDir}; + PrevValue -> + {"ERL_LIBS", DepsDir ++ ":" ++ PrevValue} + end, + [{"REBAR_DEPS_DIR", DepsDir}, ERL_LIBS]. + 'check-deps'(Config, _) -> %% Get the list of immediate (i.e. non-transitive) deps that are missing Deps = rebar_config:get_local(Config, deps, []),