summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorUri Simchoni <urisimchoni@gmail.com>2015-05-18 21:15:19 +0300
committerAndrew Bartlett <abartlet@samba.org>2015-05-20 11:19:11 +0200
commiteb696df4936bc48bb8fa7077bb5b45e5e2e6cb01 (patch)
tree2fff812a613522d9d437a51f214cfd1ea20e2ee5 /buildtools
parent3fb617310df73795fbb761253f27052ae5afa40b (diff)
downloadsamba-eb696df4936bc48bb8fa7077bb5b45e5e2e6cb01.tar.gz
Adds a new mode to samba cross-compiling.
When both --cross-answers and --cross-execute are set, this means: - Use cross-answers - If answer is unknown, then instead of adding UNKNOWN to the cross-answers file and failing configure, the new mode runs cross-execute to determine the answer and adds that to the cross-answers file. Signed-off-by: Uri Simchoni <urisimchoni@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_cross.py46
1 files changed, 34 insertions, 12 deletions
diff --git a/buildtools/wafsamba/samba_cross.py b/buildtools/wafsamba/samba_cross.py
index b48155336d8..9ca2f8d4610 100644
--- a/buildtools/wafsamba/samba_cross.py
+++ b/buildtools/wafsamba/samba_cross.py
@@ -45,7 +45,6 @@ def cross_answer(ca_file, msg):
try:
f = open(ca_file, 'r')
except:
- add_answer(ca_file, msg, ANSWER_UNKNOWN)
return ANSWER_UNKNOWN
for line in f:
line = line.strip()
@@ -80,7 +79,6 @@ def cross_answer(ca_file, msg):
else:
raise Utils.WafError("Bad answer format '%s' in %s" % (line, ca_file))
f.close()
- add_answer(ca_file, msg, ANSWER_UNKNOWN)
return ANSWER_UNKNOWN
@@ -88,24 +86,47 @@ class cross_Popen(Utils.pproc.Popen):
'''cross-compilation wrapper for Popen'''
def __init__(*k, **kw):
(obj, args) = k
-
- if '--cross-execute' in args:
- # when --cross-execute is set, then change the arguments
- # to use the cross emulator
- i = args.index('--cross-execute')
- newargs = args[i+1].split()
- newargs.extend(args[0:i])
- args = newargs
- elif '--cross-answers' in args:
+ use_answers = False
+ ans = ANSWER_UNKNOWN
+
+ # Three possibilities:
+ # 1. Only cross-answers - try the cross-answers file, and if
+ # there's no corresponding answer, add to the file and mark
+ # the configure process as unfinished.
+ # 2. Only cross-execute - get the answer from cross-execute
+ # 3. Both - try the cross-answers file, and if there is no
+ # corresponding answer - use cross-execute to get an answer,
+ # and add that answer to the file.
+ if '--cross-answers' in args:
# when --cross-answers is set, then change the arguments
# to use the cross answers if available
+ use_answers = True
i = args.index('--cross-answers')
ca_file = args[i+1]
msg = args[i+2]
ans = cross_answer(ca_file, msg)
+
+ if '--cross-execute' in args and ans == ANSWER_UNKNOWN:
+ # when --cross-execute is set, then change the arguments
+ # to use the cross emulator
+ i = args.index('--cross-execute')
+ newargs = args[i+1].split()
+ newargs.extend(args[0:i])
+ if use_answers:
+ p = real_Popen(newargs,
+ stdout=Utils.pproc.PIPE,
+ stderr=Utils.pproc.PIPE)
+ ce_out, ce_err = p.communicate()
+ ans = (p.returncode, ce_out)
+ add_answer(ca_file, msg, ans)
+ else:
+ args = newargs
+
+ if use_answers:
if ans == ANSWER_UNKNOWN:
global cross_answers_incomplete
cross_answers_incomplete = True
+ add_answer(ca_file, msg, ans)
(retcode, retstring) = ans
args = ['/bin/sh', '-c', "echo -n '%s'; exit %d" % (retstring, retcode)]
real_Popen.__init__(*(obj, args), **kw)
@@ -126,7 +147,8 @@ def SAMBA_CROSS_ARGS(conf, msg=None):
if conf.env.CROSS_EXECUTE:
ret.extend(['--cross-execute', conf.env.CROSS_EXECUTE])
- elif conf.env.CROSS_ANSWERS:
+
+ if conf.env.CROSS_ANSWERS:
if msg is None:
raise Utils.WafError("Cannot have NULL msg in cross-answers")
ret.extend(['--cross-answers', os.path.join(Options.launch_dir, conf.env.CROSS_ANSWERS), msg])