From b787f195b859e322c04b6a8355f465ebcc2266cb Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 10 Feb 2010 11:08:56 -0700 Subject: [PATCH 1/7] Add vim line; courtesy of rtilder --- bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap b/bootstrap index 5f57d2c..7eefd2e 100755 --- a/bootstrap +++ b/bootstrap @@ -1,4 +1,5 @@ #!/usr/bin/env escript +%% vim: syntax=erlang:et:ts=4 %% -*- erlang -*- main(Args) -> From 268405d0dc49d6a0a2d0ea41014b045b3ff26eb0 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 10 Feb 2010 11:15:55 -0700 Subject: [PATCH 2/7] Adding new vars for scripts to determine architecture (32/64 bit) and target platform of Erlang VM; courtesy of rtilder --- src/rebar_port_compiler.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index a347cb7..2f419c9 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -253,7 +253,9 @@ default_env() -> " -I", filename:join(erts_dir(), include), " "])}, {"DRIVER_LDFLAGS", lists:concat([" -L", code:lib_dir(erl_interface, lib), - " -lerl_interface -lei"])}]. + " -lerl_interface -lei"])}, + {"ERLANG_ARCH", 8 * erlang:system_info(wordsize)}, + {"ERLANG_TARGET", erlang:system_info(system_architecture)}]. From f502bb09dd041cdc8a524e82c482e820c169fa65 Mon Sep 17 00:00:00 2001 From: Ryan Tilder Date: Wed, 10 Feb 2010 11:23:53 -0800 Subject: [PATCH 3/7] I'm a moron. Make it a string. --- src/rebar_port_compiler.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index 2f419c9..3cc8fc1 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -254,7 +254,7 @@ default_env() -> " "])}, {"DRIVER_LDFLAGS", lists:concat([" -L", code:lib_dir(erl_interface, lib), " -lerl_interface -lei"])}, - {"ERLANG_ARCH", 8 * erlang:system_info(wordsize)}, + {"ERLANG_ARCH", integer_to_list(8 * erlang:system_info(wordsize))}, {"ERLANG_TARGET", erlang:system_info(system_architecture)}]. From 22d21f63d02cc9ce1e6a94754045ad9e78900267 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Wed, 10 Feb 2010 14:05:52 -0700 Subject: [PATCH 4/7] Append wordsize to the architecture string --- src/rebar_utils.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 7265058..1aff1a4 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -48,7 +48,8 @@ get_cwd() -> is_arch(ArchRegex) -> - Arch = erlang:system_info(system_architecture), + Words = integer_to_list(8 * erlang:system_info(wordsize)), + Arch = erlang:system_info(system_architecture) ++ "-" ++ Words, case re:run(Arch, ArchRegex, [{capture, none}]) of match -> true; From fa4b2ee701e13f445d00791dbf70934f966af5fd Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 11 Feb 2010 00:16:34 +0100 Subject: [PATCH 5/7] Add emacs and vim file local variables --- bootstrap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap b/bootstrap index 7eefd2e..9916324 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #!/usr/bin/env escript -%% vim: syntax=erlang:et:ts=4 -%% -*- erlang -*- +%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ft=erlang ts=4 sw=4 et main(Args) -> %% Get a string repr of build time From a0732e9e78ea543178b9f29aaf8fa6e72011506e Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 12 Feb 2010 11:57:50 -0700 Subject: [PATCH 6/7] Make sure to cover all edge cases when parsing module names --- src/rebar_erlc_compiler.erl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 51b7f17..c41b96d 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -106,13 +106,20 @@ inspect(Source, IncludePath) -> -spec inspect_epp(Epp::pid(), Module::string(), Includes::[string()]) -> {string(), [string()]}. inspect_epp(Epp, Module, Includes) -> case epp:parse_erl_form(Epp) of - {ok, {attribute, _, module, ActualModule}} -> - %% If the module name includes package info, we get a list of atoms... - case is_list(ActualModule) of - true -> + {ok, {attribute, _, module, ModInfo}} -> + case ModInfo of + %% Typical module name, single atom + ActualModule when is_atom(ActualModule) -> + ActualModuleStr = atom_to_list(ActualModule); + %% Packag-ized module name, list of atoms + ActualModule when is_list(ActualModule) -> ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], "."); - false -> - ActualModuleStr = atom_to_list(ActualModule) + %% Parameterized module name, single atom + {ActualModule, _} when is_atom(ActualModule) -> + ActualModuleStr = atom_to_list(ActualModule); + %% Parameterized and packagized module name, list of atoms + {ActualModule, _} when is_list(ActualModule) -> + ActualModuleStr = string:join([atom_to_list(P) || P <- ActualModule], ".") end, inspect_epp(Epp, ActualModuleStr, Includes); {ok, {attribute, 1, file, {Module, 1}}} -> From 96c1ceba6007551812add22d585f46256d78e106 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 12 Feb 2010 15:05:32 -0700 Subject: [PATCH 7/7] Break out arch string function; update ERLANG_TARGET to include bitness of the Erlang target --- src/rebar_port_compiler.erl | 2 +- src/rebar_utils.erl | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index 3cc8fc1..b08a046 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -255,7 +255,7 @@ default_env() -> {"DRIVER_LDFLAGS", lists:concat([" -L", code:lib_dir(erl_interface, lib), " -lerl_interface -lei"])}, {"ERLANG_ARCH", integer_to_list(8 * erlang:system_info(wordsize))}, - {"ERLANG_TARGET", erlang:system_info(system_architecture)}]. + {"ERLANG_TARGET", rebar_utils:get_arch()}]. diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 1aff1a4..1e99caa 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -28,6 +28,7 @@ -export([get_cwd/0, is_arch/1, + get_arch/0, get_os/0, sh/2, sh/3, sh_failfast/2, @@ -48,15 +49,17 @@ get_cwd() -> is_arch(ArchRegex) -> - Words = integer_to_list(8 * erlang:system_info(wordsize)), - Arch = erlang:system_info(system_architecture) ++ "-" ++ Words, - case re:run(Arch, ArchRegex, [{capture, none}]) of + case re:run(get_arch(), ArchRegex, [{capture, none}]) of match -> true; nomatch -> false end. +get_arch() -> + Words = integer_to_list(8 * erlang:system_info(wordsize)), + erlang:system_info(system_architecture) ++ "-" ++ Words. + get_os() -> Arch = erlang:system_info(system_architecture), case match_first([{"linux", linux}, {"darwin", darwin}], Arch) of