Upgrade Doorstop to version 4.5.0 (#1260)

This commit is contained in:
Arrowmaster authored and GitHub committed 2026-02-24 17:05:40 +01:00
1 parent 0d275a4df3
commit c0386134c6
6 files changed
+234 -182

No files matched your search

+1 -1
View File
@@ -57,7 +57,7 @@ A more comprehensive comparison list of features and compatibility is available
## Used libraries ## Used libraries
- [NeighTools/UnityDoorstop](https://github.com/NeighTools/UnityDoorstop) - v4.3.0 - [NeighTools/UnityDoorstop](https://github.com/NeighTools/UnityDoorstop) - v4.5.0
- [BepInEx/HarmonyX](https://github.com/BepInEx/HarmonyX) - v2.10.2 - [BepInEx/HarmonyX](https://github.com/BepInEx/HarmonyX) - v2.10.2
- [0x0ade/MonoMod](https://github.com/0x0ade/MonoMod) - v22.7.31.1 - [0x0ade/MonoMod](https://github.com/0x0ade/MonoMod) - v22.7.31.1
- [jbevain/cecil](https://github.com/jbevain/cecil) - v0.10.4 - [jbevain/cecil](https://github.com/jbevain/cecil) - v0.10.4
@@ -31,10 +31,6 @@ dll_search_path_override =
# If true, Mono debugger server will be enabled # If true, Mono debugger server will be enabled
debug_enabled = false debug_enabled = false
# When debug_enabled is true, this option specifies whether Doorstop should initialize the debugger server
# If you experience crashes when starting the debugger on debug UnityPlayer builds, try setting this to false
debug_start_server = true
# When debug_enabled is true, specifies the address to use for the debugger server # When debug_enabled is true, specifies the address to use for the debugger server
debug_address = 127.0.0.1:10000 debug_address = 127.0.0.1:10000
@@ -32,10 +32,6 @@ dll_search_path_override = "BepInEx\core"
# If true, Mono debugger server will be enabled # If true, Mono debugger server will be enabled
debug_enabled = false debug_enabled = false
# When debug_enabled is true, this option specifies whether Doorstop should initialize the debugger server
# If you experience crashes when starting the debugger on debug UnityPlayer builds, try setting this to false
debug_start_server = true
# When debug_enabled is true, specifies the address to use for the debugger server # When debug_enabled is true, specifies the address to use for the debugger server
debug_address = 127.0.0.1:10000 debug_address = 127.0.0.1:10000
+115 -85
View File
@@ -8,8 +8,6 @@
# 1. Via CLI: Run ./run_bepinex.sh <path to game> [doorstop arguments] [game arguments] # 1. Via CLI: Run ./run_bepinex.sh <path to game> [doorstop arguments] [game arguments]
# 2. Via config: edit the options below and run ./run.sh without any arguments # 2. Via config: edit the options below and run ./run.sh without any arguments
# 0 is false, 1 is true
# LINUX: name of Unity executable # LINUX: name of Unity executable
# MACOS: name of the .app directory # MACOS: name of the .app directory
executable_name="" executable_name=""
@@ -19,6 +17,7 @@ executable_name=""
# General Config Options # General Config Options
# Enable Doorstop? # Enable Doorstop?
# 0 is false, 1 is true
enabled="1" enabled="1"
# Path to the assembly to load and execute # Path to the assembly to load and execute
@@ -39,15 +38,12 @@ ignore_disable_switch="0"
# (e.g. mscorlib is stripped in original game) # (e.g. mscorlib is stripped in original game)
# This option causes Mono to seek mscorlib and core libraries from a different folder before Managed # This option causes Mono to seek mscorlib and core libraries from a different folder before Managed
# Original Managed folder is added as a secondary folder in the search path # Original Managed folder is added as a secondary folder in the search path
# To specify multiple paths, separate them with colons (:)
dll_search_path_override="" dll_search_path_override=""
# If 1, Mono debugger server will be enabled # If 1, Mono debugger server will be enabled
debug_enable="0" debug_enable="0"
# When debug_enabled is 1, this option specifies whether Doorstop should initialize the debugger server
# If you experience crashes when starting the debugger on debug UnityPlayer builds, try setting this to 0
debug_start_server="0"
# When debug_enabled is 1, specifies the address to use for the debugger server # When debug_enabled is 1, specifies the address to use for the debugger server
debug_address="127.0.0.1:10000" debug_address="127.0.0.1:10000"
@@ -64,43 +60,43 @@ corlib_dir="dotnet"
################################################################################ ################################################################################
# Everything past this point is the actual script # Everything past this point is the actual script
set -e
# Special case: program is launched via Steam # Special case: program is launched via Steam on Linux
# In that case rerun the script via their bootstrapper to ensure Steam overlay works # In that case rerun the script via their bootstrapper to delay adding Doorstop to LD_PRELOAD
if [ "$2" = "SteamLaunch" ]; then # This is required until https://github.com/NeighTools/UnityDoorstop/issues/88 is resolved
# Conceptually: exec "$1" "$2" "$3" "$4" "$0" "rest of $@" for a in "$@"; do
# But newer versions of Steam interleave the $1..$4 with some "--" arguments, so preserve them as well if [ "$a" = "SteamLaunch" ]; then
# Bash has array subscripting, but POSIX sh doesn't, so avoid it rotated=0; max=$#
to_rotate=4 while [ $rotated -lt $max ]; do
rotated=0 # Test if argument is prefixed with the value of $PWD
while [ $((to_rotate-=1)) -ge 0 ]; do if [ "$1" != "${1#"${PWD%/}/"}" ]; then
while [ "z$1" = "z--" ]; do to_rotate=$(($# - rotated))
set -- "$@" "$1" set -- "$@" "$0"
shift while [ $((to_rotate-=1)) -ge 0 ]; do
rotated=$((rotated+1)) set -- "$@" "$1"
shift
done
exec "$@"
else
set -- "$@" "$1"
shift
rotated=$((rotated+1))
fi
done done
set -- "$@" "$1" echo "Could not determine game executable launched by Steam" 1>&2
shift exit 1
rotated=$((rotated+1)) fi
done done
to_rotate=$(($# - rotated))
set -- "$@" "$0"
while [ $((to_rotate-=1)) -ge 0 ]; do
set -- "$@" "$1"
shift
done
exec "$@"
fi
# Handle first param being executable name # Handle first param being executable name
if [ -x "$1" ] ; then if [ -x "$1" ] ; then
executable_name="$1" executable_name="$1"
echo "Target executable: $1"
shift shift
fi fi
if [ -z "${executable_name}" ] || [ ! -x "${executable_name}" ]; then if [ -z "${executable_name}" ] || [ ! -x "${executable_name}" ]; then
echo "Please set executable_name to a valid name in a text editor or as the first command line parameter" echo "Please set executable_name to a valid name in a text editor or as the first command line parameter" 1>&2
exit 1 exit 1
fi fi
@@ -111,50 +107,56 @@ arch=""
executable_path="" executable_path=""
lib_extension="" lib_extension=""
# Set executable path and the extension to use for the libdoorstop shared object abs_path() {
# Resolve relative path to absolute from BASEDIR
if [ "$1" = "${1#/}" ]; then
set -- "${BASEDIR}/${1}"
fi
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
# 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)" os_type="$(uname -s)"
case ${os_type} in case ${os_type} in
Linux*) Linux*)
executable_path="${executable_name}" executable_path="$(abs_path "$executable_name")"
# Handle relative paths
if ! echo "$executable_path" | grep "^/.*$"; then
executable_path="${BASEDIR}/${executable_path}"
fi
lib_extension="so" lib_extension="so"
;; ;;
Darwin*) Darwin*)
real_executable_name="${executable_name}" real_executable_name="$(abs_path "$executable_name")"
# Handle relative directories
if ! echo "$real_executable_name" | grep "^/.*$"; then
real_executable_name="${BASEDIR}/${real_executable_name}"
fi
# If we're not even an actual executable, check .app Info for actual executable # If we're not even an actual executable, check .app Info for actual executable
if ! echo "$real_executable_name" | grep "^.*\.app/Contents/MacOS/.*"; then case $real_executable_name in
# Add .app to the end if not given *.app/Contents/MacOS/*)
if ! echo "$real_executable_name" | grep "^.*\.app$"; then executable_path="${executable_name}"
real_executable_name="${real_executable_name}.app" ;;
fi *)
inner_executable_name=$(defaults read "${real_executable_name}/Contents/Info" CFBundleExecutable) # Add .app to the end if not given
executable_path="${real_executable_name}/Contents/MacOS/${inner_executable_name}" if [ "$real_executable_name" = "${real_executable_name%.app}" ]; then
else real_executable_name="${real_executable_name}.app"
executable_path="${executable_name}" fi
fi inner_executable_name=$(defaults read "${real_executable_name}/Contents/Info" CFBundleExecutable)
executable_path="${real_executable_name}/Contents/MacOS/${inner_executable_name}"
;;
esac
lib_extension="dylib" 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 # alright whos running games on freebsd
echo "Unknown operating system ($(uname -s))" echo "Unknown operating system ($(uname -s))" 1>&2
echo "Make an issue at https://github.com/NeighTools/UnityDoorstop" echo "Make an issue at https://github.com/NeighTools/UnityDoorstop" 1>&2
exit 1 exit 1
;; ;;
esac esac
abs_path() {
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
_readlink() { _readlink() {
# relative links with readlink (without -f) do not preserve the path info # relative links with readlink (without -f) do not preserve the path info
ab_path="$(abs_path "$1")" ab_path="$(abs_path "$1")"
@@ -166,7 +168,6 @@ _readlink() {
echo "$link" echo "$link"
} }
resolve_executable_path () { resolve_executable_path () {
e_path="$(abs_path "$1")" e_path="$(abs_path "$1")"
@@ -176,19 +177,23 @@ resolve_executable_path () {
echo "${e_path}" echo "${e_path}"
} }
# Get absolute path of executable and show to user # Get absolute path of executable
executable_path=$(resolve_executable_path "${executable_path}") executable_path=$(resolve_executable_path "${executable_path}")
echo "${executable_path}"
# Figure out the arch of the executable with file # Figure out the arch of the executable with file
file_out="$(LD_PRELOAD="" file -b "${executable_path}")" file_out="$(LD_PRELOAD="" file -b "${executable_path}")"
case "${file_out}" in case "${file_out}" in
*PE32*) *PE32*)
echo "The executable is a Windows executable file. You must use Wine/Proton and BepInEx for Windows with this executable." 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." 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" echo "More info: https://docs.bepinex.dev/articles/advanced/steam_interop.html#protonwine" 1>&2
exit 1 exit 1
;; ;;
*shell\ script*)
# Fallback for games that launch a shell script from Steam
# default to x64, change as needed
arch="x64"
;;
*64-bit*) *64-bit*)
arch="x64" arch="x64"
;; ;;
@@ -196,10 +201,10 @@ case "${file_out}" in
arch="x86" arch="x86"
;; ;;
*) *)
echo "The executable \"${executable_path}\" is not compiled for x86 or x64 (might be ARM?)" echo "The executable \"${executable_path}\" is not compiled for x86 or x64 (might be ARM?)" 1>&2
echo "If you think this is a mistake (or would like to encourage support for other architectures)" echo "If you think this is a mistake (or would like to encourage support for other architectures)" 1>&2
echo "Please make an issue at https://github.com/NeighTools/UnityDoorstop" echo "Please make an issue at https://github.com/NeighTools/UnityDoorstop" 1>&2
echo "Got: ${file_out}" echo "Got: ${file_out}" 1>&2
exit 1 exit 1
;; ;;
esac esac
@@ -217,65 +222,81 @@ doorstop_bool() {
} }
# Read from command line # Read from command line
while :; do i=0; max=$#
while [ $i -lt $max ]; do
case "$1" in case "$1" in
--doorstop_enabled) --doorstop_enabled) # For backwards compatibility. Renamed to --doorstop-enabled
enabled="$(doorstop_bool "$2")" enabled="$(doorstop_bool "$2")"
shift shift
i=$((i+1))
;; ;;
--doorstop_target_assembly) --doorstop_target_assembly) # For backwards compatibility. Renamed to --doorstop-target-assembly
target_assembly="$2" target_assembly="$2"
shift shift
i=$((i+1))
;;
--doorstop-enabled)
enabled="$(doorstop_bool "$2")"
shift
i=$((i+1))
;;
--doorstop-target-assembly)
target_assembly="$2"
shift
i=$((i+1))
;; ;;
--doorstop-boot-config-override) --doorstop-boot-config-override)
boot_config_override="$2" boot_config_override="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-mono-dll-search-path-override) --doorstop-mono-dll-search-path-override)
dll_search_path_override="$2" dll_search_path_override="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-mono-debug-enabled) --doorstop-mono-debug-enabled)
debug_enable="$(doorstop_bool "$2")" debug_enable="$(doorstop_bool "$2")"
shift shift
;; i=$((i+1))
--doorstop-mono-debug-start-server)
debug_start_server="$(doorstop_bool "$2")"
shift
;; ;;
--doorstop-mono-debug-suspend) --doorstop-mono-debug-suspend)
debug_suspend="$(doorstop_bool "$2")" debug_suspend="$(doorstop_bool "$2")"
shift shift
i=$((i+1))
;; ;;
--doorstop-mono-debug-address) --doorstop-mono-debug-address)
debug_address="$2" debug_address="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-clr-runtime-coreclr-path) --doorstop-clr-runtime-coreclr-path)
coreclr_path="$2" coreclr_path="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-clr-corlib-dir) --doorstop-clr-corlib-dir)
corlib_dir="$2" corlib_dir="$2"
shift shift
i=$((i+1))
;; ;;
*) *)
if [ -z "$1" ]; then set -- "$@" "$1"
break
fi
rest_args="$rest_args $1"
;; ;;
esac esac
shift shift
i=$((i+1))
done done
target_assembly="$(abs_path "$target_assembly")"
# Move variables to environment # Move variables to environment
export DOORSTOP_ENABLED="$enabled" export DOORSTOP_ENABLED="$enabled"
export DOORSTOP_TARGET_ASSEMBLY="$target_assembly" export DOORSTOP_TARGET_ASSEMBLY="$target_assembly"
export DOORSTOP_BOOT_CONFIG_OVERRIDE="$boot_config_override"
export DOORSTOP_IGNORE_DISABLED_ENV="$ignore_disable_switch" export DOORSTOP_IGNORE_DISABLED_ENV="$ignore_disable_switch"
export DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE="$dll_search_path_override" export DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE="$dll_search_path_override"
export DOORSTOP_MONO_DEBUG_ENABLED="$debug_enable" export DOORSTOP_MONO_DEBUG_ENABLED="$debug_enable"
export DOORSTOP_MONO_DEBUG_START_SERVER="$debug_start_server"
export DOORSTOP_MONO_DEBUG_ADDRESS="$debug_address" export DOORSTOP_MONO_DEBUG_ADDRESS="$debug_address"
export DOORSTOP_MONO_DEBUG_SUSPEND="$debug_suspend" export DOORSTOP_MONO_DEBUG_SUSPEND="$debug_suspend"
export DOORSTOP_CLR_RUNTIME_CORECLR_PATH="$coreclr_path.$lib_extension" export DOORSTOP_CLR_RUNTIME_CORECLR_PATH="$coreclr_path.$lib_extension"
@@ -299,5 +320,14 @@ else
export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}" export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}"
fi fi
# shellcheck disable=SC2086 if [ -n "${is_apple_silicon}" ]; then
exec "$executable_path" $rest_args 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
+114 -85
View File
@@ -8,8 +8,6 @@
# 1. Via CLI: Run ./run_bepinex.sh <path to game> [doorstop arguments] [game arguments] # 1. Via CLI: Run ./run_bepinex.sh <path to game> [doorstop arguments] [game arguments]
# 2. Via config: edit the options below and run ./run.sh without any arguments # 2. Via config: edit the options below and run ./run.sh without any arguments
# 0 is false, 1 is true
# LINUX: name of Unity executable # LINUX: name of Unity executable
# MACOS: name of the .app directory # MACOS: name of the .app directory
executable_name="" executable_name=""
@@ -19,6 +17,7 @@ executable_name=""
# General Config Options # General Config Options
# Enable Doorstop? # Enable Doorstop?
# 0 is false, 1 is true
enabled="1" enabled="1"
# Path to the assembly to load and execute # Path to the assembly to load and execute
@@ -45,10 +44,6 @@ dll_search_path_override="BepInEx/core"
# If 1, Mono debugger server will be enabled # If 1, Mono debugger server will be enabled
debug_enable="0" debug_enable="0"
# When debug_enabled is 1, this option specifies whether Doorstop should initialize the debugger server
# If you experience crashes when starting the debugger on debug UnityPlayer builds, try setting this to 0
debug_start_server="0"
# When debug_enabled is 1, specifies the address to use for the debugger server # When debug_enabled is 1, specifies the address to use for the debugger server
debug_address="127.0.0.1:10000" debug_address="127.0.0.1:10000"
@@ -65,43 +60,43 @@ corlib_dir=""
################################################################################ ################################################################################
# Everything past this point is the actual script # Everything past this point is the actual script
set -e
# Special case: program is launched via Steam # Special case: program is launched via Steam on Linux
# In that case rerun the script via their bootstrapper to ensure Steam overlay works # In that case rerun the script via their bootstrapper to delay adding Doorstop to LD_PRELOAD
if [ "$2" = "SteamLaunch" ]; then # This is required until https://github.com/NeighTools/UnityDoorstop/issues/88 is resolved
# Conceptually: exec "$1" "$2" "$3" "$4" "$0" "rest of $@" for a in "$@"; do
# But newer versions of Steam interleave the $1..$4 with some "--" arguments, so preserve them as well if [ "$a" = "SteamLaunch" ]; then
# Bash has array subscripting, but POSIX sh doesn't, so avoid it rotated=0; max=$#
to_rotate=4 while [ $rotated -lt $max ]; do
rotated=0 # Test if argument is prefixed with the value of $PWD
while [ $((to_rotate-=1)) -ge 0 ]; do if [ "$1" != "${1#"${PWD%/}/"}" ]; then
while [ "z$1" = "z--" ]; do to_rotate=$(($# - rotated))
set -- "$@" "$1" set -- "$@" "$0"
shift while [ $((to_rotate-=1)) -ge 0 ]; do
rotated=$((rotated+1)) set -- "$@" "$1"
shift
done
exec "$@"
else
set -- "$@" "$1"
shift
rotated=$((rotated+1))
fi
done done
set -- "$@" "$1" echo "Could not determine game executable launched by Steam" 1>&2
shift exit 1
rotated=$((rotated+1)) fi
done done
to_rotate=$(($# - rotated))
set -- "$@" "$0"
while [ $((to_rotate-=1)) -ge 0 ]; do
set -- "$@" "$1"
shift
done
exec "$@"
fi
# Handle first param being executable name # Handle first param being executable name
if [ -x "$1" ] ; then if [ -x "$1" ] ; then
executable_name="$1" executable_name="$1"
echo "Target executable: $1"
shift shift
fi fi
if [ -z "${executable_name}" ] || [ ! -x "${executable_name}" ]; then if [ -z "${executable_name}" ] || [ ! -x "${executable_name}" ]; then
echo "Please set executable_name to a valid name in a text editor or as the first command line parameter" echo "Please set executable_name to a valid name in a text editor or as the first command line parameter" 1>&2
exit 1 exit 1
fi fi
@@ -112,50 +107,56 @@ arch=""
executable_path="" executable_path=""
lib_extension="" lib_extension=""
# Set executable path and the extension to use for the libdoorstop shared object abs_path() {
# Resolve relative path to absolute from BASEDIR
if [ "$1" = "${1#/}" ]; then
set -- "${BASEDIR}/${1}"
fi
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
# 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)" os_type="$(uname -s)"
case ${os_type} in case ${os_type} in
Linux*) Linux*)
executable_path="${executable_name}" executable_path="$(abs_path "$executable_name")"
# Handle relative paths
if ! echo "$executable_path" | grep "^/.*$"; then
executable_path="${BASEDIR}/${executable_path}"
fi
lib_extension="so" lib_extension="so"
;; ;;
Darwin*) Darwin*)
real_executable_name="${executable_name}" real_executable_name="$(abs_path "$executable_name")"
# Handle relative directories
if ! echo "$real_executable_name" | grep "^/.*$"; then
real_executable_name="${BASEDIR}/${real_executable_name}"
fi
# If we're not even an actual executable, check .app Info for actual executable # If we're not even an actual executable, check .app Info for actual executable
if ! echo "$real_executable_name" | grep "^.*\.app/Contents/MacOS/.*"; then case $real_executable_name in
# Add .app to the end if not given *.app/Contents/MacOS/*)
if ! echo "$real_executable_name" | grep "^.*\.app$"; then executable_path="${executable_name}"
real_executable_name="${real_executable_name}.app" ;;
fi *)
inner_executable_name=$(defaults read "${real_executable_name}/Contents/Info" CFBundleExecutable) # Add .app to the end if not given
executable_path="${real_executable_name}/Contents/MacOS/${inner_executable_name}" if [ "$real_executable_name" = "${real_executable_name%.app}" ]; then
else real_executable_name="${real_executable_name}.app"
executable_path="${executable_name}" fi
fi inner_executable_name=$(defaults read "${real_executable_name}/Contents/Info" CFBundleExecutable)
executable_path="${real_executable_name}/Contents/MacOS/${inner_executable_name}"
;;
esac
lib_extension="dylib" 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 # alright whos running games on freebsd
echo "Unknown operating system ($(uname -s))" echo "Unknown operating system ($(uname -s))" 1>&2
echo "Make an issue at https://github.com/NeighTools/UnityDoorstop" echo "Make an issue at https://github.com/NeighTools/UnityDoorstop" 1>&2
exit 1 exit 1
;; ;;
esac esac
abs_path() {
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
_readlink() { _readlink() {
# relative links with readlink (without -f) do not preserve the path info # relative links with readlink (without -f) do not preserve the path info
ab_path="$(abs_path "$1")" ab_path="$(abs_path "$1")"
@@ -167,7 +168,6 @@ _readlink() {
echo "$link" echo "$link"
} }
resolve_executable_path () { resolve_executable_path () {
e_path="$(abs_path "$1")" e_path="$(abs_path "$1")"
@@ -177,19 +177,23 @@ resolve_executable_path () {
echo "${e_path}" echo "${e_path}"
} }
# Get absolute path of executable and show to user # Get absolute path of executable
executable_path=$(resolve_executable_path "${executable_path}") executable_path=$(resolve_executable_path "${executable_path}")
echo "${executable_path}"
# Figure out the arch of the executable with file # Figure out the arch of the executable with file
file_out="$(LD_PRELOAD="" file -b "${executable_path}")" file_out="$(LD_PRELOAD="" file -b "${executable_path}")"
case "${file_out}" in case "${file_out}" in
*PE32*) *PE32*)
echo "The executable is a Windows executable file. You must use Wine/Proton and BepInEx for Windows with this executable." 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." 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" echo "More info: https://docs.bepinex.dev/articles/advanced/steam_interop.html#protonwine" 1>&2
exit 1 exit 1
;; ;;
*shell\ script*)
# Fallback for games that launch a shell script from Steam
# default to x64, change as needed
arch="x64"
;;
*64-bit*) *64-bit*)
arch="x64" arch="x64"
;; ;;
@@ -197,10 +201,10 @@ case "${file_out}" in
arch="x86" arch="x86"
;; ;;
*) *)
echo "The executable \"${executable_path}\" is not compiled for x86 or x64 (might be ARM?)" echo "The executable \"${executable_path}\" is not compiled for x86 or x64 (might be ARM?)" 1>&2
echo "If you think this is a mistake (or would like to encourage support for other architectures)" echo "If you think this is a mistake (or would like to encourage support for other architectures)" 1>&2
echo "Please make an issue at https://github.com/NeighTools/UnityDoorstop" echo "Please make an issue at https://github.com/NeighTools/UnityDoorstop" 1>&2
echo "Got: ${file_out}" echo "Got: ${file_out}" 1>&2
exit 1 exit 1
;; ;;
esac esac
@@ -218,65 +222,81 @@ doorstop_bool() {
} }
# Read from command line # Read from command line
while :; do i=0; max=$#
while [ $i -lt $max ]; do
case "$1" in case "$1" in
--doorstop_enabled) --doorstop_enabled) # For backwards compatibility. Renamed to --doorstop-enabled
enabled="$(doorstop_bool "$2")" enabled="$(doorstop_bool "$2")"
shift shift
i=$((i+1))
;; ;;
--doorstop_target_assembly) --doorstop_target_assembly) # For backwards compatibility. Renamed to --doorstop-target-assembly
target_assembly="$2" target_assembly="$2"
shift shift
i=$((i+1))
;;
--doorstop-enabled)
enabled="$(doorstop_bool "$2")"
shift
i=$((i+1))
;;
--doorstop-target-assembly)
target_assembly="$2"
shift
i=$((i+1))
;; ;;
--doorstop-boot-config-override) --doorstop-boot-config-override)
boot_config_override="$2" boot_config_override="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-mono-dll-search-path-override) --doorstop-mono-dll-search-path-override)
dll_search_path_override="$2" dll_search_path_override="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-mono-debug-enabled) --doorstop-mono-debug-enabled)
debug_enable="$(doorstop_bool "$2")" debug_enable="$(doorstop_bool "$2")"
shift shift
;; i=$((i+1))
--doorstop-mono-debug-start-server)
debug_start_server="$(doorstop_bool "$2")"
shift
;; ;;
--doorstop-mono-debug-suspend) --doorstop-mono-debug-suspend)
debug_suspend="$(doorstop_bool "$2")" debug_suspend="$(doorstop_bool "$2")"
shift shift
i=$((i+1))
;; ;;
--doorstop-mono-debug-address) --doorstop-mono-debug-address)
debug_address="$2" debug_address="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-clr-runtime-coreclr-path) --doorstop-clr-runtime-coreclr-path)
coreclr_path="$2" coreclr_path="$2"
shift shift
i=$((i+1))
;; ;;
--doorstop-clr-corlib-dir) --doorstop-clr-corlib-dir)
corlib_dir="$2" corlib_dir="$2"
shift shift
i=$((i+1))
;; ;;
*) *)
if [ -z "$1" ]; then set -- "$@" "$1"
break
fi
rest_args="$rest_args $1"
;; ;;
esac esac
shift shift
i=$((i+1))
done done
target_assembly="$(abs_path "$target_assembly")"
# Move variables to environment # Move variables to environment
export DOORSTOP_ENABLED="$enabled" export DOORSTOP_ENABLED="$enabled"
export DOORSTOP_TARGET_ASSEMBLY="$target_assembly" export DOORSTOP_TARGET_ASSEMBLY="$target_assembly"
export DOORSTOP_BOOT_CONFIG_OVERRIDE="$boot_config_override"
export DOORSTOP_IGNORE_DISABLED_ENV="$ignore_disable_switch" export DOORSTOP_IGNORE_DISABLED_ENV="$ignore_disable_switch"
export DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE="$dll_search_path_override" export DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE="$dll_search_path_override"
export DOORSTOP_MONO_DEBUG_ENABLED="$debug_enable" export DOORSTOP_MONO_DEBUG_ENABLED="$debug_enable"
export DOORSTOP_MONO_DEBUG_START_SERVER="$debug_start_server"
export DOORSTOP_MONO_DEBUG_ADDRESS="$debug_address" export DOORSTOP_MONO_DEBUG_ADDRESS="$debug_address"
export DOORSTOP_MONO_DEBUG_SUSPEND="$debug_suspend" export DOORSTOP_MONO_DEBUG_SUSPEND="$debug_suspend"
export DOORSTOP_CLR_RUNTIME_CORECLR_PATH="$coreclr_path.$lib_extension" export DOORSTOP_CLR_RUNTIME_CORECLR_PATH="$coreclr_path.$lib_extension"
@@ -300,5 +320,14 @@ else
export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}" export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}"
fi fi
# shellcheck disable=SC2086 if [ -n "${is_apple_silicon}" ]; then
exec "$executable_path" $rest_args 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
+4 -3
View File
@@ -32,7 +32,7 @@ public class BuildContext : FrostingContext
BleedingEdge BleedingEdge
} }
public const string DoorstopVersion = "4.3.0"; public const string DoorstopVersion = "4.5.0";
public const string DotnetRuntimeVersion = "6.0.7"; public const string DotnetRuntimeVersion = "6.0.7";
public const string DobbyVersion = "1.0.5"; public const string DobbyVersion = "1.0.5";
@@ -253,8 +253,9 @@ public sealed class MakeDistTask : FrostingTask<BuildContext>
if (dist.Engine == "Unity") if (dist.Engine == "Unity")
{ {
var doorstopPath = var doorstopPath = dist.Os == "macos"
ctx.CacheDirectory.Combine("doorstop").Combine($"doorstop_{dist.Os}").Combine(dist.Arch); ? ctx.CacheDirectory.Combine("doorstop").Combine("doorstop_macos").Combine("universal")
: ctx.CacheDirectory.Combine("doorstop").Combine($"doorstop_{dist.Os}").Combine(dist.Arch);
foreach (var filePath in ctx.GetFiles(doorstopPath.Combine($"*.{dist.DllExtension}").FullPath)) foreach (var filePath in ctx.GetFiles(doorstopPath.Combine($"*.{dist.DllExtension}").FullPath))
ctx.CopyFileToDirectory(filePath, targetDir); ctx.CopyFileToDirectory(filePath, targetDir);
ctx.CopyFileToDirectory(doorstopPath.CombineWithFilePath(".doorstop_version"), targetDir); ctx.CopyFileToDirectory(doorstopPath.CombineWithFilePath(".doorstop_version"), targetDir);