From 4b8463ff43f8983a706b181c5292491f9f954be1 Mon Sep 17 00:00:00 2001
From: Changqing Li <changqing.li@windriver.com>
Date: Fri, 25 Jan 2019 15:00:59 +0800
Subject: [PATCH] waf: add support of cross_compile

After upgrade, waf also upgraded

on 1.5.19, for cross_compile, subprocess.Popen is set to be
samba_cross.cross_Popen, which will not execute testprog on
host, but only read result from cross-answers.txt which is
passed by option --cross-answer

part of old code:
    args = Utils.to_list(kw.get('exec_args', []))
    proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE)

but on new version, exec_args is not used and cause do_configure
failed with Exec format error

fixed by append cross anser related args to cmd

Upstream-Status: Submitted [https://gitlab.com/samba-team/samba/merge_requests/211]

Signed-off-by: Changqing Li <changqing.li@windriver.com>
---
 third_party/waf/waflib/Tools/c_config.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/third_party/waf/waflib/Tools/c_config.py b/third_party/waf/waflib/Tools/c_config.py
index 7608215..767cf33 100644
--- a/third_party/waf/waflib/Tools/c_config.py
+++ b/third_party/waf/waflib/Tools/c_config.py
@@ -660,20 +660,21 @@ class test_exec(Task.Task):
 	"""
 	color = 'PINK'
 	def run(self):
+		args = self.generator.bld.kw.get('exec_args', [])
 		if getattr(self.generator, 'rpath', None):
 			if getattr(self.generator, 'define_ret', False):
-				self.generator.bld.retval = self.generator.bld.cmd_and_log([self.inputs[0].abspath()])
-			else:
-				self.generator.bld.retval = self.generator.bld.exec_command([self.inputs[0].abspath()])
+				self.generator.bld.retval = self.generator.bld.cmd_and_log([self.inputs[0].abspath()] + args)
+			else: 
+				self.generator.bld.retval = self.generator.bld.exec_command([self.inputs[0].abspath()] + args)
 		else:
 			env = self.env.env or {}
 			env.update(dict(os.environ))
 			for var in ('LD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'PATH'):
 				env[var] = self.inputs[0].parent.abspath() + os.path.pathsep + env.get(var, '')
 			if getattr(self.generator, 'define_ret', False):
-				self.generator.bld.retval = self.generator.bld.cmd_and_log([self.inputs[0].abspath()], env=env)
+				self.generator.bld.retval = self.generator.bld.cmd_and_log([self.inputs[0].abspath()] + args, env=env)
 			else:
-				self.generator.bld.retval = self.generator.bld.exec_command([self.inputs[0].abspath()], env=env)
+				self.generator.bld.retval = self.generator.bld.exec_command([self.inputs[0].abspath()] + args, env=env)
 
 @feature('test_exec')
 @after_method('apply_link')
-- 
2.7.4

