Extract code to get wordsize into helper function

This commit is contained in:
Tuncer Ayaz 2011-05-31 10:52:23 +02:00
parent 0bbb2985f0
commit 70137292e1
2 changed files with 12 additions and 15 deletions

View file

@ -398,14 +398,7 @@ default_env() ->
{"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
{"darwin", "DRV_LDFLAGS",
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
{"ERLANG_ARCH",
try erlang:system_info({wordsize, external}) of
Val ->
integer_to_list(8 * Val)
catch
error:badarg ->
integer_to_list(8 * erlang:system_info(wordsize))
end},
{"ERLANG_ARCH", rebar_utils:wordsize()},
{"ERLANG_TARGET", rebar_utils:get_arch()},
%% Solaris specific flags

View file

@ -29,6 +29,7 @@
-export([get_cwd/0,
is_arch/1,
get_arch/0,
wordsize/0,
sh/2,
find_files/2,
now_str/0,
@ -62,15 +63,18 @@ is_arch(ArchRegex) ->
end.
get_arch() ->
Words = try erlang:system_info({wordsize, external}) of
Words = wordsize(),
erlang:system_info(otp_release) ++ "-"
++ erlang:system_info(system_architecture) ++ "-" ++ Words.
wordsize() ->
try erlang:system_info({wordsize, external}) of
Val ->
integer_to_list(8 * Val)
catch
error:badarg ->
integer_to_list(8 * erlang:system_info(wordsize))
end,
erlang:system_info(otp_release) ++ "-"
++ erlang:system_info(system_architecture) ++ "-" ++ Words.
end.
%%
%% Options = [Option] -- defaults to [use_stdout, abort_on_error]