883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
62 lines
3.0 KiB
Python
62 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Exercise Wine PE initialization without the game.
|
|
|
|
Requires PE-only builds in build/default-wire-regression-private and
|
|
build/self-locating-wire-private; the latter uses --self-locating-bundle.
|
|
"""
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / 'ops'))
|
|
from build_wine_wire import FLAGS, LIBS
|
|
from wine_console import run_console
|
|
|
|
if not all(shutil.which(x) for x in ('wine', 'clang', 'lld-link', 'wineserver')):
|
|
print('SKIP: Wine and PE build tools required')
|
|
sys.exit(77)
|
|
|
|
def dos(path):
|
|
return 'Z:' + str(path).replace('/', '\\')
|
|
|
|
with tempfile.TemporaryDirectory(prefix='gw-bundle-init-') as tmp:
|
|
root = Path(tmp) / 'bundle'
|
|
game_dir = root / 'runtime/native-client/_classic_beta_'
|
|
build_dir = root / 'build'
|
|
(build_dir / 'default').mkdir(parents=True)
|
|
(build_dir / 'forever-schema').mkdir()
|
|
game_dir.mkdir(parents=True)
|
|
for source, target in (
|
|
(ROOT / 'build/default-wire-regression-private/GWNativeWire.dll', build_dir / 'default/GWNativeWire.dll'),
|
|
(ROOT / 'build/self-locating-wire-private/GWNativeWire.dll', build_dir / 'GWNativeWire.dll'),
|
|
(ROOT / 'build/libgateway_wine_wire.so', build_dir / 'libgateway_wine_wire.so'),
|
|
(ROOT / 'build/libgateway_native.so', build_dir / 'libgateway_native.so'),
|
|
(ROOT / 'build/forever-schema/libforever_codec.so', build_dir / 'forever-schema/libforever_codec.so'),
|
|
):
|
|
shutil.copy2(source, target)
|
|
obj = root / 'fixture.obj'
|
|
exe = game_dir / 'WowB.exe'
|
|
nt = '\\??\\' + dos(build_dir / 'libgateway_wine_wire.so')
|
|
defines = [
|
|
'-DGW_DEFAULT_WIRE_DLL=' + json.dumps(dos(build_dir / 'default/GWNativeWire.dll')),
|
|
'-DGW_SELF_LOCATING_WIRE_DLL=' + json.dumps(dos(build_dir / 'GWNativeWire.dll')),
|
|
'-DGW_EXPLICIT_WINE_PATH=L' + json.dumps(nt),
|
|
]
|
|
subprocess.run(['clang', *FLAGS, *defines, '-c', str(ROOT / 'tests/wine_bundle_initialize_fixture.c'), '-o', str(obj)], check=True)
|
|
subprocess.run(['lld-link', '/entry:fixture_start', '/subsystem:console', '/nodefaultlib', '/timestamp:0', '/out:' + str(exe), str(obj), str(LIBS[2]), str(LIBS[3])], check=True)
|
|
env = dict(os.environ, WINEPREFIX=str(Path(tmp) / 'prefix'), WINEDEBUG='-all')
|
|
for name in ('LD_PRELOAD', 'GW_NATIVE_BOOTSTRAP', 'GW_NATIVE_EXPECTED_EXE', 'GW_NATIVE_REGISTER'):
|
|
env.pop(name, None)
|
|
try:
|
|
result = run_console(['wine', str(exe)], env=env, timeout=60)
|
|
if result.returncode:
|
|
raise RuntimeError('PE bundle initialization fixture failed: exit ' + str(result.returncode) + '; Wine stderr: ' + result.stderr.decode(errors='replace')[:600])
|
|
finally:
|
|
subprocess.run(['wineserver', '-k'], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False)
|
|
print('Owned Wine PE bundle and explicit-path initialization passed; no game or client acceptance.')
|