#!/usr/bin/env python3 """Launch the Rust development scene and check bounded GPU presentation. Requires prepared private resources and a desktop display (or --vscreen on headless Linux). This is a renderer startup check, not a gameplay parity gate. """ import argparse import json import os from pathlib import Path import subprocess import sys try: from . import lab except ImportError: import lab def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--vscreen', action='store_true') parser.add_argument('--prepare', action='store_true') args = parser.parse_args() if args.prepare: subprocess.run([sys.executable, str(lab.ROOT / 'tools/prepare_native_client.py'), '--prepare'], cwd=lab.ROOT, check=True) root = lab.LOCAL / 'horizon-client' root.mkdir(parents=True, exist_ok=True) report = root / 'startup-smoke.json' report.unlink(missing_ok=True) environment = dict(os.environ, RUSTUP_TOOLCHAIN='stable') subprocess.run(['cargo', 'build', '--locked', '-p', 'horizon-client'], cwd=lab.ROOT, env=environment, check=True, timeout=3600) metadata = json.loads(subprocess.check_output( ['cargo', 'metadata', '--locked', '--no-deps', '--format-version', '1'], cwd=lab.ROOT, env=environment)) executable = Path(metadata['target_directory']) / 'debug' / ( 'horizon-client.exe' if os.name == 'nt' else 'horizon-client') command = (['vscreen', 'run'] if args.vscreen else []) + [ str(executable), '--radius', '1', '--frames', '30', '--smoke-report', str(report), '--timeout-seconds', '60'] with (root / 'startup-smoke.log').open('w') as log: subprocess.run(command, cwd=lab.ROOT, env=environment, check=True, stdout=log, stderr=subprocess.STDOUT, timeout=120) result = json.loads(report.read_text()) if (result.get('error') is not None or result.get('presented_frames') != 30 or result.get('resident_chunks') != 9 or result.get('merged_quads', 0) <= 0 or not result.get('adapter') or min(result.get('window_size', [0])) <= 0): raise RuntimeError('Incomplete native client presentation: ' + str(report)) result['executable_sha256'] = lab.digest(executable, 'sha256') result['resource_manifest_sha256'] = lab.digest( root / '26.3/horizon-resources.json', 'sha256') result['sources'] = { str(path.relative_to(lab.ROOT)): lab.digest(path, 'sha256') for path in sorted((lab.ROOT / 'crates/horizon-client/src').glob('*')) if path.is_file() } lab.write_json(report, result) print(f'Native renderer startup passed: {report}') if __name__ == '__main__': main()