Skip to content

Commit 3eb1725

Browse files
committed
Try to use cross toolchain on linux when needed
Getting /usr/i686-linux-gnu/lib in LD_LIBRARY_PATH when cross i6868 Signed-off-by: Yonggang Luo <[email protected]>
1 parent dc0add5 commit 3eb1725

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

tools/build.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import re
2828
import os
2929

30+
from distutils import spawn
31+
3032
from common_py import path
3133
from common_py.system.filesystem import FileSystem as fs
3234
from common_py.system.executor import Executor as ex
@@ -411,12 +413,24 @@ def run_checktest(options):
411413
args.append('--quiet')
412414

413415
fs.chdir(path.PROJECT_ROOT)
414-
code = ex.run_cmd(cmd, args)
416+
env = os.environ.copy()
417+
if (options.target_tuple == 'i686-linux') and \
418+
(options.host_tuple != options.target_tuple):
419+
old = env.get("LD_LIBRARY_PATH")
420+
if old:
421+
env["LD_LIBRARY_PATH"] = old + ":/usr/i686-linux-gnu/lib"
422+
else:
423+
env["LD_LIBRARY_PATH"] = "/usr/i686-linux-gnu/lib"
424+
if spawn.find_executable('i686-linux-gnu-gcc'):
425+
env['CC'] = 'i686-linux-gnu-gcc'
426+
env['CXX'] = 'i686-linux-gnu-g++'
427+
428+
code = ex.run_cmd(cmd, args, env=env)
415429
if code != 0:
416430
ex.fail('Failed to pass unit tests')
417431

418432
if not options.no_check_valgrind:
419-
code = ex.run_cmd(cmd, ['--valgrind'] + args)
433+
code = ex.run_cmd(cmd, ['--valgrind'] + args, env=env)
420434
if code != 0:
421435
ex.fail('Failed to pass unit tests in valgrind environment')
422436

tools/common_py/system/executor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ def fail(msg):
6060
exit(1)
6161

6262
@staticmethod
63-
def run_cmd(cmd, args=[], quiet=False, cwd=None):
63+
def run_cmd(cmd, args=[], quiet=False, cwd=None, env=None):
6464
if not quiet:
6565
Executor.print_cmd_line(cmd, args)
6666
try:
67-
return subprocess.call([cmd] + args, cwd=cwd)
67+
return subprocess.call([cmd] + args, cwd=cwd, env=env)
6868
except OSError as e:
6969
Executor.fail("[Failed - %s] %s" % (cmd, e.strerror))
7070

tools/testrunner.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def __init__(self, options):
158158
# Process the iotjs build information.
159159
iotjs_output = Executor.check_run_cmd_output(self.iotjs,
160160
[path.BUILD_INFO_PATH])
161+
print("IoT.js build info:" + iotjs_output.decode('utf8', 'ignore'))
161162
build_info = json.loads(iotjs_output)
162163

163164
self.builtins = set(build_info["builtins"])
@@ -180,7 +181,13 @@ def build_napi_test_module(self):
180181
cmd = ['--debug'] if self.debug else ['--release']
181182
if self.platform == 'windows':
182183
node_gyp += '.cmd'
183-
cmd.append('--arch=x64' if self.arch == 'x64' else '--arch=ia32')
184+
if self.arch == 'x64':
185+
cmd.append('--arch=x64')
186+
elif self.arch == 'ia32':
187+
cmd.append('--arch=ia32')
188+
elif self.arch:
189+
raise Exception(self.arch + " not supported")
190+
184191
Executor.check_run_cmd(node_gyp, ['rebuild'] + cmd,
185192
cwd=project_root)
186193

0 commit comments

Comments
 (0)