|
|
|
@ -21,17 +21,18 @@ import shutil |
|
|
|
|
import subprocess |
|
|
|
|
import tempfile |
|
|
|
|
import platform |
|
|
|
|
import argparse |
|
|
|
|
from io import StringIO |
|
|
|
|
from enum import Enum |
|
|
|
|
from glob import glob |
|
|
|
|
from pathlib import Path |
|
|
|
|
|
|
|
|
|
import mesonbuild |
|
|
|
|
from mesonbuild import mesonlib |
|
|
|
|
from mesonbuild import mesonmain |
|
|
|
|
from mesonbuild import mtest |
|
|
|
|
from mesonbuild import mlog |
|
|
|
|
from mesonbuild.environment import Environment, detect_ninja |
|
|
|
|
from mesonbuild.coredata import backendlist |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Fake classes and objects for mocking |
|
|
|
@ -106,9 +107,9 @@ def find_vcxproj_with_target(builddir, target): |
|
|
|
|
import re, fnmatch |
|
|
|
|
t, ext = os.path.splitext(target) |
|
|
|
|
if ext: |
|
|
|
|
p = '<TargetName>{}</TargetName>\s*<TargetExt>\{}</TargetExt>'.format(t, ext) |
|
|
|
|
p = r'<TargetName>{}</TargetName>\s*<TargetExt>\{}</TargetExt>'.format(t, ext) |
|
|
|
|
else: |
|
|
|
|
p = '<TargetName>{}</TargetName>'.format(t) |
|
|
|
|
p = r'<TargetName>{}</TargetName>'.format(t) |
|
|
|
|
for root, dirs, files in os.walk(builddir): |
|
|
|
|
for f in fnmatch.filter(files, '*.vcxproj'): |
|
|
|
|
f = os.path.join(builddir, f) |
|
|
|
@ -218,32 +219,40 @@ def print_system_info(): |
|
|
|
|
print('System:', platform.system()) |
|
|
|
|
print('') |
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
def main(): |
|
|
|
|
print_system_info() |
|
|
|
|
parser = argparse.ArgumentParser() |
|
|
|
|
parser.add_argument('--cov', action='store_true') |
|
|
|
|
parser.add_argument('--backend', default=None, dest='backend', |
|
|
|
|
choices=backendlist) |
|
|
|
|
parser.add_argument('--cross', default=False, dest='cross', action='store_true') |
|
|
|
|
(options, _) = parser.parse_known_args() |
|
|
|
|
# Enable coverage early... |
|
|
|
|
enable_coverage = '--cov' in sys.argv |
|
|
|
|
enable_coverage = options.cov |
|
|
|
|
if enable_coverage: |
|
|
|
|
os.makedirs('.coverage', exist_ok=True) |
|
|
|
|
sys.argv.remove('--cov') |
|
|
|
|
import coverage |
|
|
|
|
coverage.process_startup() |
|
|
|
|
returncode = 0 |
|
|
|
|
# Iterate over list in reverse order to find the last --backend arg |
|
|
|
|
backend = Backend.ninja |
|
|
|
|
cross = False |
|
|
|
|
# FIXME: PLEASE convert to argparse |
|
|
|
|
for arg in reversed(sys.argv[1:]): |
|
|
|
|
if arg.startswith('--backend'): |
|
|
|
|
if arg.startswith('--backend=vs'): |
|
|
|
|
backend = Backend.vs |
|
|
|
|
elif arg == '--backend=xcode': |
|
|
|
|
backend = Backend.xcode |
|
|
|
|
if arg.startswith('--cross'): |
|
|
|
|
cross = True |
|
|
|
|
if arg == '--cross=mingw': |
|
|
|
|
cross = 'mingw' |
|
|
|
|
elif arg == '--cross=arm': |
|
|
|
|
cross = 'arm' |
|
|
|
|
backend = options.backend |
|
|
|
|
cross = options.cross |
|
|
|
|
msbuild_exe = shutil.which('msbuild') |
|
|
|
|
# Auto-detect backend if unspecified |
|
|
|
|
if backend is None: |
|
|
|
|
if msbuild_exe is not None: |
|
|
|
|
backend = 'vs' # Meson will auto-detect VS version to use |
|
|
|
|
else: |
|
|
|
|
backend = 'ninja' |
|
|
|
|
# Set backend arguments for Meson |
|
|
|
|
if backend.startswith('vs'): |
|
|
|
|
backend = Backend.vs |
|
|
|
|
elif backend == 'xcode': |
|
|
|
|
backend = Backend.xcode |
|
|
|
|
elif backend == 'ninja': |
|
|
|
|
backend = Backend.ninja |
|
|
|
|
else: |
|
|
|
|
raise RuntimeError('Unknown backend: {!r}'.format(backend)) |
|
|
|
|
# Running on a developer machine? Be nice! |
|
|
|
|
if not mesonlib.is_windows() and not mesonlib.is_haiku() and 'TRAVIS' not in os.environ: |
|
|
|
|
os.nice(20) |
|
|
|
@ -267,26 +276,33 @@ if __name__ == '__main__': |
|
|
|
|
# Can't pass arguments to unit tests, so set the backend to use in the environment |
|
|
|
|
env = os.environ.copy() |
|
|
|
|
env['MESON_UNIT_TEST_BACKEND'] = backend.name |
|
|
|
|
with tempfile.TemporaryDirectory() as td: |
|
|
|
|
with tempfile.TemporaryDirectory() as temp_dir: |
|
|
|
|
# Enable coverage on all subsequent processes. |
|
|
|
|
if enable_coverage: |
|
|
|
|
with open(os.path.join(td, 'usercustomize.py'), 'w') as f: |
|
|
|
|
f.write('import coverage\n' |
|
|
|
|
'coverage.process_startup()\n') |
|
|
|
|
Path(temp_dir, 'usercustomize.py').open('w').write( |
|
|
|
|
'import coverage\n' |
|
|
|
|
'coverage.process_startup()\n') |
|
|
|
|
env['COVERAGE_PROCESS_START'] = '.coveragerc' |
|
|
|
|
env['PYTHONPATH'] = os.pathsep.join([td] + env.get('PYTHONPATH', [])) |
|
|
|
|
env['PYTHONPATH'] = os.pathsep.join([temp_dir] + env.get('PYTHONPATH', [])) |
|
|
|
|
if not cross: |
|
|
|
|
returncode += subprocess.call(mesonlib.python_command + ['run_meson_command_tests.py', '-v'], env=env) |
|
|
|
|
returncode += subprocess.call(mesonlib.python_command + ['run_unittests.py', '-v'], env=env) |
|
|
|
|
returncode += subprocess.call(mesonlib.python_command + ['run_project_tests.py'] + sys.argv[1:], env=env) |
|
|
|
|
cmd = mesonlib.python_command + ['run_meson_command_tests.py', '-v'] |
|
|
|
|
returncode += subprocess.call(cmd, env=env) |
|
|
|
|
cmd = mesonlib.python_command + ['run_unittests.py', '-v'] |
|
|
|
|
returncode += subprocess.call(cmd, env=env) |
|
|
|
|
cmd = mesonlib.python_command + ['run_project_tests.py'] + sys.argv[1:] |
|
|
|
|
returncode += subprocess.call(cmd, env=env) |
|
|
|
|
else: |
|
|
|
|
cross_test_args = mesonlib.python_command + ['run_cross_test.py'] |
|
|
|
|
if cross is True or cross == 'arm': |
|
|
|
|
print(mlog.bold('Running armhf cross tests.').get_text(mlog.colorize_console)) |
|
|
|
|
print() |
|
|
|
|
returncode += subprocess.call(cross_test_args + ['cross/ubuntu-armhf.txt'], env=env) |
|
|
|
|
if cross is True or cross == 'mingw': |
|
|
|
|
print(mlog.bold('Running mingw-w64 64-bit cross tests.').get_text(mlog.colorize_console)) |
|
|
|
|
print() |
|
|
|
|
returncode += subprocess.call(cross_test_args + ['cross/linux-mingw-w64-64bit.txt'], env=env) |
|
|
|
|
sys.exit(returncode) |
|
|
|
|
print(mlog.bold('Running armhf cross tests.').get_text(mlog.colorize_console)) |
|
|
|
|
print() |
|
|
|
|
cmd = cross_test_args + ['cross/ubuntu-armhf.txt'] |
|
|
|
|
returncode += subprocess.call(cmd, env=env) |
|
|
|
|
print(mlog.bold('Running mingw-w64 64-bit cross tests.') |
|
|
|
|
.get_text(mlog.colorize_console)) |
|
|
|
|
print() |
|
|
|
|
cmd = cross_test_args + ['cross/linux-mingw-w64-64bit.txt'] |
|
|
|
|
returncode += subprocess.call(cmd, env=env) |
|
|
|
|
return returncode |
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
sys.exit(main()) |
|
|
|
|