Fix cross compilation tests.

pull/68/merge
Jussi Pakkanen 10 years ago
parent 717abc99fb
commit 572587f5ce
  1. 10
      cross/ubuntu-mingw.txt
  2. 8
      interpreter.py
  3. 3
      meson_test.py
  4. 2
      mparser.py
  5. 6
      run_cross_test.py
  6. 5
      test cases/common/59 object generator/meson.build
  7. 15
      test cases/common/59 object generator/obj_generator.py

@ -1,8 +1,8 @@
name = 'windows' name = 'windows'
exe_wrapper = 'wine' # A command used to run generated executables. exe_wrapper = 'wine' # A command used to run generated executables.
c = '/usr/bin/i586-mingw32msvc-gcc' c = '/usr/bin/i686-w64-mingw32-gcc'
cpp = '/usr/bin/i586-mingw32msvc-g++' cpp = '/usr/bin/i686-w64-mingw32-gcc'
ar = '/usr/i586-mingw32msvc/bin/ar' ar = '/usr/bin/i686-w64-mingw32-ar'
strip = '/usr/i586-mingw32msvc/bin/strip' strip = '/usr/bin/i686-w64-mingw32-strip'
root = '/usr/i586-mingw32msvc' root = '/usr/i686-w64-mingw32'

@ -503,12 +503,16 @@ class CompilerHolder(InterpreterObject):
'has_function' : self.has_function_method, 'has_function' : self.has_function_method,
'has_member' : self.has_member_method, 'has_member' : self.has_member_method,
'alignment' : self.alignment_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): def version_method(self, args, kwargs):
return self.compiler.version return self.compiler.version
def cmd_array_method(self, args, kwargs):
return self.compiler.exelist
def alignment_method(self, args, kwargs): def alignment_method(self, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise InterpreterException('Alignment method takes exactly one positional argument.') raise InterpreterException('Alignment method takes exactly one positional argument.')
@ -1682,7 +1686,7 @@ class Interpreter():
index = args[0] index = args[0]
if not isinstance(index, int): if not isinstance(index, int):
raise InvalidArguments('Array index must be a number.') 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))) raise InvalidArguments('Array index %s is out of bounds for array of size %d.' % (index, len(obj)))
return obj[index] return obj[index]
raise InterpreterException('Arrays do not have a method called "%s".' % method_name) raise InterpreterException('Arrays do not have a method called "%s".' % method_name)

@ -41,6 +41,9 @@ class TestRun():
def write_log(logfile, test_name, result_str, result): def write_log(logfile, test_name, result_str, result):
logfile.write(result_str + '\n\n') logfile.write(result_str + '\n\n')
logfile.write('--- command ---\n') logfile.write('--- command ---\n')
if result.cmd is None:
logfile.write('NONE')
else:
logfile.write(' '.join(result.cmd)) logfile.write(' '.join(result.cmd))
logfile.write('\n--- "%s" stdout ---\n' % test_name) logfile.write('\n--- "%s" stdout ---\n' % test_name)
logfile.write(result.stdo) logfile.write(result.stdo)

@ -41,7 +41,7 @@ class Lexer:
# Need to be sorted longest to shortest. # Need to be sorted longest to shortest.
('ignore', re.compile(r'[ \t]')), ('ignore', re.compile(r'[ \t]')),
('id', re.compile('[_a-zA-Z][_0-9a-zA-Z]*')), ('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_cont', re.compile(r'\\\n')),
('eol', re.compile(r'\n')), ('eol', re.compile(r'\n')),
('multiline_string', re.compile(r"'''(.|\n)*?'''", re.M)), ('multiline_string', re.compile(r"'''(.|\n)*?'''", re.M)),

@ -45,7 +45,7 @@ def run_test(testdir, should_succeed=True):
os.mkdir(test_build_dir) os.mkdir(test_build_dir)
os.mkdir(install_dir) os.mkdir(install_dir)
print('Running test: ' + testdir) 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 = subprocess.Popen(gen_command)
p.wait() p.wait()
if not should_succeed: if not should_succeed:
@ -62,7 +62,9 @@ def run_test(testdir, should_succeed=True):
pt.wait() pt.wait()
if pt.returncode != 0: if pt.returncode != 0:
raise RuntimeError('Running unit tests failed.') 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() pi.wait()
if pi.returncode != 0: if pi.returncode != 0:
raise RuntimeError('Running install failed.') raise RuntimeError('Running install failed.')

@ -12,10 +12,11 @@ else
outputname = '@BASENAME@.o' outputname = '@BASENAME@.o'
endif 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, gen = generator(python,
output : outputname, output : outputname,
arguments : [comp, '@INPUT@', '@OUTPUT@']) arguments : [comp, cc, '@INPUT@', '@OUTPUT@'])
generated = gen.process('source.c') generated = gen.process('source.c')

@ -5,14 +5,15 @@
import sys, shutil, subprocess import sys, shutil, subprocess
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) != 3: if len(sys.argv) != 4:
print(sys.argv[0], 'input_file output_file') print(sys.argv[0], 'compiler input_file output_file')
sys.exit(1) sys.exit(1)
ifile = sys.argv[1] compiler = sys.argv[1]
ofile = sys.argv[2] ifile = sys.argv[2]
if shutil.which('cl'): ofile = sys.argv[3]
cmd = ['cl', '/nologo', '/Fo'+ofile, '/c', ifile] if compiler.endswith('cl'):
cmd = [compiler, '/nologo', '/Fo'+ofile, '/c', ifile]
else: else:
cmd = ['cc', '-c', ifile, '-o', ofile] cmd = [compiler, '-c', ifile, '-o', ofile]
sys.exit(subprocess.call(cmd)) sys.exit(subprocess.call(cmd))

Loading…
Cancel
Save