Skip to content
Snippets Groups Projects
Commit f32a9730 authored by Ludovico de Nittis's avatar Ludovico de Nittis Committed by Simon McVittie
Browse files

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


When a game is launched with a custom launch option as:
"LD_LIBRARY_PATH="/my_libs:${LD_LIBRARY_PATH}" %command%"
we want to treat /my_libs as if it were part of the OS-level search
path.

Instead of overloading "SYSTEM_LD_LIBRARY_PATH", this patch introduces a
new, more appropriate, environment variable called
"PRESSURE_VESSEL_APP_LD_LIBRARY_PATH".

Please note that "PRESSURE_VESSEL_APP_LD_LIBRARY_PATH" will also contain
the system paths that are coming from `ldconfig` (added by the "run.sh"
script).

Signed-off-by: default avatarLudovico de Nittis <ludovico.denittis@collabora.com>
parent 7a962895
No related branches found
No related tags found
1 merge request!19_v2-entry-point: Support custom LD_LIBRARY_PATH from game launch options
Pipeline #5365 passed with warnings
......@@ -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%")
#
# 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment