mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-04 10:44:52 +00:00
feat(gameengine): auto-detect Steam game data via ${env:VAR} placeholders
Workflow JSON params can now reference environment variables (e.g.
${env:QUAKE3_PAK0}) which are expanded at JSON load time. A new Python
detector reads the Windows registry and parses libraryfolders.vdf to
locate Steam libraries, then resolves known-game files into env vars
that dev_commands.py exports before launching the engine. Lets users
with legitimate Steam-owned game data run packages like quake3 without
hardcoded paths.
Also fixes os.execv on Windows (Invalid argument with spaced paths) by
falling back to subprocess.call.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -640,6 +640,22 @@ def run_demo(args: argparse.Namespace) -> None:
|
||||
if not args.no_sync:
|
||||
_sync_assets(build_dir, args.dry_run)
|
||||
|
||||
# Detect Steam-owned game data and export as env vars for ${env:VAR}
|
||||
# substitution in workflow JSON. Silent no-op if Steam isn't installed.
|
||||
try:
|
||||
from steam_detector import detect_and_export
|
||||
detected = detect_and_export()
|
||||
if detected:
|
||||
print("=== Detected game data ===")
|
||||
for k, v in detected.items():
|
||||
print(f" {k}={v}")
|
||||
os.environ[k] = v
|
||||
print()
|
||||
except NotImplementedError as e:
|
||||
print(f"[steam_detector] {e}")
|
||||
except Exception as e:
|
||||
print(f"[steam_detector] detection skipped: {e}")
|
||||
|
||||
exe_name = args.target or ("sdl3_app.exe" if IS_WINDOWS else "sdl3_app")
|
||||
binary = str(Path(build_dir).resolve() / exe_name)
|
||||
run_args = _strip_leading_double_dash(args.args)
|
||||
@@ -647,8 +663,12 @@ def run_demo(args: argparse.Namespace) -> None:
|
||||
if run_args:
|
||||
cmd.extend(run_args)
|
||||
_print_cmd(cmd)
|
||||
import os
|
||||
os.chdir(build_dir)
|
||||
if IS_WINDOWS:
|
||||
# os.execv is buggy on Windows with paths containing spaces;
|
||||
# use subprocess and propagate the exit code instead.
|
||||
import subprocess
|
||||
sys.exit(subprocess.call(cmd))
|
||||
os.execv(binary, cmd)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user