diff --git a/headless.py b/headless.py new file mode 100644 index 0000000000..5bc64d9bb3 --- /dev/null +++ b/headless.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +"""Small wrapper that locates the newest PPSSPPHeadless binary (same way +test.py does) and forwards all command line arguments to it. + +Usage: + python3 headless.py [OPTIONS] [FILES...] +""" + +import glob +import os +import subprocess +import sys + +PPSSPP_EXECUTABLES = [ + # Windows + "Windows\\Debug\\PPSSPPHeadless.exe", + "Windows\\Release\\PPSSPPHeadless.exe", + "Windows\\x64\\Debug\\PPSSPPHeadless.exe", + "Windows\\x64\\Release\\PPSSPPHeadless.exe", + "build*/PPSSPPHeadless.exe", + "./PPSSPPHeadless.exe", + # Mac + "build*/Debug/PPSSPPHeadless", + "build*/Release/PPSSPPHeadless", + "build*/RelWithDebInfo/PPSSPPHeadless", + "build*/MinSizeRel/PPSSPPHeadless", + # Linux + "build*/PPSSPPHeadless", + "./PPSSPPHeadless", +] + + +def find_headless(): + env_path = os.environ.get("PPSSPP_HEADLESS") + if env_path and os.path.exists(env_path): + return env_path + possible_exes = [glob.glob(f) for f in PPSSPP_EXECUTABLES] + possible_exes = [x for sublist in possible_exes for x in sublist] + existing = [f for f in possible_exes if os.path.exists(f)] + if not existing: + return None + return max(existing, key=os.path.getmtime) + + +def main(): + headless = find_headless() + if headless is None: + print("ERROR: PPSSPPHeadless binary not found. Set PPSSPP_HEADLESS or run from the repo root.", file=sys.stderr) + return 2 + return subprocess.call([headless] + sys.argv[1:]) + + +if __name__ == "__main__": + sys.exit(main())