From 3e8aebdb9b9c3ee458bbe701e735f95ee5474fc2 Mon Sep 17 00:00:00 2001 From: Arrowmaster Date: Fri, 6 Feb 2026 17:58:25 -0500 Subject: [PATCH] Upgrade Doorstop to version 4.5.0 (#1259) --- README.md | 2 +- build.cake | 2 +- doorstop/run_bepinex.sh | 55 ++++++++++++++++++++++++++++------------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 9011ef9..9b96bd3 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Unity plugin framework **[User and developer guides](https://bepinex.github.io/bepinex_docs/master/articles/index.html)** ## Used libraries -- [NeighTools/UnityDoorstop](https://github.com/NeighTools/UnityDoorstop) - 4.4.1 ([226bd1d](https://github.com/NeighTools/UnityDoorstop/commit/226bd1d7964a16c7479cc92151ee30ce4f8fc418)) +- [NeighTools/UnityDoorstop](https://github.com/NeighTools/UnityDoorstop) - 4.5.0 ([33dab9a](https://github.com/NeighTools/UnityDoorstop/commit/33dab9a6733862eb81869ff08431d9478b28784b)) - [BepInEx/HarmonyX](https://github.com/BepInEx/HarmonyX) - 2.7.0 ([2537257](https://github.com/BepInEx/HarmonyX/commit/253725768e59b0e1ea90105cdbcc4a0a477422c7)) - [MonoMod/MonoMod](https://github.com/MonoMod/MonoMod) - v21.12.13.01 ([ede81f4](https://github.com/MonoMod/MonoMod/commit/ede81f48924d58abf05359409fad740fe2b0dfb5)) - [jbevain/cecil](https://github.com/jbevain/cecil) - 0.10.4 ([98ec890](https://github.com/jbevain/cecil/commit/98ec890d44643ad88d573e97be0e120435eda732)) diff --git a/build.cake b/build.cake index b963456..db25712 100644 --- a/build.cake +++ b/build.cake @@ -4,7 +4,7 @@ #addin nuget:?package=Cake.Json&version=7.0.1 #addin nuget:?package=Newtonsoft.Json&version=13.0.3 -const string DOORSTOP_VER = "4.4.1"; +const string DOORSTOP_VER = "4.5.0"; var target = Argument("target", "Build"); var isBleedingEdge = Argument("bleeding_edge", false); diff --git a/doorstop/run_bepinex.sh b/doorstop/run_bepinex.sh index f8f2c7f..d0b44f2 100644 --- a/doorstop/run_bepinex.sh +++ b/doorstop/run_bepinex.sh @@ -60,25 +60,17 @@ corlib_dir="" ################################################################################ # Everything past this point is the actual script +set -e -# Special case: program is launched via Steam -# In that case rerun the script via their bootstrapper to ensure Steam overlay works -steam_arg_helper() { - if [ "$executable_name" != "" ] && [ "$1" != "${1%"$executable_name"}" ]; then - return 0 - elif [ "$executable_name" = "" ] && [ "$1" != "${1%.x86_64}" ]; then - return 0 - elif [ "$executable_name" = "" ] && [ "$1" != "${1%.x86}" ]; then - return 0 - else - return 1 - fi -} +# Special case: program is launched via Steam on Linux +# In that case rerun the script via their bootstrapper to delay adding Doorstop to LD_PRELOAD +# This is required until https://github.com/NeighTools/UnityDoorstop/issues/88 is resolved for a in "$@"; do if [ "$a" = "SteamLaunch" ]; then rotated=0; max=$# while [ $rotated -lt $max ]; do - if steam_arg_helper "$1"; then + # Test if argument is prefixed with the value of $PWD + if [ "$1" != "${1#"${PWD%/}/"}" ]; then to_rotate=$(($# - rotated)) set -- "$@" "$0" while [ $((to_rotate-=1)) -ge 0 ]; do @@ -92,7 +84,7 @@ for a in "$@"; do rotated=$((rotated+1)) fi done - echo "Please set executable_name to a valid name in a text editor" 1>&2 + echo "Could not determine game executable launched by Steam" 1>&2 exit 1 fi done @@ -123,7 +115,7 @@ abs_path() { echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" } -# Set executable path and the extension to use for the libdoorstop shared object +# Set executable path and the extension to use for the libdoorstop shared object as well as check whether we're running on Apple Silicon os_type="$(uname -s)" case ${os_type} in Linux*) @@ -148,6 +140,14 @@ case ${os_type} in ;; esac lib_extension="dylib" + + # CPUs for Apple Silicon are in the format "Apple M.." + cpu_type="$(sysctl -n machdep.cpu.brand_string)" + case "${cpu_type}" in + Apple*) + is_apple_silicon=1 + ;; + esac ;; *) # alright whos running games on freebsd @@ -183,6 +183,17 @@ executable_path=$(resolve_executable_path "${executable_path}") # Figure out the arch of the executable with file file_out="$(LD_PRELOAD="" file -b "${executable_path}")" case "${file_out}" in + *PE32*) + echo "The executable is a Windows executable file. You must use Wine/Proton and BepInEx for Windows with this executable." 1>&2 + echo "Uninstall BepInEx for *nix and install BepInEx for Windows instead." 1>&2 + echo "More info: https://docs.bepinex.dev/articles/advanced/steam_interop.html#protonwine" 1>&2 + exit 1 + ;; + *shell\ script*) + # Fallback for games that launch a shell script from Steam + # default to x64, change as needed + arch="x64" + ;; *64-bit*) arch="x64" ;; @@ -309,4 +320,14 @@ else export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}" fi -exec "$executable_path" "$@" +if [ -n "${is_apple_silicon}" ]; then + export ARCHPREFERENCE="arm64,x86_64" + + # We need to use arch for Apple Silicon to allow the executable to be run natively as otherwise if + # the executable is universal, supporting both x86_64 and arm64, MacOs will still run it as x86_64 + # if the parent process is running as x86. + # arch also strips the DYLD_INSERT_LIBRARIES env var so we have to pass that in manually + exec arch -e DYLD_INSERT_LIBRARIES="${DYLD_INSERT_LIBRARIES}" "$executable_path" "$@" +else + exec "$executable_path" "$@" +fi