summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Gumm <sigmastar@gmail.com>2011-12-08 20:03:18 +0100
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-12-08 20:12:16 +0100
commit9f31ceae00c579b48df95600d495369ac20600d3 (patch)
treee98ffd24b1acbf31d1bf0328a6fbc79e140270c7
parent8f4e80b8273ff285c974396641fc6c998121c21e (diff)
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.
-rw-r--r--src/rebar_port_compiler.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 1b46112..4d03a97 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -392,6 +392,14 @@ os_env() ->
%% Drop variables without a name (win32)
[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() ->
[
{"CXX_TEMPLATE",
@@ -402,13 +410,13 @@ default_env() ->
"$CC $PORT_IN_FILES $LDFLAGS $DRV_LDFLAGS -o $PORT_OUT_FILE"},
{"CC", "cc"},
{"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"),
" "])},
{"ERL_LDFLAGS", " -L$ERL_EI_LIBDIR -lerl_interface -lei"},
{"DRV_CFLAGS", "-g -Wall -fPIC $ERL_CFLAGS"},
{"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
- {"ERL_EI_LIBDIR", code:lib_dir(erl_interface, lib)},
+ {"ERL_EI_LIBDIR", erl_interface_dir(lib)},
{"darwin", "DRV_LDFLAGS",
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
{"ERLANG_ARCH", rebar_utils:wordsize()},