proton: Start unknown filetypes with 'start.exe'

Doom II for example launches with a batch script.
This commit is contained in:
Andrew Eikum 2018-03-30 09:10:48 -05:00
parent d0d0e9e9d5
commit 69942f9fc8

15
proton
View File

@ -269,6 +269,7 @@ ARCH_I386=1
ARCH_X86_64=2 ARCH_X86_64=2
def determine_architecture(path): def determine_architecture(path):
#algorithm from file's msdos magic file #algorithm from file's msdos magic file
try:
with open(path, "rb") as f: with open(path, "rb") as f:
magic = f.read(2) magic = f.read(2)
if magic != "MZ": if magic != "MZ":
@ -291,6 +292,10 @@ def determine_architecture(path):
if arch == 0x014c: if arch == 0x014c:
return ARCH_I386 return ARCH_I386
return ARCH_UNKNOWN return ARCH_UNKNOWN
except:
return ARCH_UNKNOWN
game_arch = determine_architecture(sys.argv[2])
def dump_dbg_env(f): def dump_dbg_env(f):
f.write("PATH=\"" + env["PATH"] + "\" \\\n") f.write("PATH=\"" + env["PATH"] + "\" \\\n")
@ -309,8 +314,7 @@ def dump_dbg_env(f):
f.write("\tWINEDLLOVERRIDES=\"" + env["WINEDLLOVERRIDES"] + "\" \\\n") f.write("\tWINEDLLOVERRIDES=\"" + env["WINEDLLOVERRIDES"] + "\" \\\n")
def dump_dbg_scripts(): def dump_dbg_scripts():
arch = determine_architecture(sys.argv[2]) if game_arch == ARCH_X86_64:
if arch == ARCH_X86_64:
wine_name = "\"" + bindir + "wine64\"" wine_name = "\"" + bindir + "wine64\""
else: else:
wine_name = "\"" + bindir + "wine\"" wine_name = "\"" + bindir + "wine\""
@ -388,6 +392,9 @@ def dump_dbg_scripts():
f.write(" \"" + arg + "\"") f.write(" \"" + arg + "\"")
f.write(")\n") f.write(")\n")
dump_dbg_env(f) dump_dbg_env(f)
if game_arch == ARCH_UNKNOWN:
f.write("\t" + wine_name + " start \"${@:-${DEF_CMD[@]}}\"\n")
else:
f.write("\t" + wine_name + " \"${@:-${DEF_CMD[@]}}\"\n") f.write("\t" + wine_name + " \"${@:-${DEF_CMD[@]}}\"\n")
os.chmod("/tmp/proton_run", 0755) os.chmod("/tmp/proton_run", 0755)
@ -397,6 +404,10 @@ if sys.argv[1] == "run":
# if "PROTON_DUMP_DEBUG_COMMAND" in os.environ: #for now, we are always dumping the debug scripts # if "PROTON_DUMP_DEBUG_COMMAND" in os.environ: #for now, we are always dumping the debug scripts
dump_dbg_scripts() dump_dbg_scripts()
# else: #see above # else: #see above
if game_arch == ARCH_UNKNOWN:
#probably a batch script or something, hopefully start.exe can handle it
run_wine([wine_path, "start", "/unix"] + sys.argv[2:])
else:
run_wine([wine_path] + sys.argv[2:]) run_wine([wine_path] + sys.argv[2:])
elif sys.argv[1] == "getcompatpath": elif sys.argv[1] == "getcompatpath":
#linux -> windows path #linux -> windows path