Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions dylib/feats/compat_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ NP_CONF_NAMES
BEGIN {
nkv = 0; records = 0; id = ""; code = ""; detail = ""
if (kind == "plugin") {
split("label description description_on section on off depends requires inject env overrides stage tools type choice min max step default suffix hide_crossover apps patch variants group improves needed_for", f, " ")
split("1 1 16 1 1 1 1 4 1 16 1 1 8 1 16 1 1 1 1 1 1 16 16 8 1 16 16", m, " ")
split("label description description_on section on off depends requires inject env overrides stage tools type choice min max step default suffix hide_crossover apps patch variants group improves needed_for launcher", f, " ")
split("1 1 16 1 1 1 1 4 1 16 1 1 8 1 16 1 1 1 1 1 1 16 16 8 1 16 16 1", m, " ")
split("label", req, " "); nreq = 1
} else {
split("label variant src dst build remove apps", f, " ")
Expand Down Expand Up @@ -3352,6 +3352,8 @@ stage_step="plugins"
np_feat_dylibs=""
np_feat_envs=""
np_feat_patches=""
np_feat_launcher=""
np_feat_launcher_key=""
while IFS= read -r np_feat_key; do
[ -n "$np_feat_key" ] || continue
if ! np_feat_installed "$np_feat_key"; then
Expand Down Expand Up @@ -3412,6 +3414,20 @@ while IFS= read -r np_feat_key; do
fi
fi

# A Windows program the game is started through. The first one found wins.
np_feat_exe=$(np_feat_first "$np_feat_key" launcher)
if [ -n "$np_feat_exe" ]; then
np_feat_exe=$(np_home_path "$np_feat_exe")
if [ -n "$np_feat_launcher" ]; then
np_feat_log "$np_feat_key's launcher is skipped as $np_feat_launcher_key already set one"
elif [ ! -f "$np_feat_exe" ]; then
np_feat_log "$np_feat_key's launcher is skipped as $np_feat_exe doesn't exist"
else
np_feat_launcher=$np_feat_exe
np_feat_launcher_key=$np_feat_key
fi
fi

np_feat_over=$(np_feat_first "$np_feat_key" overrides)
if [ -n "$np_feat_over" ]; then
export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:+$WINEDLLOVERRIDES;}$np_feat_over"
Expand Down Expand Up @@ -3512,6 +3528,12 @@ $np_feat_envs"
np_feat_dylibs=""
fi

# The shim starts its first argument, so the launcher gets the game and its arguments.
if [ -n "$np_feat_launcher" ] && [ "$verb" = waitforexitandrun ]; then
set -- "$np_feat_launcher" "$@"
np_feat_log "$np_feat_launcher_key starts the game through $np_feat_launcher"
fi

game_cwd="$(pwd)"
if [ -n "$STEAM_DYLD_INSERT_LIBRARIES" ]; then
echo "=== overlay injected from $STEAM_DYLD_INSERT_LIBRARIES ===" >> "$log" 2>&1 || true
Expand Down
2 changes: 1 addition & 1 deletion dylib/feats/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static const np_conf_spec_t kPlugin[] = {
{ "max", 1, 0 }, { "step", 1, 0 }, { "default", 1, 0 },
{ "suffix", 1, 0 }, { "hide_crossover", 1, 0 }, { "apps", 16, 0 },
{ "patch", 16, 0 }, { "variants", 8, 0 }, { "group", 1, 0 },
{ "improves", 16, 0 }, { "needed_for", 16, 0 },
{ "improves", 16, 0 }, { "needed_for", 16, 0 }, { "launcher", 1, 0 },
{ NULL, 0, 0 }
};

Expand Down
36 changes: 36 additions & 0 deletions dylib/tests/featstagecheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,42 @@ out=$(run np_tool_name=notproton-fex-rosetta NOTPROTON_PICKY=1 NOTPROTON_ANY=1)
ok "and does on a tool its pattern matches" "$(line "$out" 1)" \
"steamclient=n;lsteamclient=b;picky=n;any=n"

# Plugin launchers: the first one found wins.
launcher() {
# shellcheck disable=SC2016 # expanded by the inner shell
env -i PATH="$PATH" HOME="$work" np_support="$work/Library/Application Support/notproton" \
log="$work/log" WINEPREFIX="$work/pfx" "$@" \
sh -c 'set -e; . "$1/block.sh"; printf "%s|%s" "$np_feat_launcher" "$np_feat_launcher_key"' \
sh "$work"
}
printf 'exe\n' > "$work/lib/first.exe"
printf 'exe\n' > "$work/lib/second.exe"
reset
conf 10-first.conf <<EOF
[NOTPROTON_FIRST]
label = First
launcher = lib/first.exe
EOF
conf 20-second.conf <<EOF
[NOTPROTON_SECOND]
label = Second
launcher = $work/lib/second.exe
EOF
ok "a launcher is resolved from the home folder" "$(launcher NOTPROTON_FIRST=1)" \
"$work/lib/first.exe|NOTPROTON_FIRST"
ok "an absolute launcher is taken as it is" "$(launcher NOTPROTON_SECOND=1)" \
"$work/lib/second.exe|NOTPROTON_SECOND"
ok "the first file's launcher wins over a later one" \
"$(launcher NOTPROTON_FIRST=1 NOTPROTON_SECOND=1)" "$work/lib/first.exe|NOTPROTON_FIRST"
ok "a launcher switched off is not used" "$(launcher)" "|"
reset
conf 10-gone.conf <<EOF
[NOTPROTON_GONE]
label = Gone
launcher = lib/missing.exe
EOF
ok "a launcher that isn't there is skipped" "$(launcher NOTPROTON_GONE=1)" "|"

# shellcheck disable=SC2016 # expanded by the inner shell
dyld=$(env -i HOME="$work" STEAM_DYLD_INSERT_LIBRARIES=/o.dylib NOTPROTON_FEATURE_DYLIBS=/f.dylib \
sh -c 'eval "$1"; printf "%s|%s" "$DYLD_INSERT_LIBRARIES" "${NOTPROTON_OVERLAY_SHIM:+shim}"' sh "$inject")
Expand Down