42 lines
1.8 KiB
Python
42 lines
1.8 KiB
Python
|
|
"""Reuse the actual Release app objects for a hardware-free theme smoke test."""
|
||
|
|
import os
|
||
|
|
from pathlib import Path
|
||
|
|
import re
|
||
|
|
import shlex
|
||
|
|
import subprocess
|
||
|
|
|
||
|
|
root = Path(__file__).resolve().parents[1]
|
||
|
|
qt = Path('C:/Qt/Qt5.12.4/5.12.4/mingw73_64')
|
||
|
|
toolchain = Path('C:/Qt/Qt5.12.4/Tools/mingw730_64/bin')
|
||
|
|
text = (root / 'Makefile.Release').read_text(encoding='utf-8')
|
||
|
|
|
||
|
|
|
||
|
|
def value(name):
|
||
|
|
return re.search(r'^' + name + r'\s*=\s*(.*)$', text, re.M).group(1).strip()
|
||
|
|
|
||
|
|
|
||
|
|
def args(text):
|
||
|
|
return [part.strip('"') for part in shlex.split(text, posix=False)]
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
env = dict(os.environ)
|
||
|
|
env['PATH'] = os.pathsep.join((str(toolchain), str(qt / 'bin'), str(root / 'bin/release'), env['PATH']))
|
||
|
|
env['QT_QPA_PLATFORM'] = 'offscreen'
|
||
|
|
env['QT_QPA_FONTDIR'] = 'C:/Windows/Fonts'
|
||
|
|
output = root / 'build/application-theme-shell'
|
||
|
|
output.mkdir(parents=True, exist_ok=True)
|
||
|
|
obj = output / 'application_shell_test.o'
|
||
|
|
binary = output / 'application_shell_test.exe'
|
||
|
|
flags = value('CXXFLAGS').replace('$(DEFINES)', value('DEFINES'))
|
||
|
|
subprocess.run([str(toolchain / 'g++.exe'), '-c', *args(flags), *args(value('INCPATH')),
|
||
|
|
'-I' + str(root / 'src'), str(root / 'tests/application_shell_test.cpp'), '-o', str(obj)],
|
||
|
|
cwd=root, env=env, check=True)
|
||
|
|
objects = (root / 'object_script.CmvrControlStation.Release').read_text().splitlines()
|
||
|
|
objects = [item for item in objects if not item.replace('\\', '/').endswith('/main.o')]
|
||
|
|
response = output / 'objects.rsp'
|
||
|
|
response.write_text('\n'.join(objects), encoding='utf-8')
|
||
|
|
subprocess.run([str(toolchain / 'g++.exe'), '-mthreads', '-o', str(binary), str(obj),
|
||
|
|
'@' + str(response), *args(value('LIBS'))], cwd=root, env=env, check=True)
|
||
|
|
subprocess.run([str(binary)], cwd=output, env=env, check=True, timeout=30)
|