Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
43 lines
3.8 KiB
Python
43 lines
3.8 KiB
Python
from pathlib import Path
|
|
import sys,os,json,shutil,subprocess,time,fcntl,signal
|
|
root=Path('/home/jakub/devel/escapistsrereintroduced');sys.path.insert(0,str(root/'tools'))
|
|
from headless_game import assert_no_game,assert_prefix_idle,cleanup_owned_run
|
|
from source_manifest import addon_manifest
|
|
from external_addons import policy,prepare_profile
|
|
base=Path('/tmp/erri-welcome-audio');run=base/'native9';run.mkdir();source=run/'source';source.mkdir()
|
|
steam=Path.home()/'.local/share/Steam';compat=Path('/tmp/erri-takeover-client-compat')
|
|
lock=(compat/'.erri-workbench.lock').open('a');fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB);assert_prefix_idle(compat);assert_no_game()
|
|
for rel in addon_manifest(root):
|
|
dest=source/Path(rel).relative_to('addons/core');dest.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(root/rel,dest)
|
|
shutil.copy2('/tmp/erri-takeover-pair-source32/resourceDatabase.rdb',source/'resourceDatabase.rdb')
|
|
shutil.copy2(base/'probe-download.c',source/'Scripts/Game/ERR/00_Core/ERR_ZWelcomeAudioProbe.c')
|
|
addons=run/'addons';addons.mkdir();prepare_profile(addons,steam/'steamapps/compatdata/1874880/pfx/drive_c/users/steamuser/Documents/My Games/ArmaReforger/addons',policy(root),run/'external-cache.json');(addons/'ERR_Core').symlink_to(source,target_is_directory=True)
|
|
profile=run/'profile';profile.mkdir();(profile/'profile').mkdir();shutil.copy2(base/'welcome.wav',profile/'profile/welcome.wav')
|
|
proton=steam/'steamapps/common/Proton - Experimental/proton';game=steam/'steamapps/common/Arma Reforger'
|
|
cmd=['gamescope','--backend','headless','-W','1280','-H','720','-w','1280','-h','720','-r','30','--',str(proton),'run',str(game/'ArmaReforgerSteam.exe'),'-addonsDir','Z:'+str(addons),'-addons','2528466DE220D91C','-profile','Z:'+str(profile),'-maxFPS','30','-noSplash','-noThrow','-disableCrashReporter','-logconsole']
|
|
env=os.environ.copy();env.update(STEAM_COMPAT_DATA_PATH=str(compat),STEAM_COMPAT_CLIENT_INSTALL_PATH=str(steam),WINEPREFIX=str(compat/'pfx'),PULSE_SINK='erri_welcome_test',PROTON_LOG='1',PROTON_LOG_DIR=str(run),SteamGameId='1874880',SteamAppId='1874880')
|
|
(run/'command.json').write_text(json.dumps(cmd,indent=2));p=None;rec=None;reason='timeout'
|
|
http_log=(run/'http.log').open('w');http=subprocess.Popen([sys.executable,'-m','http.server','18947','--bind','127.0.0.1','--directory',str(base)],stdout=http_log,stderr=subprocess.STDOUT,start_new_session=True)
|
|
module=subprocess.check_output(['pactl','load-module','module-null-sink','sink_name=erri_welcome_test','sink_properties=device.description=EscapeWelcomeTest'],text=True).strip()
|
|
with (run/'stdout.log').open('w') as log, (run/'record.log').open('w') as reclog:
|
|
try:
|
|
rec=subprocess.Popen(['ffmpeg','-y','-f','pulse','-i','erri_welcome_test.monitor','-ac','1','-ar','24000',str(run/'capture.wav')],stdout=reclog,stderr=subprocess.STDOUT,start_new_session=True)
|
|
p=subprocess.Popen(cmd,cwd=game,env=env,stdout=log,stderr=subprocess.STDOUT,start_new_session=True)
|
|
start=time.monotonic()
|
|
while time.monotonic()-start<150:
|
|
files=sorted(profile.glob('logs/logs_*/console.log'));text=files[-1].read_text(errors='replace') if files else ''
|
|
if 'ERR WELCOME AUDIO COMPLETE' in text:reason='probe-complete';break
|
|
if "Can't compile" in text:reason='compile-failed';break
|
|
if p.poll() is not None:reason='client-exit';break
|
|
time.sleep(.5)
|
|
finally:
|
|
if p:
|
|
cleanup=cleanup_owned_run(p,proton,env,compat);(run/'cleanup.json').write_text(json.dumps(cleanup,indent=2))
|
|
if rec and rec.poll() is None:
|
|
os.killpg(rec.pid,signal.SIGINT)
|
|
try:rec.wait(timeout=5)
|
|
except subprocess.TimeoutExpired:os.killpg(rec.pid,signal.SIGKILL);rec.wait()
|
|
subprocess.run(['pactl','unload-module',module],check=True)
|
|
http.terminate();http.wait(timeout=5);http_log.close()
|
|
(run/'result.json').write_text(json.dumps({'reason':reason},indent=2));print(reason)
|