From 572587f5cef0741cf68d5842d503ddb764e3d47b Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sat, 9 May 2015 16:17:20 +0300 Subject: [PATCH] Fix cross compilation tests. --- cross/ubuntu-mingw.txt | 10 +++++----- interpreter.py | 8 ++++++-- meson_test.py | 5 ++++- mparser.py | 2 +- run_cross_test.py | 6 ++++-- test cases/common/59 object generator/meson.build | 5 +++-- .../common/59 object generator/obj_generator.py | 15 ++++++++------- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/cross/ubuntu-mingw.txt b/cross/ubuntu-mingw.txt index 66b279f22658..7e848ac876ca 100644 --- a/cross/ubuntu-mingw.txt +++ b/cross/ubuntu-mingw.txt @@ -1,8 +1,8 @@ name = 'windows' exe_wrapper = 'wine' # A command used to run generated executables. -c = '/usr/bin/i586-mingw32msvc-gcc' -cpp = '/usr/bin/i586-mingw32msvc-g++' -ar = '/usr/i586-mingw32msvc/bin/ar' -strip = '/usr/i586-mingw32msvc/bin/strip' +c = '/usr/bin/i686-w64-mingw32-gcc' +cpp = '/usr/bin/i686-w64-mingw32-gcc' +ar = '/usr/bin/i686-w64-mingw32-ar' +strip = '/usr/bin/i686-w64-mingw32-strip' -root = '/usr/i586-mingw32msvc' +root = '/usr/i686-w64-mingw32' diff --git a/interpreter.py b/interpreter.py index 4297633edd48..8c165184acfd 100644 --- a/interpreter.py +++ b/interpreter.py @@ -503,12 +503,16 @@ def __init__(self, compiler, env): 'has_function' : self.has_function_method, 'has_member' : self.has_member_method, 'alignment' : self.alignment_method, - 'version' : self.version_method + 'version' : self.version_method, + 'cmd_array' : self.cmd_array_method, }) def version_method(self, args, kwargs): return self.compiler.version + def cmd_array_method(self, args, kwargs): + return self.compiler.exelist + def alignment_method(self, args, kwargs): if len(args) != 1: raise InterpreterException('Alignment method takes exactly one positional argument.') @@ -1682,7 +1686,7 @@ def array_method_call(self, obj, method_name, args): index = args[0] if not isinstance(index, int): raise InvalidArguments('Array index must be a number.') - if index < 0 or index >= len(obj): + if index < -len(obj) or index >= len(obj): raise InvalidArguments('Array index %s is out of bounds for array of size %d.' % (index, len(obj))) return obj[index] raise InterpreterException('Arrays do not have a method called "%s".' % method_name) diff --git a/meson_test.py b/meson_test.py index d4a5b6251529..2807ddeace4c 100755 --- a/meson_test.py +++ b/meson_test.py @@ -41,7 +41,10 @@ def __init__(self, res, returncode, duration, stdo, stde, cmd): def write_log(logfile, test_name, result_str, result): logfile.write(result_str + '\n\n') logfile.write('--- command ---\n') - logfile.write(' '.join(result.cmd)) + if result.cmd is None: + logfile.write('NONE') + else: + logfile.write(' '.join(result.cmd)) logfile.write('\n--- "%s" stdout ---\n' % test_name) logfile.write(result.stdo) logfile.write('\n--- "%s" stderr ---\n' % test_name) diff --git a/mparser.py b/mparser.py index b7fb5195b122..e8f20a5dc671 100644 --- a/mparser.py +++ b/mparser.py @@ -41,7 +41,7 @@ def __init__(self): # Need to be sorted longest to shortest. ('ignore', re.compile(r'[ \t]')), ('id', re.compile('[_a-zA-Z][_0-9a-zA-Z]*')), - ('number', re.compile(r'\d+')), + ('number', re.compile(r'-?\d+')), ('eol_cont', re.compile(r'\\\n')), ('eol', re.compile(r'\n')), ('multiline_string', re.compile(r"'''(.|\n)*?'''", re.M)), diff --git a/run_cross_test.py b/run_cross_test.py index 60263369c85f..7355c2830785 100755 --- a/run_cross_test.py +++ b/run_cross_test.py @@ -45,7 +45,7 @@ def run_test(testdir, should_succeed=True): os.mkdir(test_build_dir) os.mkdir(install_dir) print('Running test: ' + testdir) - gen_command = [sys.executable, meson_command, '--prefix', install_dir, '--libdir', 'lib', testdir, test_build_dir] + extra_flags + gen_command = [sys.executable, meson_command, '--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir] + extra_flags p = subprocess.Popen(gen_command) p.wait() if not should_succeed: @@ -62,7 +62,9 @@ def run_test(testdir, should_succeed=True): pt.wait() if pt.returncode != 0: raise RuntimeError('Running unit tests failed.') - pi = subprocess.Popen(install_commands, cwd=test_build_dir) + install_env = os.environ.copy() + install_env['DESTDIR'] = install_dir + pi = subprocess.Popen(install_commands, cwd=test_build_dir, env=install_env) pi.wait() if pi.returncode != 0: raise RuntimeError('Running install failed.') diff --git a/test cases/common/59 object generator/meson.build b/test cases/common/59 object generator/meson.build index 04d7d8b084f5..d2c8afb6c11c 100644 --- a/test cases/common/59 object generator/meson.build +++ b/test cases/common/59 object generator/meson.build @@ -12,10 +12,11 @@ else outputname = '@BASENAME@.o' endif -# Generate a header file that needs to be included. +cc = meson.get_compiler('c').cmd_array().get(0-1) +# Generate an object file manually. gen = generator(python, output : outputname, - arguments : [comp, '@INPUT@', '@OUTPUT@']) + arguments : [comp, cc, '@INPUT@', '@OUTPUT@']) generated = gen.process('source.c') diff --git a/test cases/common/59 object generator/obj_generator.py b/test cases/common/59 object generator/obj_generator.py index f64484342968..6f98f3986d8a 100755 --- a/test cases/common/59 object generator/obj_generator.py +++ b/test cases/common/59 object generator/obj_generator.py @@ -5,14 +5,15 @@ import sys, shutil, subprocess if __name__ == '__main__': - if len(sys.argv) != 3: - print(sys.argv[0], 'input_file output_file') + if len(sys.argv) != 4: + print(sys.argv[0], 'compiler input_file output_file') sys.exit(1) - ifile = sys.argv[1] - ofile = sys.argv[2] - if shutil.which('cl'): - cmd = ['cl', '/nologo', '/Fo'+ofile, '/c', ifile] + compiler = sys.argv[1] + ifile = sys.argv[2] + ofile = sys.argv[3] + if compiler.endswith('cl'): + cmd = [compiler, '/nologo', '/Fo'+ofile, '/c', ifile] else: - cmd = ['cc', '-c', ifile, '-o', ofile] + cmd = [compiler, '-c', ifile, '-o', ofile] sys.exit(subprocess.call(cmd))