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
1 unresolved thread
Files
2
+ 32
32
@@ -152,38 +152,38 @@ fi
# 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
#
# We extract all the entries from $LD_LIBRARY_PATH that are not under the
# $STEAM_RUNTIME paths. In this way we should end up with a list of paths
# that are from the system $LD_LIBRARY_PATH, the system "ldconfig" and the
# manually set $LD_LIBRARY_PATH paths from the game launch options.
case "${STEAM_RUNTIME-}" in
(/*)
oldIFS="$IFS"
IFS=:
paths=
for path in ${LD_LIBRARY_PATH-}; do
if [ "${path}" == "${STEAM_RUNTIME}" ]; then
# path is exactly the ${STEAM_RUNTIME}; ignore
continue
elif [ "${path#${STEAM_RUNTIME}/}" != "${path}" ]; then
# path is ${STEAM_RUNTIME}/...; ignore
continue
else
# keep it (note that we discard the extra leading ":" later)
paths="${paths}:${path}"
fi
done
IFS="$oldIFS"
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH="${paths#:}"
;;
(*)
# use LD_LIBRARY_PATH as-is
export PRESSURE_VESSEL_APP_LD_LIBRARY_PATH="${LD_LIBRARY_PATH-}"
;;
esac
unset LD_LIBRARY_PATH
unset STEAM_RUNTIME
Loading