-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_desktop_release.py
More file actions
79 lines (69 loc) · 2.28 KB
/
run_desktop_release.py
File metadata and controls
79 lines (69 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import argparse
import subprocess
import sys
from pathlib import Path
import sts2_recovery as recover
def parse_args() -> argparse.Namespace:
script_dir = Path(__file__).resolve().parent
parser = argparse.ArgumentParser(description="Run the exported Windows Desktop Release package.")
parser.add_argument(
"--output-dir",
"-OutputDir",
type=Path,
default=script_dir / "build" / "recovered_project",
help="existing recovered project directory",
)
parser.add_argument(
"--renderer",
default=None,
help="optional rendering driver override, e.g. d3d12 / vulkan / opengl3",
)
parser.add_argument(
"--quit-after",
type=int,
default=0,
help="quit automatically after N seconds",
)
parser.add_argument(
"--log-file",
type=Path,
default=None,
help="optional exported runtime log file path",
)
parser.add_argument(
"extra_args",
nargs=argparse.REMAINDER,
help="extra arguments forwarded to the exported executable (prefix with --)",
)
return parser.parse_args()
def main() -> int:
args = parse_args()
args.output_dir = args.output_dir.resolve()
export_exe = (args.output_dir / recover.WINDOWS_RELEASE_EXPORT_RELATIVE_PATH).resolve()
if not export_exe.exists():
print(
"未发现桌面 Release 导出包,请先运行 "
"`python .\\export_desktop_release.py`。",
file=sys.stderr,
)
return 1
cmd = [str(export_exe)]
if args.renderer:
cmd.extend(["--rendering-driver", args.renderer])
if args.quit_after > 0:
cmd.extend(["--quit-after", str(args.quit_after)])
if args.log_file is not None:
cmd.extend(["--log-file", str(args.log_file.resolve())])
extra_args = list(args.extra_args)
if extra_args and extra_args[0] == "--":
extra_args = extra_args[1:]
cmd.extend(extra_args)
recover.log("$ " + subprocess.list2cmdline(cmd))
completed = subprocess.run(cmd, cwd=str(export_exe.parent), check=False)
return completed.returncode
if __name__ == "__main__":
try:
raise SystemExit(main())
except Exception as exc:
print(f"ERROR: {exc}", file=sys.stderr)
raise