aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server/src/ts_install.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2015-03-18 11:08:28 +0100
committerPeter Andersson <[email protected]>2015-03-18 11:08:28 +0100
commitae42a30d17367c0c52a057230c18179dcda539bb (patch)
treebc00ad3e859b8c48810ba7f5b156565e79c89a0d /lib/test_server/src/ts_install.erl
parentccf75f6d855b02e2241223c65ee924562686ac49 (diff)
parentfcd42a374f5bee6693737a3ff7276b6694a930f2 (diff)
downloadotp-ae42a30d17367c0c52a057230c18179dcda539bb.tar.gz
otp-ae42a30d17367c0c52a057230c18179dcda539bb.tar.bz2
otp-ae42a30d17367c0c52a057230c18179dcda539bb.zip
Merge remote-tracking branch 'origin/peppe/fix_xcomp' into maint
* origin/peppe/fix_xcomp: Modify the xcomp file for ARM and enable more flags Fix problem with variables not getting assigned during installation OTP-11441
Diffstat (limited to 'lib/test_server/src/ts_install.erl')
-rw-r--r--lib/test_server/src/ts_install.erl53
1 files changed, 50 insertions, 3 deletions
diff --git a/lib/test_server/src/ts_install.erl b/lib/test_server/src/ts_install.erl
index bc62015ac3..594e619fbc 100644
--- a/lib/test_server/src/ts_install.erl
+++ b/lib/test_server/src/ts_install.erl
@@ -18,7 +18,6 @@
%%
-module(ts_install).
-
-export([install/2, platform_id/1]).
-include("ts.hrl").
@@ -135,15 +134,63 @@ unix_autoconf(XConf) ->
case filelib:is_file(Configure) of
true ->
OSXEnv = macosx_cflags(),
+ UnQuotedEnv = assign_vars(unquote(Env++OSXEnv)),
io:format("Running ~s~nEnv: ~p~n",
- [lists:flatten(Configure ++ Args),Env++OSXEnv]),
+ [lists:flatten(Configure ++ Args),UnQuotedEnv]),
Port = open_port({spawn, lists:flatten(["\"",Configure,"\"",Args])},
- [stream, eof, {env,Env++OSXEnv}]),
+ [stream, eof, {env,UnQuotedEnv}]),
ts_lib:print_data(Port);
false ->
{error, no_configure_script}
end.
+unquote([{Var,Val}|T]) ->
+ [{Var,unquote(Val)}|unquote(T)];
+unquote([]) ->
+ [];
+unquote("\""++Rest) ->
+ lists:reverse(tl(lists:reverse(Rest)));
+unquote(String) ->
+ String.
+
+assign_vars([]) ->
+ [];
+assign_vars([{VAR,FlagsStr} | VARs]) ->
+ [{VAR,assign_vars(FlagsStr)} | assign_vars(VARs)];
+assign_vars(FlagsStr) ->
+ Flags = [assign_all_vars(Str,[]) || Str <- string:tokens(FlagsStr, [$ ])],
+ string:strip(lists:flatten(lists:map(fun(Flag) ->
+ Flag ++ " "
+ end, Flags)), right).
+
+assign_all_vars([$$ | Rest], FlagSoFar) ->
+ {VarName,Rest1} = get_var_name(Rest, []),
+ assign_all_vars(Rest1, FlagSoFar ++ assign_var(VarName));
+assign_all_vars([Char | Rest], FlagSoFar) ->
+ assign_all_vars(Rest, FlagSoFar ++ [Char]);
+assign_all_vars([], Flag) ->
+ Flag.
+
+get_var_name([Ch | Rest] = Str, VarR) ->
+ case valid_char(Ch) of
+ true -> get_var_name(Rest, [Ch | VarR]);
+ false -> {lists:reverse(VarR),Str}
+ end;
+get_var_name([], VarR) ->
+ {lists:reverse(VarR),[]}.
+
+assign_var(VarName) ->
+ case os:getenv(VarName) of
+ false -> "";
+ Val -> Val
+ end.
+
+valid_char(Ch) when Ch >= $a, Ch =< $z -> true;
+valid_char(Ch) when Ch >= $A, Ch =< $Z -> true;
+valid_char(Ch) when Ch >= $0, Ch =< $9 -> true;
+valid_char($_) -> true;
+valid_char(_) -> false.
+
get_xcomp_flag(Flag, Flags) ->
get_xcomp_flag(Flag, Flag, Flags).
get_xcomp_flag(Flag, Tag, Flags) ->