From d8756ba78851b8b9681f985c757175fa41b9bb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathis=20Dr=C3=B6ge?= Date: Fri, 30 Sep 2022 01:08:03 +0200 Subject: [PATCH] Set some more Wine-related env vars when launching with built-in libraries --- src/backend/launcher.ts | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts index 3921ff794f..f1bbd38c27 100644 --- a/src/backend/launcher.ts +++ b/src/backend/launcher.ts @@ -330,20 +330,37 @@ function setupWineEnvVars(gameSettings: GameSettings, gameId = '0') { } } if (!gameSettings.preferSystemLibs && wineVersion.type === 'wine') { - if (wineVersion.lib32 && wineVersion.lib) { + // https://github.com/ValveSoftware/Proton/blob/4221d9ef07cc38209ff93dbbbca9473581a38255/proton#L1091-L1093 + if (!process.env.ORIG_LD_LIBRARY_PATH) { + ret.ORIG_LD_LIBRARY_PATH = process.env.LD_LIBRARY_PATH ?? '' + } + + const { lib32, lib } = wineVersion + if (lib32 && lib) { // append wine libs at the beginning - ret.LD_LIBRARY_PATH = [ - wineVersion.lib32, - wineVersion.lib, - process.env.LD_LIBRARY_PATH - ] + ret.LD_LIBRARY_PATH = [lib, lib32, process.env.LD_LIBRARY_PATH] .filter(Boolean) .join(':') + + // https://github.com/ValveSoftware/Proton/blob/4221d9ef07cc38209ff93dbbbca9473581a38255/proton#L1099 + // NOTE: Proton does not make sure that these folders exist first, I believe we should :^) + const gstp_path_lib64 = join(lib, 'gstreamer-1.0') + const gstp_path_lib32 = join(lib32, 'gstreamer-1.0') + if (existsSync(gstp_path_lib64) && existsSync(gstp_path_lib32)) { + ret.GST_PLUGIN_SYSTEM_PATH_1_0 = gstp_path_lib64 + ':' + gstp_path_lib32 + } + + // https://github.com/ValveSoftware/Proton/blob/4221d9ef07cc38209ff93dbbbca9473581a38255/proton#L1097 + const winedll_path_lib64 = join(lib, 'wine') + const winedll_path_lib32 = join(lib32, 'wine') + if (existsSync(winedll_path_lib64) && existsSync(winedll_path_lib32)) { + ret.WINEDLLPATH = winedll_path_lib64 + ':' + winedll_path_lib32 + } } else { logError( [ `Couldn't find all library folders of ${wineVersion.name}!`, - `Missing ${wineVersion.lib32} or ${wineVersion.lib}!`, + `Missing ${lib32} and/or ${lib}!`, `Falling back to system libraries!` ].join('\n') )