summaryrefslogtreecommitdiff
path: root/src/rebar_env.erl
diff options
context:
space:
mode:
authorfeng19 <feng_19@foxmail.com>2018-06-21 10:24:56 +0800
committerfeng19 <feng_19@foxmail.com>2018-06-21 10:24:56 +0800
commit482718b8bf31024d919aabad1da2e9116411f2aa (patch)
tree1c693d007b98b0fc31a23aac19abbf94096ad9ef /src/rebar_env.erl
parentdc0f8b4d66d12c10ed4df85148b5e8ce13056f40 (diff)
parent38865da7ba01e7d5e60316e970f01959e85759ee (diff)
Merge tag '3.6.0' into refresh_paths
Bump to 3.6.0 - Introduce support of add and del operations for overrides - OTP-21 compatibility - Bump cth_readable for OTP-21 compat - upgrade relx to 3.25.0 - upgrade bbmustache to 1.5.0 - run compile provider in default namespace from bare compiling (fixes hooks for mix builds) - Resolve string vs list crashing rebar3 in erl_first_files - Create ERLANG_LIB_*_erl_interface environment variables only if erl_interface exists - Add hooks to the upgrade command - Add --start-clean flag to rebar3 shell - Auto-boot main app in OTP app project templates - Use maps for child spec examples in templates
Diffstat (limited to 'src/rebar_env.erl')
-rw-r--r--src/rebar_env.erl54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/rebar_env.erl b/src/rebar_env.erl
index eea47de..e9adafb 100644
--- a/src/rebar_env.erl
+++ b/src/rebar_env.erl
@@ -37,26 +37,40 @@ create_env(State) ->
-spec create_env(rebar_state:t(), rebar_dict()) -> proplists:proplist().
create_env(State, Opts) ->
BaseDir = rebar_dir:base_dir(State),
- [
- {"REBAR_DEPS_DIR", filename:absname(rebar_dir:deps_dir(State))},
- {"REBAR_BUILD_DIR", filename:absname(rebar_dir:base_dir(State))},
- {"REBAR_ROOT_DIR", filename:absname(rebar_dir:root_dir(State))},
- {"REBAR_CHECKOUTS_DIR", filename:absname(rebar_dir:checkouts_dir(State))},
- {"REBAR_PLUGINS_DIR", filename:absname(rebar_dir:plugins_dir(State))},
- {"REBAR_GLOBAL_CONFIG_DIR", filename:absname(rebar_dir:global_config_dir(State))},
- {"REBAR_GLOBAL_CACHE_DIR", filename:absname(rebar_dir:global_cache_dir(Opts))},
- {"REBAR_TEMPLATE_DIR", filename:absname(rebar_dir:template_dir(State))},
- {"REBAR_APP_DIRS", join_dirs(BaseDir, rebar_dir:lib_dirs(State))},
- {"REBAR_SRC_DIRS", join_dirs(BaseDir, rebar_dir:all_src_dirs(Opts))},
- {"ERLANG_ERTS_VER", erlang:system_info(version)},
- {"ERLANG_ROOT_DIR", code:root_dir()},
- {"ERLANG_LIB_DIR_erl_interface", code:lib_dir(erl_interface)},
- {"ERLANG_LIB_VER_erl_interface", re_version(code:lib_dir(erl_interface))},
- {"ERL", filename:join([code:root_dir(), "bin", "erl"])},
- {"ERLC", filename:join([code:root_dir(), "bin", "erlc"])},
- {"ERLANG_ARCH" , rebar_api:wordsize()},
- {"ERLANG_TARGET", rebar_api:get_arch()}
- ].
+ EnvVars = [
+ {"REBAR_DEPS_DIR", filename:absname(rebar_dir:deps_dir(State))},
+ {"REBAR_BUILD_DIR", filename:absname(rebar_dir:base_dir(State))},
+ {"REBAR_ROOT_DIR", filename:absname(rebar_dir:root_dir(State))},
+ {"REBAR_CHECKOUTS_DIR", filename:absname(rebar_dir:checkouts_dir(State))},
+ {"REBAR_PLUGINS_DIR", filename:absname(rebar_dir:plugins_dir(State))},
+ {"REBAR_GLOBAL_CONFIG_DIR", filename:absname(rebar_dir:global_config_dir(State))},
+ {"REBAR_GLOBAL_CACHE_DIR", filename:absname(rebar_dir:global_cache_dir(Opts))},
+ {"REBAR_TEMPLATE_DIR", filename:absname(rebar_dir:template_dir(State))},
+ {"REBAR_APP_DIRS", join_dirs(BaseDir, rebar_dir:lib_dirs(State))},
+ {"REBAR_SRC_DIRS", join_dirs(BaseDir, rebar_dir:all_src_dirs(Opts))},
+ {"ERLANG_ERTS_VER", erlang:system_info(version)},
+ {"ERLANG_ROOT_DIR", code:root_dir()},
+ {"ERL", filename:join([code:root_dir(), "bin", "erl"])},
+ {"ERLC", filename:join([code:root_dir(), "bin", "erlc"])},
+ {"ERLANG_ARCH" , rebar_api:wordsize()},
+ {"ERLANG_TARGET", rebar_api:get_arch()}
+ ],
+ EInterfaceVars = create_erl_interface_env(),
+ lists:append([EnvVars, EInterfaceVars]).
+
+-spec create_erl_interface_env() -> list().
+create_erl_interface_env() ->
+ case code:lib_dir(erl_interface) of
+ {error, bad_name} ->
+ ?WARN("erl_interface is missing. ERLANG_LIB_DIR_erl_interface and "
+ "ERLANG_LIB_VER_erl_interface will not be added to the environment.", []),
+ [];
+ Dir ->
+ [
+ {"ERLANG_LIB_DIR_erl_interface", Dir},
+ {"ERLANG_LIB_VER_erl_interface", re_version(Dir)}
+ ]
+ end.
%% ====================================================================
%% Internal functions