forked from bates64/papermario-dx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·60 lines (48 loc) · 1.2 KB
/
run
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
#!/usr/bin/env python3
import os
import subprocess
import shutil
import platform
ROM = "ver/current/build/papermario.z64"
EMULATOR_PATHS = [
"cen64",
"ares",
"mupen64plus",
"retroarch",
"Project64",
]
emulator = None
for command in EMULATOR_PATHS:
if shutil.which(command) is not None:
emulator = command
break
# WSl compat
command += ".exe"
if shutil.which(command) is not None:
emulator = command
break
def is_wsl(v: str = platform.uname().release) -> int:
"""
detects if Python is running in WSL
"""
if v.endswith("-Microsoft"):
return 1
elif v.endswith("microsoft-standard-WSL2"):
return 2
return 0
def windows_path(path):
return subprocess.check_output(["wslpath", "-w", path]).decode().strip()
def main():
if os.system(f"ninja {ROM}") != 0:
print("error: build failed")
return
wsl = is_wsl() != 0
rom = windows_path(ROM) if wsl else ROM
if emulator is not None:
subprocess.run([emulator, rom])
else:
print("error: no emulator found")
if wsl:
print(" hint: add an emulator to your PATH")
if __name__ == "__main__":
main()