Skip to content
Snippets Groups Projects

_v2-entry-point: Support custom LD_LIBRARY_PATH from game launch options

Merged Ludovico de Nittis requested to merge wip/denittis/t24167 into master
Files
2
+ 43
0
@@ -142,6 +142,49 @@ if [ -z "${STEAM_COMPAT_SESSION_ID-}" ]; then
is_main=yes
fi
# At this point $LD_LIBRARY_PATH might
# 1. be equal to $STEAM_RUNTIME_LIBRARY_PATH (e.g. a game without
# any special launch options).
# 2. contain all the entries of $STEAM_RUNTIME_LIBRARY_PATH, plus eventually
# any additional paths from the game launch options (e.g. a game launched
# with "LD_LIBRARY_PATH=/my_game_path:${LD_LIBRARY_PATH} %command%")
# 3. contain just new entries from the game launch options (e.g. a game
# launched with "LD_LIBRARY_PATH=/my_game_path %command%")
# 4. being unset or empty (e.g. a game launched with
# "LD_LIBRARY_PATH="" %command%")
if [[ -n "${LD_LIBRARY_PATH-}" ]]; then
# This is the first scenario. In this case we leave
# $PRESSURE_VESSEL_APP_LD_LIBRARY_PATH set to $SYSTEM_LD_LIBRARY_PATH.
if [[ "${LD_LIBRARY_PATH}" == "${STEAM_RUNTIME_LIBRARY_PATH-}" ]]; then
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH=${SYSTEM_LD_LIBRARY_PATH-}
else
# Remove the $SYSTEM_LD_LIBRARY_PATH paths that are present in
# $STEAM_RUNTIME_LIBRARY_PATH
runtime_paths=$("${here}/remove-duplicated-paths" \
"${STEAM_RUNTIME_LIBRARY_PATH-}" \
"${SYSTEM_LD_LIBRARY_PATH-}")
# Extract all the new paths that have been set from the game launch
# options
resulting_paths=$("${here}/remove-duplicated-paths" \
"${LD_LIBRARY_PATH}" \
"${runtime_paths-}")
# If $resulting_paths is empty, this means that the game launch options
# didn't change the $LD_LIBRARY_PATH
if [[ -n "${resulting_paths-}" ]]; then
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH=${resulting_paths}
else
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH=${SYSTEM_LD_LIBRARY_PATH-}
fi
fi
else
# If $LD_LIBRARY_PATH is unset or empty, this is the fourth scenario. In
# this case we set $PRESSURE_VESSEL_APP_LD_LIBRARY_PATH to an empty value.
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH=""
fi
unset LD_LIBRARY_PATH
unset STEAM_RUNTIME
Loading