2018-08-23 14:21:22 +03:00
|
|
|
#!/usr/bin/env python
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
#script to launch Wine with the correct environment
|
|
|
|
|
2018-08-24 10:18:36 +03:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2018-01-19 20:03:54 +03:00
|
|
|
import filecmp
|
2018-01-18 23:00:48 +03:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
import shutil
|
2018-02-15 17:49:56 +03:00
|
|
|
import struct
|
2018-01-18 23:00:48 +03:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2018-01-19 20:03:54 +03:00
|
|
|
import tarfile
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-03-16 18:08:29 +03:00
|
|
|
from filelock import FileLock, Timeout
|
|
|
|
|
2018-06-21 17:09:10 +03:00
|
|
|
#To enable debug logging, copy "user_settings.sample.py" to "user_settings.py"
|
|
|
|
#and edit it if needed.
|
2018-03-16 19:02:04 +03:00
|
|
|
|
2018-08-23 17:01:32 +03:00
|
|
|
CURRENT_PREFIX_VERSION="3.7-2"
|
2018-02-15 21:53:47 +03:00
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
PFX="Proton: "
|
|
|
|
|
2018-03-06 21:13:24 +03:00
|
|
|
if "Darwin" in os.uname()[0]:
|
|
|
|
ld_path_var = "DYLD_LIBRARY_PATH"
|
|
|
|
else:
|
|
|
|
ld_path_var = "LD_LIBRARY_PATH"
|
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
def log(msg):
|
2018-03-13 17:57:35 +03:00
|
|
|
sys.stderr.write(PFX + msg + os.linesep)
|
|
|
|
sys.stderr.flush()
|
2018-02-15 21:53:47 +03:00
|
|
|
|
|
|
|
def upgrade_pfx(old_ver):
|
|
|
|
if old_ver == CURRENT_PREFIX_VERSION:
|
|
|
|
return
|
2018-08-23 17:01:32 +03:00
|
|
|
|
2018-04-20 18:11:19 +03:00
|
|
|
log("Upgrading prefix from " + str(old_ver) + " to " + CURRENT_PREFIX_VERSION + " (" + os.environ["STEAM_COMPAT_DATA_PATH"] + ")")
|
2018-08-23 17:42:18 +03:00
|
|
|
|
|
|
|
if old_ver == None:
|
|
|
|
return
|
|
|
|
|
2018-08-23 17:01:32 +03:00
|
|
|
old_proton_ver, old_prefix_ver = old_ver.split('-')
|
|
|
|
|
|
|
|
if old_proton_ver == "3.7" and old_prefix_ver == "1":
|
|
|
|
if not os.path.exists(prefix + "/drive_c/windows/syswow64/kernel32.dll"):
|
|
|
|
#shipped a busted 64-bit-only installation on 20180822. detect and wipe clean
|
|
|
|
log("Detected broken 64-bit-only installation, re-creating prefix.")
|
|
|
|
shutil.rmtree(prefix)
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-01-19 22:03:51 +03:00
|
|
|
def run_wine(args):
|
2018-03-30 16:46:34 +03:00
|
|
|
subprocess.call(args, env=env, stderr=lfile)
|
2018-01-19 22:03:51 +03:00
|
|
|
|
2018-01-23 17:03:43 +03:00
|
|
|
def makedirs(path):
|
|
|
|
try:
|
|
|
|
os.makedirs(path)
|
|
|
|
except:
|
|
|
|
#already exists
|
|
|
|
pass
|
|
|
|
|
2018-07-20 16:26:15 +03:00
|
|
|
def real_copy(src, dst):
|
|
|
|
if os.path.islink(src):
|
|
|
|
os.symlink(os.readlink(src), dst)
|
|
|
|
else:
|
|
|
|
shutil.copy(src,dst)
|
|
|
|
|
|
|
|
def mergedirs(src, dst):
|
|
|
|
for src_dir, dirs, files in os.walk(src):
|
|
|
|
dst_dir = src_dir.replace(src, dst, 1)
|
|
|
|
if not os.path.exists(dst_dir):
|
|
|
|
os.makedirs(dst_dir)
|
|
|
|
for dir_ in dirs:
|
|
|
|
src_file = os.path.join(src_dir, dir_)
|
|
|
|
dst_file = os.path.join(dst_dir, dir_)
|
|
|
|
if os.path.islink(src_file) and not os.path.exists(dst_file):
|
|
|
|
real_copy(src_file, dst_file)
|
|
|
|
for file_ in files:
|
|
|
|
src_file = os.path.join(src_dir, file_)
|
|
|
|
dst_file = os.path.join(dst_dir, file_)
|
|
|
|
if not os.path.exists(dst_file):
|
|
|
|
real_copy(src_file, dst_file)
|
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
if not ("STEAM_COMPAT_DATA_PATH" in os.environ):
|
|
|
|
log("No compat data path?")
|
|
|
|
sys.exit(1)
|
|
|
|
|
2018-01-19 20:03:54 +03:00
|
|
|
basedir = os.path.dirname(sys.argv[0])
|
|
|
|
bindir = basedir + "/dist/bin/"
|
2018-02-14 22:59:35 +03:00
|
|
|
libdir = basedir + "/dist/lib"
|
|
|
|
lib64dir = basedir + "/dist/lib64"
|
2018-01-18 23:00:48 +03:00
|
|
|
wine_path = bindir + "/wine64"
|
|
|
|
|
2018-01-19 20:03:54 +03:00
|
|
|
#extract if needed
|
2018-03-16 18:08:29 +03:00
|
|
|
dist_lock = FileLock(basedir + "/dist.lock", timeout=-1)
|
|
|
|
with dist_lock:
|
|
|
|
if not os.path.exists(basedir + "/dist") or \
|
|
|
|
not os.path.exists(basedir + "/dist/version") or \
|
|
|
|
not filecmp.cmp(basedir + "/version", basedir + "/dist/version"):
|
|
|
|
if os.path.exists(basedir + "/dist"):
|
|
|
|
shutil.rmtree(basedir + "/dist")
|
|
|
|
tar = tarfile.open(basedir + "/proton_dist.tar.gz", mode="r:gz")
|
|
|
|
tar.extractall(path=basedir + "/dist")
|
|
|
|
tar.close()
|
|
|
|
shutil.copy(basedir + "/version", basedir + "/dist/")
|
2018-01-19 20:03:54 +03:00
|
|
|
|
2018-01-18 23:00:48 +03:00
|
|
|
env = dict(os.environ)
|
2018-03-28 18:27:56 +03:00
|
|
|
dlloverrides = {}
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-06-21 17:09:10 +03:00
|
|
|
#for performance, logging is disabled by default; override with user_settings.py
|
|
|
|
env["DXVK_LOG_LEVEL"] = "none"
|
|
|
|
env["WINEDEBUG"] = "-all"
|
2018-08-22 18:11:30 +03:00
|
|
|
env.pop("WINEARCH", "")
|
2018-05-11 15:14:04 +03:00
|
|
|
|
2018-03-06 21:13:24 +03:00
|
|
|
if ld_path_var in os.environ:
|
2018-03-13 17:55:05 +03:00
|
|
|
env[ld_path_var] = lib64dir + ":" + libdir + ":" + os.environ[ld_path_var]
|
2018-01-18 23:00:48 +03:00
|
|
|
else:
|
2018-03-06 21:13:24 +03:00
|
|
|
env[ld_path_var] = lib64dir + ":" + libdir
|
2018-02-14 22:59:35 +03:00
|
|
|
|
|
|
|
env["WINEDLLPATH"] = lib64dir + "/wine:" + libdir + "/wine"
|
|
|
|
|
|
|
|
if "PATH" in os.environ:
|
2018-03-13 17:55:05 +03:00
|
|
|
env["PATH"] = bindir + ":" + os.environ["PATH"]
|
2018-02-14 22:59:35 +03:00
|
|
|
else:
|
|
|
|
env["PATH"] = bindir
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-03-16 18:08:29 +03:00
|
|
|
with dist_lock:
|
|
|
|
if not os.path.isdir(basedir + "/dist/share/default_pfx"):
|
|
|
|
#make default prefix
|
|
|
|
env["WINEPREFIX"] = basedir + "/dist/share/default_pfx"
|
|
|
|
run_wine([wine_path, "wineboot"])
|
|
|
|
run_wine([bindir + "/wineserver", "-w"])
|
2018-01-25 22:22:24 +03:00
|
|
|
|
|
|
|
prefix = os.environ["STEAM_COMPAT_DATA_PATH"] + "/pfx/"
|
|
|
|
env["WINEPREFIX"] = prefix
|
2018-01-18 23:00:48 +03:00
|
|
|
|
2018-08-22 22:43:40 +03:00
|
|
|
if "PROTON_LOG" in env:
|
|
|
|
env["WINEDEBUG"] = "+timestamp,+pid,+tid,+seh,+debugstr,+module"
|
|
|
|
|
2018-06-21 17:09:10 +03:00
|
|
|
#load environment overrides
|
|
|
|
if os.path.exists(basedir + "/user_settings.py"):
|
2018-07-11 21:44:52 +03:00
|
|
|
try:
|
|
|
|
import user_settings
|
|
|
|
env.update(user_settings.user_settings)
|
|
|
|
except e:
|
|
|
|
log("************************************************")
|
|
|
|
log("THERE IS AN ERROR IN YOUR user_settings.py FILE:")
|
|
|
|
log("%s" % sys.exc_info()[1])
|
|
|
|
log("************************************************")
|
2018-06-21 17:09:10 +03:00
|
|
|
|
|
|
|
def check_environment(env_name, config_name):
|
|
|
|
if not env_name in env:
|
|
|
|
return
|
|
|
|
if env[env_name] == "0" or len(env[env_name]) == 0:
|
|
|
|
config_opts.discard(config_name)
|
|
|
|
else:
|
|
|
|
config_opts.add(config_name)
|
|
|
|
|
|
|
|
if "STEAM_COMPAT_CONFIG" in os.environ:
|
|
|
|
config_opts = set(os.environ["STEAM_COMPAT_CONFIG"].split(","))
|
|
|
|
else:
|
|
|
|
config_opts = set()
|
|
|
|
|
|
|
|
check_environment("PROTON_USE_WINED3D11", "wined3d11")
|
|
|
|
check_environment("PROTON_NO_D3D11", "nod3d11")
|
|
|
|
check_environment("PROTON_NO_ESYNC", "noesync")
|
|
|
|
|
|
|
|
if not "noesync" in config_opts:
|
|
|
|
env["WINEESYNC"] = "1"
|
|
|
|
|
|
|
|
lfile = None
|
2018-06-27 15:42:10 +03:00
|
|
|
if "SteamGameId" in env:
|
|
|
|
if env["WINEDEBUG"] != "-all":
|
|
|
|
lfile_path = os.environ["HOME"] + "/steam-" + os.environ["SteamGameId"] + ".log"
|
|
|
|
if os.path.exists(lfile_path):
|
|
|
|
os.remove(lfile_path)
|
|
|
|
lfile = open(lfile_path, "w+")
|
|
|
|
else:
|
|
|
|
env["WINEDEBUG"] = "-all"
|
2018-06-21 17:09:10 +03:00
|
|
|
|
2018-03-16 18:39:04 +03:00
|
|
|
prefix_lock = FileLock(os.environ["STEAM_COMPAT_DATA_PATH"] + "/pfx.lock", timeout=-1)
|
|
|
|
with prefix_lock:
|
|
|
|
version_file = os.environ["STEAM_COMPAT_DATA_PATH"] + "/version"
|
|
|
|
if os.path.exists(version_file):
|
|
|
|
with open(version_file, "r") as f:
|
|
|
|
upgrade_pfx(f.readline().strip())
|
|
|
|
else:
|
|
|
|
upgrade_pfx(None)
|
|
|
|
|
2018-08-23 17:01:32 +03:00
|
|
|
if not os.path.exists(prefix + "/user.reg"):
|
|
|
|
#copy default prefix into place
|
|
|
|
mergedirs(basedir + "/dist/share/default_pfx", prefix)
|
|
|
|
|
2018-03-16 18:39:04 +03:00
|
|
|
with open(version_file, "w") as f:
|
|
|
|
f.write(CURRENT_PREFIX_VERSION + "\n")
|
|
|
|
|
|
|
|
#copy steam files into place
|
|
|
|
if "STEAM_COMPAT_CLIENT_INSTALL_PATH" in os.environ:
|
|
|
|
#modern steam client sets this
|
|
|
|
steamdir = os.environ["STEAM_COMPAT_CLIENT_INSTALL_PATH"]
|
|
|
|
elif "STEAM_CLIENT_CONFIG_FILE" in os.environ:
|
|
|
|
#fallback for old steam clients (should remove once changes graduate)
|
|
|
|
steamdir = os.path.dirname(os.environ["STEAM_CLIENT_CONFIG_FILE"])
|
|
|
|
else:
|
|
|
|
#linux-only fallback, really shouldn't get here
|
|
|
|
steamdir = os.environ["HOME"] + ".steam/root/"
|
|
|
|
dst = prefix + "/drive_c/Program Files (x86)/"
|
|
|
|
makedirs(dst + "Steam")
|
|
|
|
filestocopy = ["steamclient.dll",
|
|
|
|
"steamclient64.dll",
|
|
|
|
"Steam.dll"]
|
|
|
|
for f in filestocopy:
|
|
|
|
if os.path.isfile(steamdir + "/legacycompat/" + f):
|
|
|
|
dstfile = dst + "Steam/" + f
|
|
|
|
if os.path.isfile(dstfile):
|
|
|
|
os.remove(dstfile)
|
|
|
|
shutil.copy(steamdir + "/legacycompat/" + f, dstfile)
|
|
|
|
|
|
|
|
#copy openvr files into place
|
|
|
|
dst = prefix + "/drive_c/vrclient/bin/"
|
|
|
|
makedirs(dst)
|
|
|
|
shutil.copy(basedir + "/dist/lib/wine/fakedlls/vrclient.dll", dst)
|
|
|
|
shutil.copy(basedir + "/dist/lib64/wine/fakedlls/vrclient_x64.dll", dst)
|
|
|
|
|
2018-07-12 17:25:38 +03:00
|
|
|
shutil.copy(basedir + "/dist/lib/wine/dxvk/openvr_api_dxvk.dll", prefix + "/drive_c/windows/syswow64/")
|
|
|
|
shutil.copy(basedir + "/dist/lib64/wine/dxvk/openvr_api_dxvk.dll", prefix + "/drive_c/windows/system32/")
|
|
|
|
|
2018-03-16 18:39:04 +03:00
|
|
|
#parse linux openvr config and present it in win32 format to the app.
|
|
|
|
#logic from openvr's CVRPathRegistry_Public::GetPaths
|
|
|
|
|
|
|
|
#check environment for overrides
|
|
|
|
vr_runtime = None
|
|
|
|
if "VR_OVERRIDE" in env:
|
|
|
|
vr_runtime = env["VR_OVERRIDE"]
|
|
|
|
env.pop("VR_OVERRIDE")
|
|
|
|
|
|
|
|
vr_config = None
|
|
|
|
if "VR_CONFIG_PATH" in env:
|
|
|
|
vr_config = env["VR_CONFIG_PATH"]
|
|
|
|
env.pop("VR_CONFIG_PATH")
|
|
|
|
|
|
|
|
vr_log = None
|
|
|
|
if "VR_LOG_PATH" in env:
|
|
|
|
vr_log = env["VR_LOG_PATH"]
|
|
|
|
env.pop("VR_LOG_PATH")
|
|
|
|
|
|
|
|
#load from json if needed
|
|
|
|
if vr_runtime is None or \
|
|
|
|
vr_config is None or \
|
|
|
|
vr_log is None:
|
|
|
|
try:
|
|
|
|
#TODO: support mac
|
|
|
|
if "XDG_CONFIG_HOME" in os.environ:
|
|
|
|
path = os.environ["XDG_CONFIG_HOME"]
|
|
|
|
else:
|
|
|
|
path = os.environ["HOME"] + "/.config"
|
|
|
|
path = path + "/openvr/openvrpaths.vrpath"
|
|
|
|
|
|
|
|
j = json.load(open(path, "r"))
|
|
|
|
|
|
|
|
if vr_runtime is None:
|
|
|
|
vr_runtime = j["runtime"][0]
|
|
|
|
|
|
|
|
if vr_config is None:
|
|
|
|
vr_config = j["config"][0]
|
|
|
|
|
|
|
|
if vr_log is None:
|
|
|
|
vr_log = j["log"][0]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2018-08-20 18:45:26 +03:00
|
|
|
makedirs(prefix + "/drive_c/users/steamuser/Local Settings/Application Data/openvr")
|
2018-03-16 18:39:04 +03:00
|
|
|
|
|
|
|
#remove existing file
|
2018-08-20 18:45:26 +03:00
|
|
|
vrpaths_name = prefix + "/drive_c/users/steamuser/Local Settings/Application Data/openvr/openvrpaths.vrpath"
|
2018-03-16 18:39:04 +03:00
|
|
|
if os.path.exists(vrpaths_name):
|
|
|
|
os.remove(vrpaths_name)
|
|
|
|
|
|
|
|
#dump new file
|
|
|
|
if not vr_runtime is None:
|
|
|
|
try:
|
|
|
|
env["PROTON_VR_RUNTIME"] = vr_runtime
|
|
|
|
|
|
|
|
j = { "runtime": [ "C:\\vrclient\\", "C:\\vrclient" ] }
|
|
|
|
|
|
|
|
if not vr_config is None:
|
|
|
|
win_vr_config = subprocess.check_output([wine_path, "winepath", "-w", vr_config], env=env, stderr=lfile)
|
|
|
|
j["config"] = [ win_vr_config.strip() ]
|
|
|
|
|
|
|
|
if not vr_log is None:
|
|
|
|
win_vr_log = subprocess.check_output([wine_path, "winepath", "-w", vr_log], env=env, stderr=lfile)
|
|
|
|
j["log"] = [ win_vr_log.strip() ]
|
|
|
|
|
|
|
|
j["version"] = 1
|
|
|
|
j["jsonid"] = "vrpathreg"
|
|
|
|
|
|
|
|
json.dump(j, open(vrpaths_name, "w"), indent=2)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def make_dxvk_links(dll_dir, link_dir):
|
|
|
|
if os.path.lexists(link_dir + "/d3d11.dll"):
|
|
|
|
os.remove(link_dir + "/d3d11.dll")
|
|
|
|
if os.path.lexists(link_dir + "/dxgi.dll"):
|
|
|
|
os.remove(link_dir + "/dxgi.dll")
|
|
|
|
os.symlink(dll_dir + "/d3d11.dll", link_dir + "/d3d11.dll")
|
|
|
|
os.symlink(dll_dir + "/dxgi.dll", link_dir + "/dxgi.dll")
|
|
|
|
|
2018-05-18 00:37:43 +03:00
|
|
|
if "wined3d11" in config_opts:
|
|
|
|
#use gl-based wined3d for d3d11
|
|
|
|
make_dxvk_links(basedir + "/dist/lib64/wine/",
|
|
|
|
prefix + "drive_c/windows/system32")
|
|
|
|
make_dxvk_links(basedir + "/dist/lib/wine/",
|
|
|
|
prefix + "drive_c/windows/syswow64")
|
|
|
|
else:
|
|
|
|
#use vulkan-based dxvk for d3d11
|
2018-03-16 18:39:04 +03:00
|
|
|
make_dxvk_links(basedir + "/dist/lib64/wine/dxvk/",
|
|
|
|
prefix + "drive_c/windows/system32")
|
|
|
|
make_dxvk_links(basedir + "/dist/lib/wine/dxvk/",
|
|
|
|
prefix + "drive_c/windows/syswow64")
|
2018-03-28 18:27:56 +03:00
|
|
|
dlloverrides["dxgi"] = "n"
|
|
|
|
dlloverrides["d3d11"] = "n"
|
2018-02-09 20:03:59 +03:00
|
|
|
|
2018-03-28 18:27:56 +03:00
|
|
|
if "nod3d11" in config_opts:
|
|
|
|
dlloverrides["d3d11"] = ""
|
|
|
|
if "dxgi" in dlloverrides:
|
|
|
|
del dlloverrides["dxgi"]
|
|
|
|
|
|
|
|
s = ""
|
2018-08-23 14:21:22 +03:00
|
|
|
for dll in dlloverrides:
|
|
|
|
setting = dlloverrides[dll]
|
2018-03-28 18:27:56 +03:00
|
|
|
if len(s) > 0:
|
|
|
|
s = s + ";" + dll + "=" + setting
|
|
|
|
else:
|
|
|
|
s = dll + "=" + setting
|
|
|
|
env["WINEDLLOVERRIDES"] = s
|
|
|
|
|
2018-02-15 17:49:56 +03:00
|
|
|
ARCH_UNKNOWN=0
|
|
|
|
ARCH_I386=1
|
|
|
|
ARCH_X86_64=2
|
|
|
|
def determine_architecture(path):
|
|
|
|
#algorithm from file's msdos magic file
|
2018-03-30 17:10:48 +03:00
|
|
|
try:
|
|
|
|
with open(path, "rb") as f:
|
|
|
|
magic = f.read(2)
|
2018-08-24 21:48:57 +03:00
|
|
|
if magic != b"MZ":
|
2018-03-30 17:10:48 +03:00
|
|
|
return ARCH_UNKNOWN
|
|
|
|
f.seek(0x18)
|
|
|
|
reloc = struct.unpack('<H', f.read(2))[0]
|
|
|
|
if reloc < 0x40:
|
|
|
|
#DOS
|
|
|
|
return ARCH_I386
|
|
|
|
f.seek(0x3c)
|
|
|
|
pe_offs = struct.unpack('<L', f.read(4))[0]
|
|
|
|
f.seek(pe_offs)
|
|
|
|
magic = f.read(4)
|
2018-08-24 21:48:57 +03:00
|
|
|
if magic != b"PE\0\0":
|
2018-03-30 17:10:48 +03:00
|
|
|
return ARCH_UNKNOWN
|
|
|
|
f.seek(pe_offs + 4)
|
|
|
|
arch = struct.unpack('<H', f.read(2))[0]
|
|
|
|
if arch == 0x8664:
|
|
|
|
return ARCH_X86_64
|
|
|
|
if arch == 0x014c:
|
|
|
|
return ARCH_I386
|
2018-02-15 17:49:56 +03:00
|
|
|
return ARCH_UNKNOWN
|
2018-03-30 17:10:48 +03:00
|
|
|
except:
|
2018-02-15 17:49:56 +03:00
|
|
|
return ARCH_UNKNOWN
|
|
|
|
|
2018-03-30 17:10:48 +03:00
|
|
|
game_arch = determine_architecture(sys.argv[2])
|
|
|
|
|
2018-03-14 21:58:11 +03:00
|
|
|
def dump_dbg_env(f):
|
2018-03-16 19:02:04 +03:00
|
|
|
f.write("PATH=\"" + env["PATH"] + "\" \\\n")
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("\tTERM=\"xterm\" \\\n") #XXX
|
|
|
|
f.write("\tWINEDEBUG=\"-all\" \\\n")
|
2018-02-15 19:13:33 +03:00
|
|
|
f.write("\tWINEDLLPATH=\"" + env["WINEDLLPATH"] + "\" \\\n")
|
2018-03-06 21:13:24 +03:00
|
|
|
f.write("\t" + ld_path_var + "=\"" + env[ld_path_var] + "\" \\\n")
|
2018-02-15 19:13:33 +03:00
|
|
|
f.write("\tWINEPREFIX=\"" + env["WINEPREFIX"] + "\" \\\n")
|
2018-03-16 19:02:04 +03:00
|
|
|
if "SteamGameId" in env:
|
|
|
|
f.write("\tSteamGameId=\"" + env["SteamGameId"] + "\" \\\n")
|
|
|
|
if "SteamAppId" in env:
|
|
|
|
f.write("\tSteamAppId=\"" + env["SteamAppId"] + "\" \\\n")
|
2018-02-15 19:13:33 +03:00
|
|
|
if "PROTON_VR_RUNTIME" in env:
|
|
|
|
f.write("\tPROTON_VR_RUNTIME=\"" + env["PROTON_VR_RUNTIME"] + "\" \\\n")
|
|
|
|
if "WINEDLLOVERRIDES" in env:
|
|
|
|
f.write("\tWINEDLLOVERRIDES=\"" + env["WINEDLLOVERRIDES"] + "\" \\\n")
|
2018-05-15 22:58:49 +03:00
|
|
|
if "STEAM_COMPAT_CLIENT_INSTALL_PATH" in env:
|
|
|
|
f.write("\tSTEAM_COMPAT_CLIENT_INSTALL_PATH=\"" + env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] + "\" \\\n")
|
2018-03-14 21:58:11 +03:00
|
|
|
|
|
|
|
def dump_dbg_scripts():
|
|
|
|
exe_name = os.path.basename(sys.argv[2])
|
|
|
|
|
2018-08-25 14:29:13 +03:00
|
|
|
dir = env.get("PROTON_DEBUG_DIR", "/tmp") + "/proton_" + os.environ["USER"] + "/"
|
2018-08-22 22:55:38 +03:00
|
|
|
makedirs(dir)
|
|
|
|
|
|
|
|
with open(dir + "winedbg", "w") as f:
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("#!/bin/bash\n")
|
|
|
|
f.write("#Run winedbg with args\n\n")
|
|
|
|
f.write("cd \"" + os.getcwd() + "\"\n")
|
|
|
|
dump_dbg_env(f)
|
2018-06-18 18:25:04 +03:00
|
|
|
f.write("\t\"" + wine_path + "\" winedbg \"$@\"\n")
|
2018-08-24 19:14:38 +03:00
|
|
|
os.chmod(dir + "winedbg", 0o755)
|
2018-03-14 21:58:11 +03:00
|
|
|
|
2018-08-22 22:55:38 +03:00
|
|
|
with open(dir + "winedbg_run", "w") as f:
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("#!/bin/bash\n")
|
|
|
|
f.write("#Run winedbg and prepare to run game or given program\n\n")
|
|
|
|
f.write("cd \"" + os.getcwd() + "\"\n")
|
|
|
|
f.write("DEF_CMD=(")
|
|
|
|
first = True
|
|
|
|
for arg in sys.argv[2:]:
|
|
|
|
if first:
|
|
|
|
f.write("\"" + arg + "\"")
|
|
|
|
first = False
|
|
|
|
else:
|
|
|
|
f.write(" \"" + arg + "\"")
|
|
|
|
f.write(")\n")
|
|
|
|
dump_dbg_env(f)
|
2018-06-18 18:25:04 +03:00
|
|
|
f.write("\t\"" + wine_path + "\" winedbg \"${@:-${DEF_CMD[@]}}\"\n")
|
2018-08-24 19:14:38 +03:00
|
|
|
os.chmod(dir + "winedbg_run", 0o755)
|
2018-03-14 21:58:11 +03:00
|
|
|
|
2018-08-22 22:55:38 +03:00
|
|
|
with open(dir + "gdb_attach", "w") as f:
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("#!/bin/bash\n")
|
|
|
|
f.write("#Run winedbg in gdb mode and auto-attach to already-running program\n\n")
|
|
|
|
f.write("cd \"" + os.getcwd() + "\"\n")
|
|
|
|
f.write("EXE_NAME=${1:-\"" + exe_name + "\"}\n")
|
2018-08-22 22:55:38 +03:00
|
|
|
f.write("WPID_HEX=$(\"" + dir + "winedbg\" --command 'info process' | grep -i \"$EXE_NAME\" | cut -f2 -d' ' | tr -d '0')\n")
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("if [ -z \"$WPID_HEX\" ]; then \n")
|
|
|
|
f.write(" echo \"Program does not appear to be running: \\\"$EXE_NAME\\\"\"\n")
|
|
|
|
f.write(" exit 1\n")
|
|
|
|
f.write("fi\n")
|
|
|
|
f.write("WPID_DEC=$(printf %d 0x$WPID_HEX)\n")
|
|
|
|
dump_dbg_env(f)
|
2018-06-18 18:25:04 +03:00
|
|
|
f.write("\t\"" + wine_path + "\" winedbg --gdb $WPID_DEC\n")
|
2018-08-24 19:14:38 +03:00
|
|
|
os.chmod(dir + "gdb_attach", 0o755)
|
2018-03-14 21:58:11 +03:00
|
|
|
|
2018-08-22 22:55:38 +03:00
|
|
|
with open(dir + "gdb_run", "w") as f:
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("#!/bin/bash\n")
|
|
|
|
f.write("#Run winedbg in gdb mode and prepare to run game or given program\n\n")
|
|
|
|
f.write("cd \"" + os.getcwd() + "\"\n")
|
|
|
|
f.write("DEF_CMD=(")
|
|
|
|
first = True
|
|
|
|
for arg in sys.argv[2:]:
|
|
|
|
if first:
|
|
|
|
f.write("\"" + arg + "\"")
|
|
|
|
first = False
|
|
|
|
else:
|
|
|
|
f.write(" \"" + arg + "\"")
|
|
|
|
f.write(")\n")
|
|
|
|
dump_dbg_env(f)
|
2018-06-18 18:25:04 +03:00
|
|
|
f.write("\t\"" + wine_path + "\" winedbg --gdb \"${@:-${DEF_CMD[@]}}\"\n")
|
2018-08-24 19:14:38 +03:00
|
|
|
os.chmod(dir + "gdb_run", 0o755)
|
2018-03-14 21:58:11 +03:00
|
|
|
|
2018-08-22 22:55:38 +03:00
|
|
|
with open(dir + "run", "w") as f:
|
2018-03-14 21:58:11 +03:00
|
|
|
f.write("#!/bin/bash\n")
|
|
|
|
f.write("#Run game or given command in environment\n\n")
|
|
|
|
f.write("cd \"" + os.getcwd() + "\"\n")
|
|
|
|
f.write("DEF_CMD=(")
|
|
|
|
first = True
|
|
|
|
for arg in sys.argv[2:]:
|
|
|
|
if first:
|
|
|
|
f.write("\"" + arg + "\"")
|
|
|
|
first = False
|
|
|
|
else:
|
|
|
|
f.write(" \"" + arg + "\"")
|
|
|
|
f.write(")\n")
|
|
|
|
dump_dbg_env(f)
|
2018-03-30 17:10:48 +03:00
|
|
|
if game_arch == ARCH_UNKNOWN:
|
2018-06-18 18:25:04 +03:00
|
|
|
f.write("\t\"" + wine_path + "\" start \"${@:-${DEF_CMD[@]}}\"\n")
|
2018-03-30 17:10:48 +03:00
|
|
|
else:
|
2018-06-18 18:25:04 +03:00
|
|
|
f.write("\t\"" + wine_path + "\" \"${@:-${DEF_CMD[@]}}\"\n")
|
2018-08-24 19:14:38 +03:00
|
|
|
os.chmod(dir + "run", 0o755)
|
2018-02-15 19:13:33 +03:00
|
|
|
|
2018-08-08 16:01:55 +03:00
|
|
|
def run():
|
2018-08-25 14:29:13 +03:00
|
|
|
if "PROTON_DUMP_DEBUG_COMMANDS" in env:
|
2018-08-22 22:51:45 +03:00
|
|
|
try:
|
|
|
|
dump_dbg_scripts()
|
|
|
|
except:
|
2018-08-22 22:55:38 +03:00
|
|
|
log("Unable to write debug scripts! " + str(sys.exc_info()[1]))
|
2018-08-22 22:51:45 +03:00
|
|
|
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:])
|
2018-08-08 16:01:55 +03:00
|
|
|
|
2018-08-23 14:21:22 +03:00
|
|
|
if sys.version_info[0] == 2:
|
|
|
|
binary_stdout = sys.stdout
|
|
|
|
elif sys.version_info[0] == 3:
|
|
|
|
binary_stdout = sys.stdout.buffer
|
|
|
|
else:
|
2018-08-26 23:52:05 +03:00
|
|
|
raise Exception("Unsupported python version")
|
2018-08-23 14:21:22 +03:00
|
|
|
|
2018-08-08 16:01:55 +03:00
|
|
|
#determine mode
|
|
|
|
if sys.argv[1] == "run":
|
|
|
|
#start target app
|
|
|
|
run()
|
|
|
|
elif sys.argv[1] == "waitforexitandrun":
|
|
|
|
#wait for wineserver to shut down
|
|
|
|
run_wine([bindir + "/wineserver", "-w"])
|
|
|
|
#then run
|
|
|
|
run()
|
2018-02-20 16:41:39 +03:00
|
|
|
elif sys.argv[1] == "getcompatpath":
|
|
|
|
#linux -> windows path
|
2018-02-27 20:00:55 +03:00
|
|
|
path = subprocess.check_output([wine_path, "winepath", "-w", sys.argv[2]], env=env, stderr=lfile)
|
2018-08-23 14:21:22 +03:00
|
|
|
binary_stdout.write(path)
|
2018-02-20 16:41:39 +03:00
|
|
|
elif sys.argv[1] == "getnativepath":
|
|
|
|
#windows -> linux path
|
2018-02-27 20:00:55 +03:00
|
|
|
path = subprocess.check_output([wine_path, "winepath", sys.argv[2]], env=env, stderr=lfile)
|
2018-08-23 14:21:22 +03:00
|
|
|
binary_stdout.write(path)
|
2018-02-02 23:21:35 +03:00
|
|
|
else:
|
2018-02-15 22:06:32 +03:00
|
|
|
log("Need a verb.")
|
2018-02-02 23:21:35 +03:00
|
|
|
sys.exit(1)
|
2018-01-18 23:00:48 +03:00
|
|
|
|
|
|
|
sys.exit(0)
|