Fail if erl_interface not found

Previously if erl_interface could not be found {error, not_found} was
incorrectly used as a path. With this change we fail early with a
descriptive error message.
This commit is contained in:
Jesse Gumm 2011-12-08 20:03:18 +01:00 committed by Tuncer Ayaz
parent 8f4e80b827
commit 9f31ceae00

View file

@ -392,6 +392,14 @@ os_env() ->
%% Drop variables without a name (win32) %% Drop variables without a name (win32)
[T1 || {K, _V} = T1 <- Os, K =/= []]. [T1 || {K, _V} = T1 <- Os, K =/= []].
erl_interface_dir(Subdir) ->
case code:lib_dir(erl_interface, Subdir) of
{error, bad_name} ->
throw({error, {erl_interface,Subdir,"code:lib_dir(erl_interface)"
"is unable to find the erl_interface library."}});
Dir -> Dir
end.
default_env() -> default_env() ->
[ [
{"CXX_TEMPLATE", {"CXX_TEMPLATE",
@ -402,13 +410,13 @@ default_env() ->
"$CC $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS -o $PORT_OUT_FILE"}, "$CC $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS -o $PORT_OUT_FILE"},
{"CC", "cc"}, {"CC", "cc"},
{"CXX", "c++"}, {"CXX", "c++"},
{"ERL_CFLAGS", lists:concat([" -I", code:lib_dir(erl_interface, include), {"ERL_CFLAGS", lists:concat([" -I", erl_interface_dir(include),
" -I", filename:join(erts_dir(), "include"), " -I", filename:join(erts_dir(), "include"),
" "])}, " "])},
{"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lerl_interface -lei"}, {"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lerl_interface -lei"},
{"DRV_CFLAGS", "-g -Wall -fPIC $ERL_CFLAGS"}, {"DRV_CFLAGS", "-g -Wall -fPIC $ERL_CFLAGS"},
{"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"}, {"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
{"ERL_EI_LIBDIR", code:lib_dir(erl_interface, lib)}, {"ERL_EI_LIBDIR", erl_interface_dir(lib)},
{"darwin", "DRV_LDFLAGS", {"darwin", "DRV_LDFLAGS",
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"}, "-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
{"ERLANG_ARCH", rebar_utils:wordsize()}, {"ERLANG_ARCH", rebar_utils:wordsize()},