From 9f31ceae00c579b48df95600d495369ac20600d3 Mon Sep 17 00:00:00 2001 From: Jesse Gumm Date: Thu, 8 Dec 2011 20:03:18 +0100 Subject: 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. --- src/rebar_port_compiler.erl | 12 ++++++++++-- 1 file 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()}, -- cgit v1.1