mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Use latest dotnet; fix *nix scripts
This commit is contained in:
1 parent
3538abf277
commit
97998e7387
4 files changed
+542
-158
No files matched your search
+16
-13
@@ -42,7 +42,9 @@ readonly record struct Target(string Abi, string Os, string Cpu, bool NeedsRunti
|
||||
var targets = new Target[] {
|
||||
new("UnityMono", "windows", "x86"),
|
||||
new("UnityMono", "windows", "x64"),
|
||||
new("UnityMono", "unix", "any"),
|
||||
new("UnityMono", "linux", "x86"),
|
||||
new("UnityMono", "linux", "x64"),
|
||||
new("UnityMono", "macos", "x64"),
|
||||
new("UnityIL2CPP", "windows", "x86", true),
|
||||
new("UnityIL2CPP", "windows", "x64", true),
|
||||
new("UnityIL2CPP", "linux", "x86", true),
|
||||
@@ -104,8 +106,8 @@ Task("Build")
|
||||
}
|
||||
});
|
||||
|
||||
const string DOORSTOP_VER = "4.0.0-rc.2";
|
||||
const string DOTNET_MINI_VER = "2022.03.26.1";
|
||||
const string DOORSTOP_VER = "4.0.0-rc.3";
|
||||
const string DOTNET_MINI_VER = "2022.06.15.1";
|
||||
const string DOORSTOP_PROXY_DLL = "winhttp.dll";
|
||||
const string DOBBY_VER = "1.0.0";
|
||||
|
||||
@@ -143,8 +145,8 @@ Task("DownloadDependencies")
|
||||
DownloadFile($"https://github.com/NeighTools/UnityDoorstop/releases/download/v{DOORSTOP_VER}/doorstop_macos_release_{DOORSTOP_VER}.zip", doorstopZipPathMacOs);
|
||||
|
||||
ZipUncompress(doorstopZipPathWin, doorstopPath + Directory("windows"));
|
||||
ZipUncompress(doorstopZipPathLinux, doorstopPath + Directory("unix"));
|
||||
ZipUncompress(doorstopZipPathMacOs, doorstopPath + Directory("unix"));
|
||||
ZipUncompress(doorstopZipPathLinux, doorstopPath + Directory("linux"));
|
||||
ZipUncompress(doorstopZipPathMacOs, doorstopPath + Directory("macos"));
|
||||
}
|
||||
|
||||
if (NeedsRedownload("BepInEx/Dobby", DOBBY_VER)) {
|
||||
@@ -219,15 +221,13 @@ Task("MakeDist")
|
||||
ConvertableDirectoryPath? doorstopTargetDir = null;
|
||||
|
||||
if (doorstopConfigFile is not null) {
|
||||
var doorstopOs = target.IsUnix ? "unix" : target.Os;
|
||||
doorstopTargetDir = doorstopPath + Directory(doorstopOs) + Directory(target.IsUnix ? "libdoorstop" : target.Cpu);
|
||||
doorstopTargetPath = $"{doorstopTargetDir + File(target.IsUnix ? "*.*" : DOORSTOP_PROXY_DLL)}";
|
||||
doorstopTargetDir = doorstopPath + Directory(target.Os) + Directory(target.Cpu);
|
||||
doorstopTargetPath = $"{doorstopTargetDir + File(target.IsUnix ? "libdoorstop.*" : DOORSTOP_PROXY_DLL)}";
|
||||
}
|
||||
|
||||
var distTargetDir = distDir + Directory($"{target}");
|
||||
var distBepinDir = distTargetDir + Directory("BepInEx");
|
||||
var distDoorstopDir = distTargetDir;
|
||||
if (target.IsUnix) distDoorstopDir += Directory("doorstop_libs");
|
||||
|
||||
CreateDirectory(distTargetDir);
|
||||
CreateDirectory(distDoorstopDir);
|
||||
@@ -239,11 +239,10 @@ Task("MakeDist")
|
||||
CopyFile(Directory("./doorstop") + doorstopConfigFile, distTargetDir + File(target.IsUnix ? "run_bepinex.sh" : "doorstop_config.ini"));
|
||||
if (target.IsUnix) {
|
||||
CopyFiles(new GlobPattern(doorstopTargetPath), distDoorstopDir);
|
||||
MoveFile(distDoorstopDir + File(".doorstop_version"), distTargetDir + File(".doorstop_version"));
|
||||
} else {
|
||||
CopyFile(File(doorstopTargetPath), Directory(distDoorstopDir) + File(DOORSTOP_PROXY_DLL));
|
||||
CopyFile(doorstopTargetDir + File(".doorstop_version"), distDoorstopDir + File(".doorstop_version"));
|
||||
}
|
||||
CopyFile(doorstopTargetDir + File(".doorstop_version"), distDoorstopDir + File(".doorstop_version"));
|
||||
|
||||
if (target.IsUnix) {
|
||||
ReplaceTextInFiles(distTargetDir + File("run_bepinex.sh"), "\r\n", "\n");
|
||||
@@ -272,8 +271,12 @@ Task("MakeDist")
|
||||
(ConvertableDirectoryPath originDir, ConvertableFilePath? doorstopConfigFile) = (Directory(target.Abi), null);
|
||||
if (target.Abi is var abi and ("UnityIL2CPP" or "UnityMono")) {
|
||||
originDir = Directory(abi is "UnityIL2CPP" ? "IL2CPP" : "Unity");
|
||||
doorstopConfigFile = File(target.IsUnix ? "run_bepinex.sh" :
|
||||
abi is "UnityIL2CPP" ? "doorstop_config_il2cpp.ini" : "doorstop_config_mono.ini");
|
||||
// TODO: Move config file resolving to Target class
|
||||
doorstopConfigFile = File(
|
||||
target.IsUnix ?
|
||||
(abi is "UnityIL2CPP" ? "run_bepinex_il2cpp.sh" : "run_bepinex_mono.sh")
|
||||
: (abi is "UnityIL2CPP" ? "doorstop_config_il2cpp.ini" : "doorstop_config_mono.ini")
|
||||
);
|
||||
}
|
||||
PackageBepin(target, originDir, doorstopConfigFile);
|
||||
}
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
#!/bin/sh
|
||||
# BepInEx running script
|
||||
#
|
||||
# This script is used to run a Unity game with BepInEx enabled.
|
||||
#
|
||||
# Usage: Configure the script below and simply run this script when you want to run your game modded.
|
||||
a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BASEDIR=$(cd "$a"; pwd -P)
|
||||
|
||||
# -------- SETTINGS --------
|
||||
# ---- EDIT AS NEEDED ------
|
||||
|
||||
# EDIT THIS: The name of the executable to run
|
||||
# LINUX: This is the name of the Unity game executable
|
||||
# MACOS: This is the name of the game app folder, including the .app suffix
|
||||
executable_name=""
|
||||
|
||||
# The rest is automatically handled by BepInEx
|
||||
|
||||
# Whether or not to enable Doorstop. Valid values: TRUE or FALSE
|
||||
export DOORSTOP_ENABLE=TRUE
|
||||
|
||||
# What .NET assembly to execute. Valid value is a path to a .NET DLL that mono can execute.
|
||||
export DOORSTOP_INVOKE_DLL_PATH="${BASEDIR}/BepInEx/core/BepInEx.Preloader.Unity.dll"
|
||||
|
||||
# If specified, Doorstop will load core libraries from this folder instead of the normal Managed folder
|
||||
# Mainly usable to unstrip assemblies in some games
|
||||
export DOORSTOP_CORLIB_OVERRIDE_PATH=""
|
||||
|
||||
# ----- DO NOT EDIT FROM THIS LINE FORWARD ------
|
||||
# ----- (unless you know what you're doing) ------
|
||||
|
||||
# Special case: program is launched via Steam
|
||||
# In that case rerun the script via their bootstrapper to ensure Steam overlay works
|
||||
if [ "$2" = "SteamLaunch" ]; then
|
||||
"$1" "$2" "$3" "$4" "$0" "$5" "${@:6}"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -x "$1" -a ! -x "$executable_name" ]; then
|
||||
echo "Please open run.sh in a text editor and configure executable name."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
doorstop_libs="$BASEDIR/doorstop_libs"
|
||||
arch=""
|
||||
executable_path=""
|
||||
lib_postfix=""
|
||||
|
||||
os_type=$(uname -s)
|
||||
case $os_type in
|
||||
Linux*)
|
||||
executable_path="$BASEDIR/${executable_name}"
|
||||
lib_postfix="so"
|
||||
;;
|
||||
Darwin*)
|
||||
executable_name=$(basename "${executable_name}" .app)
|
||||
real_executable_name=$(defaults read "$BASEDIR/${executable_name}.app/Contents/Info" CFBundleExecutable)
|
||||
executable_path="$BASEDIR/${executable_name}.app/Contents/MacOS/${real_executable_name}"
|
||||
lib_postfix="dylib"
|
||||
;;
|
||||
*)
|
||||
echo "Cannot identify OS (got $(uname -s))!"
|
||||
echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Special case: if there is an arg, use that as executable path
|
||||
# Linux: arg is path to the executable
|
||||
# MacOS: arg is path to the .app folder which we need to resolve to the exectuable
|
||||
if [ -n "$1" ]; then
|
||||
case $os_type in
|
||||
Linux*)
|
||||
executable_path="$1"
|
||||
;;
|
||||
Darwin*)
|
||||
# Special case: allow to specify path to the executable within .app
|
||||
full_path_part=$(echo "$1" | grep "\.app/Contents/MacOS")
|
||||
if [ -z "$full_path_part" ]; then
|
||||
executable_name=$(basename "$1" .app)
|
||||
real_executable_name=$(defaults read "$1/Contents/Info" CFBundleExecutable)
|
||||
executable_path="$1/Contents/MacOS/${real_executable_name}"
|
||||
else
|
||||
executable_path="$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
abs_path() {
|
||||
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
||||
}
|
||||
|
||||
_readlink() {
|
||||
# relative links with readlink (without -f) do not preserve the path info
|
||||
ab_path="$(abs_path "$1")"
|
||||
link="$(readlink "${ab_path}")"
|
||||
case $link in
|
||||
/*);;
|
||||
*) link="$(dirname "$ab_path")/$link";;
|
||||
esac
|
||||
echo "$link"
|
||||
}
|
||||
|
||||
|
||||
resolve_executable_path () {
|
||||
e_path="$(abs_path "$1")"
|
||||
|
||||
while [ -L "${e_path}" ]; do
|
||||
e_path=$(_readlink "${e_path}");
|
||||
done
|
||||
echo "${e_path}"
|
||||
}
|
||||
|
||||
executable_path=$(resolve_executable_path "${executable_path}")
|
||||
echo "${executable_path}"
|
||||
executable_type=$(LD_PRELOAD="" file -b "${executable_path}");
|
||||
|
||||
case $executable_type in
|
||||
*PE32*)
|
||||
echo "The executable is a Windows executable file. You must use Wine/Proton and BepInEx for Windows with this executable."
|
||||
echo "Uninstall BepInEx for *nix and install BepInEx for Windows instead."
|
||||
echo "More info: https://docs.bepinex.dev/articles/advanced/steam_interop.html#protonwine"
|
||||
exit 1
|
||||
;;
|
||||
*64-bit*)
|
||||
arch="x64"
|
||||
;;
|
||||
*32-bit*|*i386*)
|
||||
arch="x86"
|
||||
;;
|
||||
*)
|
||||
echo "Cannot identify executable type (got ${executable_type})!"
|
||||
echo "Please create an issue at https://github.com/BepInEx/BepInEx/issues."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
doorstop_libname=libdoorstop_${arch}.${lib_postfix}
|
||||
export LD_LIBRARY_PATH="${doorstop_libs}":${LD_LIBRARY_PATH}
|
||||
export LD_PRELOAD=$doorstop_libname:$LD_PRELOAD
|
||||
export DYLD_LIBRARY_PATH="${doorstop_libs}"
|
||||
export DYLD_INSERT_LIBRARIES="${doorstop_libs}/$doorstop_libname"
|
||||
|
||||
"${executable_path}" "$@"
|
||||
@@ -0,0 +1,263 @@
|
||||
#!/bin/sh
|
||||
# BepInEx start script
|
||||
#
|
||||
# Run the script to start the game with BepInEx enabled
|
||||
#
|
||||
# There are two ways to use this script
|
||||
#
|
||||
# 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
|
||||
|
||||
# 0 is false, 1 is true
|
||||
|
||||
# LINUX: name of Unity executable
|
||||
# MACOS: name of the .app directory
|
||||
executable_name=""
|
||||
|
||||
# All of the below can be overriden with command line args
|
||||
|
||||
# General Config Options
|
||||
|
||||
# Enable Doorstop?
|
||||
enabled="1"
|
||||
|
||||
# Path to the assembly to load and execute
|
||||
# NOTE: The entrypoint must be of format `static void Doorstop.Entrypoint.Start()`
|
||||
target_assembly="BepInEx/core/BepInEx.IL2CPP.dll"
|
||||
|
||||
# If enabled, DOORSTOP_DISABLE env var value is ignored
|
||||
# USE THIS ONLY WHEN ASKED TO OR YOU KNOW WHAT THIS MEANS
|
||||
ignore_disable_switch="0"
|
||||
|
||||
# Mono Options
|
||||
|
||||
# Overrides default Mono DLL search path
|
||||
# Sometimes it is needed to instruct Mono to seek its assemblies from a different path
|
||||
# (e.g. mscorlib is stripped in original game)
|
||||
# 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
|
||||
dll_search_path_override=""
|
||||
|
||||
# If 1, Mono debugger server will be enabled
|
||||
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
|
||||
debug_address="127.0.0.1:10000"
|
||||
|
||||
# If 1 and debug_enabled is 1, Mono debugger server will suspend the game execution until a debugger is attached
|
||||
debug_suspend="0"
|
||||
|
||||
# CoreCLR options (IL2CPP)
|
||||
|
||||
# Path to coreclr shared library WITHOUT THE EXTENSION that contains the CoreCLR runtime
|
||||
coreclr_path="dotnet/libcoreclr"
|
||||
|
||||
# Path to the directory containing the managed core libraries for CoreCLR (mscorlib, System, etc.)
|
||||
corlib_dir="dotnet/corlib"
|
||||
|
||||
################################################################################
|
||||
# Everything past this point is the actual script
|
||||
|
||||
# Special case: program is launched via Steam
|
||||
# In that case rerun the script via their bootstrapper to ensure Steam overlay works
|
||||
if [ "$2" = "SteamLaunch" ]; then
|
||||
steam="$1 $2 $3 $4 $0 $5"
|
||||
shift 5
|
||||
$steam "$@"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Handle first param being executable name
|
||||
if [ -x "$1" ] ; then
|
||||
executable_name="$1"
|
||||
echo "Target executable: $1"
|
||||
shift
|
||||
fi
|
||||
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use POSIX-compatible way to get the directory of the executable
|
||||
a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BASEDIR=$(cd "$a" || exit; pwd -P)
|
||||
|
||||
arch=""
|
||||
executable_path=""
|
||||
lib_extension=""
|
||||
|
||||
# Set executable path and the extension to use for the libdoorstop shared object
|
||||
os_type="$(uname -s)"
|
||||
case ${os_type} in
|
||||
Linux*)
|
||||
executable_path="${executable_name}"
|
||||
# Handle relative paths
|
||||
if ! echo "$executable_path" | grep "^/.*$"; then
|
||||
executable_path="${BASEDIR}/${executable_path}"
|
||||
fi
|
||||
lib_extension="so"
|
||||
;;
|
||||
Darwin*)
|
||||
real_executable_name="${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 ! echo "$real_executable_name" | grep "^.*\.app/Contents/MacOS/.*"; then
|
||||
# Add .app to the end if not given
|
||||
if ! echo "$real_executable_name" | grep "^.*\.app$"; then
|
||||
real_executable_name="${real_executable_name}.app"
|
||||
fi
|
||||
inner_executable_name=$(defaults read "${real_executable_name}/Contents/Info" CFBundleExecutable)
|
||||
executable_path="${real_executable_name}/Contents/MacOS/${inner_executable_name}"
|
||||
else
|
||||
executable_path="${executable_name}"
|
||||
fi
|
||||
lib_extension="dylib"
|
||||
;;
|
||||
*)
|
||||
# alright whos running games on freebsd
|
||||
echo "Unknown operating system ($(uname -s))"
|
||||
echo "Make an issue at https://github.com/NeighTools/UnityDoorstop"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
abs_path() {
|
||||
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
||||
}
|
||||
|
||||
_readlink() {
|
||||
# relative links with readlink (without -f) do not preserve the path info
|
||||
ab_path="$(abs_path "$1")"
|
||||
link="$(readlink "${ab_path}")"
|
||||
case $link in
|
||||
/*);;
|
||||
*) link="$(dirname "$ab_path")/$link";;
|
||||
esac
|
||||
echo "$link"
|
||||
}
|
||||
|
||||
|
||||
resolve_executable_path () {
|
||||
e_path="$(abs_path "$1")"
|
||||
|
||||
while [ -L "${e_path}" ]; do
|
||||
e_path=$(_readlink "${e_path}");
|
||||
done
|
||||
echo "${e_path}"
|
||||
}
|
||||
|
||||
# Get absolute path of executable and show to user
|
||||
executable_path=$(resolve_executable_path "${executable_path}")
|
||||
echo "${executable_path}"
|
||||
|
||||
# Figure out the arch of the executable with file
|
||||
file_out="$(LD_PRELOAD="" file -b "${executable_path}")"
|
||||
case "${file_out}" in
|
||||
*64-bit*)
|
||||
arch="x64"
|
||||
;;
|
||||
*32-bit*)
|
||||
arch="x86"
|
||||
;;
|
||||
*)
|
||||
echo "The executable \"${executable_path}\" is not compiled for x86 or x64 (might be ARM?)"
|
||||
echo "If you think this is a mistake (or would like to encourage support for other architectures)"
|
||||
echo "Please make an issue at https://github.com/NeighTools/UnityDoorstop"
|
||||
echo "Got: ${file_out}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Helper to convert common boolean strings into just 0 and 1
|
||||
doorstop_bool() {
|
||||
case "$1" in
|
||||
TRUE|true|t|T|1|Y|y|yes)
|
||||
echo "1"
|
||||
;;
|
||||
FALSE|false|f|F|0|N|n|no)
|
||||
echo "0"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Read from command line
|
||||
while :; do
|
||||
case "$1" in
|
||||
--doorstop_enabled)
|
||||
enabled="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop_target_assembly)
|
||||
target_assembly="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-dll-search-path-override)
|
||||
dll_search_path_override="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-enabled)
|
||||
debug_enable="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-start-server)
|
||||
debug_start_server="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-suspend)
|
||||
debug_suspend="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-address)
|
||||
debug_address="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-clr-runtime-coreclr-path)
|
||||
coreclr_path="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-clr-corlib-dir)
|
||||
corlib_dir="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
break
|
||||
fi
|
||||
rest_args="$rest_args $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Move variables to environment
|
||||
export DOORSTOP_ENABLED="$enabled"
|
||||
export DOORSTOP_TARGET_ASSEMBLY="$target_assembly"
|
||||
export DOORSTOP_IGNORE_DISABLED_ENV="$ignore_disable_switch"
|
||||
export DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE="$dll_search_path_override"
|
||||
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_SUSPEND="$debug_suspend"
|
||||
export DOORSTOP_CLR_RUNTIME_CORECLR_PATH="$coreclr_path.$lib_extension"
|
||||
export DOORSTOP_CLR_CORLIB_DIR="$corlib_dir"
|
||||
|
||||
# Final setup
|
||||
doorstop_directory="${BASEDIR}/"
|
||||
doorstop_name="libdoorstop.${lib_extension}"
|
||||
|
||||
export LD_LIBRARY_PATH="${doorstop_directory}:${corlib_dir}:${LD_LIBRARY_PATH}"
|
||||
export LD_PRELOAD="${doorstop_name}:${LD_PRELOAD}"
|
||||
export DYLD_LIBRARY_PATH="${doorstop_directory}:${corlib_dir}:${DYLD_LIBRARY_PATH}"
|
||||
export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec "$executable_path" $rest_args
|
||||
@@ -0,0 +1,263 @@
|
||||
#!/bin/sh
|
||||
# BepInEx start script
|
||||
#
|
||||
# Run the script to start the game with BepInEx enabled
|
||||
#
|
||||
# There are two ways to use this script
|
||||
#
|
||||
# 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
|
||||
|
||||
# 0 is false, 1 is true
|
||||
|
||||
# LINUX: name of Unity executable
|
||||
# MACOS: name of the .app directory
|
||||
executable_name=""
|
||||
|
||||
# All of the below can be overriden with command line args
|
||||
|
||||
# General Config Options
|
||||
|
||||
# Enable Doorstop?
|
||||
enabled="1"
|
||||
|
||||
# Path to the assembly to load and execute
|
||||
# NOTE: The entrypoint must be of format `static void Doorstop.Entrypoint.Start()`
|
||||
target_assembly="BepInEx/core/BepInEx.Preloader.Unity.dll"
|
||||
|
||||
# If enabled, DOORSTOP_DISABLE env var value is ignored
|
||||
# USE THIS ONLY WHEN ASKED TO OR YOU KNOW WHAT THIS MEANS
|
||||
ignore_disable_switch="0"
|
||||
|
||||
# Mono Options
|
||||
|
||||
# Overrides default Mono DLL search path
|
||||
# Sometimes it is needed to instruct Mono to seek its assemblies from a different path
|
||||
# (e.g. mscorlib is stripped in original game)
|
||||
# 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
|
||||
dll_search_path_override=""
|
||||
|
||||
# If 1, Mono debugger server will be enabled
|
||||
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
|
||||
debug_address="127.0.0.1:10000"
|
||||
|
||||
# If 1 and debug_enabled is 1, Mono debugger server will suspend the game execution until a debugger is attached
|
||||
debug_suspend="0"
|
||||
|
||||
# CoreCLR options (IL2CPP)
|
||||
|
||||
# Path to coreclr shared library WITHOUT THE EXTENSION that contains the CoreCLR runtime
|
||||
coreclr_path=""
|
||||
|
||||
# Path to the directory containing the managed core libraries for CoreCLR (mscorlib, System, etc.)
|
||||
corlib_dir=""
|
||||
|
||||
################################################################################
|
||||
# Everything past this point is the actual script
|
||||
|
||||
# Special case: program is launched via Steam
|
||||
# In that case rerun the script via their bootstrapper to ensure Steam overlay works
|
||||
if [ "$2" = "SteamLaunch" ]; then
|
||||
steam="$1 $2 $3 $4 $0 $5"
|
||||
shift 5
|
||||
$steam "$@"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Handle first param being executable name
|
||||
if [ -x "$1" ] ; then
|
||||
executable_name="$1"
|
||||
echo "Target executable: $1"
|
||||
shift
|
||||
fi
|
||||
|
||||
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"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use POSIX-compatible way to get the directory of the executable
|
||||
a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BASEDIR=$(cd "$a" || exit; pwd -P)
|
||||
|
||||
arch=""
|
||||
executable_path=""
|
||||
lib_extension=""
|
||||
|
||||
# Set executable path and the extension to use for the libdoorstop shared object
|
||||
os_type="$(uname -s)"
|
||||
case ${os_type} in
|
||||
Linux*)
|
||||
executable_path="${executable_name}"
|
||||
# Handle relative paths
|
||||
if ! echo "$executable_path" | grep "^/.*$"; then
|
||||
executable_path="${BASEDIR}/${executable_path}"
|
||||
fi
|
||||
lib_extension="so"
|
||||
;;
|
||||
Darwin*)
|
||||
real_executable_name="${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 ! echo "$real_executable_name" | grep "^.*\.app/Contents/MacOS/.*"; then
|
||||
# Add .app to the end if not given
|
||||
if ! echo "$real_executable_name" | grep "^.*\.app$"; then
|
||||
real_executable_name="${real_executable_name}.app"
|
||||
fi
|
||||
inner_executable_name=$(defaults read "${real_executable_name}/Contents/Info" CFBundleExecutable)
|
||||
executable_path="${real_executable_name}/Contents/MacOS/${inner_executable_name}"
|
||||
else
|
||||
executable_path="${executable_name}"
|
||||
fi
|
||||
lib_extension="dylib"
|
||||
;;
|
||||
*)
|
||||
# alright whos running games on freebsd
|
||||
echo "Unknown operating system ($(uname -s))"
|
||||
echo "Make an issue at https://github.com/NeighTools/UnityDoorstop"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
abs_path() {
|
||||
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
||||
}
|
||||
|
||||
_readlink() {
|
||||
# relative links with readlink (without -f) do not preserve the path info
|
||||
ab_path="$(abs_path "$1")"
|
||||
link="$(readlink "${ab_path}")"
|
||||
case $link in
|
||||
/*);;
|
||||
*) link="$(dirname "$ab_path")/$link";;
|
||||
esac
|
||||
echo "$link"
|
||||
}
|
||||
|
||||
|
||||
resolve_executable_path () {
|
||||
e_path="$(abs_path "$1")"
|
||||
|
||||
while [ -L "${e_path}" ]; do
|
||||
e_path=$(_readlink "${e_path}");
|
||||
done
|
||||
echo "${e_path}"
|
||||
}
|
||||
|
||||
# Get absolute path of executable and show to user
|
||||
executable_path=$(resolve_executable_path "${executable_path}")
|
||||
echo "${executable_path}"
|
||||
|
||||
# Figure out the arch of the executable with file
|
||||
file_out="$(LD_PRELOAD="" file -b "${executable_path}")"
|
||||
case "${file_out}" in
|
||||
*64-bit*)
|
||||
arch="x64"
|
||||
;;
|
||||
*32-bit*)
|
||||
arch="x86"
|
||||
;;
|
||||
*)
|
||||
echo "The executable \"${executable_path}\" is not compiled for x86 or x64 (might be ARM?)"
|
||||
echo "If you think this is a mistake (or would like to encourage support for other architectures)"
|
||||
echo "Please make an issue at https://github.com/NeighTools/UnityDoorstop"
|
||||
echo "Got: ${file_out}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Helper to convert common boolean strings into just 0 and 1
|
||||
doorstop_bool() {
|
||||
case "$1" in
|
||||
TRUE|true|t|T|1|Y|y|yes)
|
||||
echo "1"
|
||||
;;
|
||||
FALSE|false|f|F|0|N|n|no)
|
||||
echo "0"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Read from command line
|
||||
while :; do
|
||||
case "$1" in
|
||||
--doorstop_enabled)
|
||||
enabled="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop_target_assembly)
|
||||
target_assembly="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-dll-search-path-override)
|
||||
dll_search_path_override="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-enabled)
|
||||
debug_enable="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-start-server)
|
||||
debug_start_server="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-suspend)
|
||||
debug_suspend="$(doorstop_bool "$2")"
|
||||
shift
|
||||
;;
|
||||
--doorstop-mono-debug-address)
|
||||
debug_address="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-clr-runtime-coreclr-path)
|
||||
coreclr_path="$2"
|
||||
shift
|
||||
;;
|
||||
--doorstop-clr-corlib-dir)
|
||||
corlib_dir="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
break
|
||||
fi
|
||||
rest_args="$rest_args $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Move variables to environment
|
||||
export DOORSTOP_ENABLED="$enabled"
|
||||
export DOORSTOP_TARGET_ASSEMBLY="$target_assembly"
|
||||
export DOORSTOP_IGNORE_DISABLED_ENV="$ignore_disable_switch"
|
||||
export DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE="$dll_search_path_override"
|
||||
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_SUSPEND="$debug_suspend"
|
||||
export DOORSTOP_CLR_RUNTIME_CORECLR_PATH="$coreclr_path.$lib_extension"
|
||||
export DOORSTOP_CLR_CORLIB_DIR="$corlib_dir"
|
||||
|
||||
# Final setup
|
||||
doorstop_directory="${BASEDIR}/"
|
||||
doorstop_name="libdoorstop.${lib_extension}"
|
||||
|
||||
export LD_LIBRARY_PATH="${doorstop_directory}:${corlib_dir}:${LD_LIBRARY_PATH}"
|
||||
export LD_PRELOAD="${doorstop_name}:${LD_PRELOAD}"
|
||||
export DYLD_LIBRARY_PATH="${doorstop_directory}:${corlib_dir}:${DYLD_LIBRARY_PATH}"
|
||||
export DYLD_INSERT_LIBRARIES="${doorstop_name}:${DYLD_INSERT_LIBRARIES}"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
exec "$executable_path" $rest_args
|
||||
Reference in new issue
Block a user