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"}, {"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
{"darwin", "DRV_LDFLAGS", {"darwin", "DRV_LDFLAGS",
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"}, "-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
{"ERLANG_ARCH", {"ERLANG_ARCH", rebar_utils: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_TARGET", rebar_utils:get_arch()}, {"ERLANG_TARGET", rebar_utils:get_arch()},
%% Solaris specific flags %% Solaris specific flags

View file

@ -29,6 +29,7 @@
-export([get_cwd/0, -export([get_cwd/0,
is_arch/1, is_arch/1,
get_arch/0, get_arch/0,
wordsize/0,
sh/2, sh/2,
find_files/2, find_files/2,
now_str/0, now_str/0,
@ -62,16 +63,19 @@ is_arch(ArchRegex) ->
end. end.
get_arch() -> get_arch() ->
Words = try erlang:system_info({wordsize, external}) of Words = wordsize(),
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(otp_release) ++ "-"
++ erlang:system_info(system_architecture) ++ "-" ++ Words. ++ 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.
%% %%
%% Options = [Option] -- defaults to [use_stdout, abort_on_error] %% Options = [Option] -- defaults to [use_stdout, abort_on_error]
%% Option = ErrorOption | OutputOption | {cd, string()} | {env, Env} %% Option = ErrorOption | OutputOption | {cd, string()} | {env, Env}