Updated cake build script

Pinched some code from the master branch to create Unix builds
This commit is contained in:
Bepis committed 2020-11-08 21:11:07 +11:00
1 parent cea6e3a9bd
commit 28a53ea645
7 files changed
+235 -35

No files matched your search

+2 -2
View File
@@ -18,7 +18,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\il2cpp\</OutputPath>
<OutputPath>..\bin\IL2CPP\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -28,7 +28,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\il2cpp\</OutputPath>
<OutputPath>..\bin\IL2CPP\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -29,7 +29,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\net\</OutputPath>
<OutputPath>..\bin\NetLauncher\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+2 -2
View File
@@ -17,7 +17,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\bin\</OutputPath>
<OutputPath>..\bin\Unity\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -25,7 +25,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\bin\</OutputPath>
<OutputPath>..\bin\Unity\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+117 -29
View File
@@ -72,8 +72,15 @@ Task("Build")
Configuration = "Release",
Restore = true
};
buildSettings.Properties["TargetFrameworks"] = new []{ "net35" };
MSBuild("./BepInEx.sln", buildSettings);
//buildSettings.Properties["TargetFrameworks"] = new []{ "net35" };
MSBuild("./BepInEx.Unity/BepInEx.Unity.csproj", buildSettings);
//buildSettings.Properties["TargetFrameworks"] = new []{ "net452" };
MSBuild("./BepInEx.NetLauncher/BepInEx.NetLauncher.csproj", buildSettings);
//buildSettings.Properties["TargetFrameworks"] = new []{ "net472" };
MSBuild("./BepInEx.IL2CPP/BepInEx.IL2CPP.csproj", buildSettings);
})
.Finally(() =>
{
@@ -85,9 +92,11 @@ Task("Build")
}
});
const string DOORSTOP_VER = "2.12.1.0";
const string DOORSTOP_VER_WIN = "3.0.2.2";
const string DOORSTOP_VER_UNIX = "1.3.0.0";
const string MONO_VER = "2020.11.08";
const string DOORSTOP_DLL = "winhttp.dll";
Task("DownloadDoorstop")
Task("DownloadDependencies")
.Does(() =>
{
Information("Downloading Doorstop");
@@ -95,27 +104,51 @@ Task("DownloadDoorstop")
var doorstopPath = Directory("./bin/doorstop");
var doorstopX64Path = doorstopPath + File("doorstop_x64.zip");
var doorstopX86Path = doorstopPath + File("doorstop_x86.zip");
var doorstopLinuxPath = doorstopPath + File("doorstop_linux.zip");
var doorstopMacPath = doorstopPath + File("doorstop_macos.zip");
CreateDirectory(doorstopPath);
DownloadFile($"https://github.com/NeighTools/UnityDoorstop/releases/download/v{DOORSTOP_VER}/Doorstop_x64_{DOORSTOP_VER}.zip", doorstopX64Path);
DownloadFile($"https://github.com/NeighTools/UnityDoorstop/releases/download/v{DOORSTOP_VER}/Doorstop_x86_{DOORSTOP_VER}.zip", doorstopX86Path);
DownloadFile($"https://github.com/NeighTools/UnityDoorstop/releases/download/v{DOORSTOP_VER_WIN}/Doorstop_x64_{DOORSTOP_VER_WIN}.zip", doorstopX64Path);
DownloadFile($"https://github.com/NeighTools/UnityDoorstop/releases/download/v{DOORSTOP_VER_WIN}/Doorstop_x86_{DOORSTOP_VER_WIN}.zip", doorstopX86Path);
DownloadFile($"https://github.com/NeighTools/UnityDoorstop.Unix/releases/download/v{DOORSTOP_VER_UNIX}/doorstop_v{DOORSTOP_VER_UNIX}_linux.zip", doorstopLinuxPath);
DownloadFile($"https://github.com/NeighTools/UnityDoorstop.Unix/releases/download/v{DOORSTOP_VER_UNIX}/doorstop_v{DOORSTOP_VER_UNIX}_macos.zip", doorstopMacPath);
Information("Extracting Doorstop");
ZipUncompress(doorstopX86Path, doorstopPath + Directory("x86"));
ZipUncompress(doorstopX64Path, doorstopPath + Directory("x64"));
ZipUncompress(doorstopLinuxPath, doorstopPath + Directory("unix"));
ZipUncompress(doorstopMacPath, doorstopPath + Directory("unix"));
Information("Downloading Mono");
var monoPath = Directory("./bin/doorstop/mono");
var monoX64Path = doorstopPath + File("mono_x64.zip");
var monoX86Path = doorstopPath + File("mono_x86.zip");
CreateDirectory(monoPath);
DownloadFile($"https://github.com/BepInEx/mono/releases/download/{MONO_VER}/mono-x64.zip", monoX64Path);
DownloadFile($"https://github.com/BepInEx/mono/releases/download/{MONO_VER}/mono-x86.zip", monoX86Path);
Information("Extracting Mono");
ZipUncompress(monoX64Path, monoPath + Directory("x64"));
ZipUncompress(monoX86Path, monoPath + Directory("x86"));
});
Task("MakeDist")
.IsDependentOn("Build")
.IsDependentOn("DownloadDoorstop")
.IsDependentOn("DownloadDependencies")
.Does(() =>
{
var distDir = Directory("./bin/dist");
var distPatcherDir = distDir + Directory("patcher");
//var distPatcherDir = distDir + Directory("patcher");
var doorstopPath = Directory("./bin/doorstop");
CreateDirectory(distDir);
CreateDirectory(distPatcherDir);
//CreateDirectory(distPatcherDir);
var changelog = TransformText("<%commit_count%> commits since <%last_tag%>\r\n\r\nChangelog (excluding merges):\r\n<%commit_log%>")
.WithToken("commit_count", RunGit($"rev-list --count {latestTag}..HEAD"))
@@ -123,26 +156,61 @@ Task("MakeDist")
.WithToken("commit_log", RunGit($"--no-pager log --no-merges --pretty=\"format:* (%h) [%an] %s\" {latestTag}..HEAD", "\r\n"))
.ToString();
void PackageBepin(string arch)
void PackageBepin(string platform, string arch, string originDir, string doorstopConfigFile = null, bool copyMono = false)
{
var distArchDir = distDir + Directory(arch);
var doorstopArchPath = doorstopPath + Directory(arch) + File(DOORSTOP_DLL);
string platformName = platform + (arch == null ? "" : "_" + arch);
bool isUnix = arch == "unix";
Information("Creating distributions for platform \"" + platformName + "\"...");
string doorstopArchPath = null;
if (arch != null)
{
doorstopArchPath = doorstopPath + Directory(arch)
+ File(isUnix ? "*.*" : DOORSTOP_DLL);
}
var distArchDir = distDir + Directory(platformName);
var bepinDir = distArchDir + Directory("BepInEx");
var doorstopDir = distArchDir;
if (isUnix) doorstopDir += Directory("doorstop_libs");
CreateDirectory(distArchDir);
CreateDirectory(doorstopDir);
CreateDirectory(bepinDir + Directory("core"));
CreateDirectory(bepinDir + Directory("plugins"));
CreateDirectory(bepinDir + Directory("patchers"));
CopyFiles("./doorstop/*.*", distArchDir);
CopyFiles("./bin/*.*", bepinDir + Directory("core"));
CopyFileToDirectory(doorstopArchPath, distArchDir);
if (doorstopArchPath != null)
{
CopyFile("./doorstop/" + doorstopConfigFile, Directory(distArchDir) + File(isUnix ? "run_bepinex.sh" : "doorstop_config.ini"));
CopyFiles(doorstopArchPath, doorstopDir);
if (isUnix)
{
ReplaceTextInFiles($"{distArchDir}/run_bepinex.sh", "\r\n", "\n");
}
if (copyMono)
{
CopyDirectory("./bin/doorstop/mono/" + arch + "/mono", Directory(distArchDir) + Directory("mono"));
}
}
CopyFiles("./bin/" + Directory(originDir) + "/*.*", Directory(bepinDir) + Directory("core"));
FileWriteText(distArchDir + File("changelog.txt"), changelog);
}
PackageBepin("x86");
PackageBepin("x64");
CopyFileToDirectory(File("./bin/patcher/BepInEx.Patcher.exe"), distPatcherDir);
PackageBepin("UnityMono", "x86", "Unity", "doorstop_config_mono.ini");
PackageBepin("UnityMono", "x64", "Unity", "doorstop_config_mono.ini");
PackageBepin("UnityMono", "unix", "Unity", "run_bepinex.sh");
PackageBepin("UnityIL2CPP", "x86", "IL2CPP", "doorstop_config_il2cpp.ini", copyMono: true);
PackageBepin("UnityIL2CPP", "x64", "IL2CPP", "doorstop_config_il2cpp.ini", copyMono: true);
PackageBepin("NetLauncher", null, "NetLauncher");
//CopyFileToDirectory(File("./bin/patcher/BepInEx.Patcher.exe"), distPatcherDir);
});
Task("Pack")
@@ -153,11 +221,15 @@ Task("Pack")
var commitPrefix = isBleedingEdge ? $"_{currentCommitShort}_" : "_";
Information("Packing BepInEx");
ZipCompress(distDir + Directory("x86"), distDir + File($"BepInEx_x86{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("x64"), distDir + File($"BepInEx_x64{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("UnityMono_x86"), distDir + File($"BepInEx_UnityMono_x86{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("UnityMono_x64"), distDir + File($"BepInEx_UnityMono_x64{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("UnityMono_unix"), distDir + File($"BepInEx_UnityMono_unix{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("UnityIL2CPP_x86"), distDir + File($"BepInEx_UnityIL2CPP_x86{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("UnityIL2CPP_x64"), distDir + File($"BepInEx_UnityIL2CPP_x64{commitPrefix}{buildVersion}.zip"));
ZipCompress(distDir + Directory("NetLauncher"), distDir + File($"BepInEx_NetLauncher{commitPrefix}{buildVersion}.zip"));
Information("Packing BepInEx.Patcher");
ZipCompress(distDir + Directory("patcher"), distDir + File($"BepInEx_Patcher{commitPrefix}{buildVersion}.zip"));
// Information("Packing BepInEx.Patcher");
// ZipCompress(distDir + Directory("patcher"), distDir + File($"BepInEx_Patcher{commitPrefix}{buildVersion}.zip"));
if(isBleedingEdge)
{
@@ -177,17 +249,33 @@ Task("Pack")
["hash"] = currentCommit,
["artifacts"] = new Dictionary<string, object>[] {
new Dictionary<string, object> {
["file"] = $"BepInEx_x64{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx for x64 machines"
["file"] = $"BepInEx_UnityMono_x64{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx Unity Mono for Windows x64 machines"
},
new Dictionary<string, object> {
["file"] = $"BepInEx_x86{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx for x86 machines"
["file"] = $"BepInEx_UnityMono_x86{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx Unity Mono for Windows x86 machines"
},
new Dictionary<string, object> {
["file"] = $"BepInEx_Patcher{commitPrefix}{buildVersion}.zip",
["description"] = "Hardpatcher for BepInEx. IMPORTANT: USE ONLY IF DOORSTOP DOES NOT WORK FOR SOME REASON!"
}
["file"] = $"BepInEx_unix{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx Unity Mono for Unix machines with GCC (Linux, MacOS)"
},
new Dictionary<string, object> {
["file"] = $"BepInEx_UnityIL2CPP_x64{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx Unity IL2CPP for Windows x64 machines"
},
new Dictionary<string, object> {
["file"] = $"BepInEx_UnityIL2CPP_x86{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx Unity IL2CPP for Windows x86 machines"
},
new Dictionary<string, object> {
["file"] = $"BepInEx_NetLauncher{commitPrefix}{buildVersion}.zip",
["description"] = "BepInEx .NET Launcher for .NET Framework/XNA games"
},
// new Dictionary<string, object> {
// ["file"] = $"BepInEx_Patcher{commitPrefix}{buildVersion}.zip",
// ["description"] = "Hardpatcher for BepInEx. IMPORTANT: USE ONLY IF DOORSTOP DOES NOT WORK FOR SOME REASON!"
// }
}
}));
}
+12
View File
@@ -0,0 +1,12 @@
[UnityDoorstop]
# Specifies whether assembly executing is enabled
enabled=true
# Specifies the path (absolute, or relative to the game's exe) to the DLL/EXE that should be executed by Doorstop
targetAssembly=BepInEx\core\BepInEx.IL2CPP.dll
# Specifies whether Unity's output log should be redirected to <current folder>\output_log.txt
redirectOutputLog=false
[MonoBackend]
runtimeLib=mono\MonoBleedingEdge\EmbedRuntime\mono-2.0-sgen.dll
configDir=mono\MonoBleedingEdge\etc
corlibDir=mono\Managed
@@ -2,6 +2,6 @@
# Specifies whether assembly executing is enabled
enabled=true
# Specifies the path (absolute, or relative to the game's exe) to the DLL/EXE that should be executed by Doorstop
targetAssembly=BepInEx\core\BepInEx.Preloader.dll
targetAssembly=BepInEx\core\BepInEx.Unity.Preloader.dll
# Specifies whether Unity's output log should be redirected to <current folder>\output_log.txt
redirectOutputLog=false
+100
View File
@@ -0,0 +1,100 @@
#!/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.
# -------- 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="${PWD}/BepInEx/core/BepInEx.Preloader.dll"
# ----- DO NOT EDIT FROM THIS LINE FORWARD ------
# ----- (unless you know what you're doing) ------
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="${PWD}/doorstop_libs"
arch=""
executable_path=""
lib_postfix=""
os_type=`uname -s`
case $os_type in
Linux*)
executable_path="${PWD}/${executable_name}"
lib_postfix="so"
;;
Darwin*)
executable_name=`basename "${executable_name}" .app`
real_executable_name=`defaults read "${PWD}/${executable_name}.app/Contents/Info" CFBundleExecutable`
executable_path="${PWD}/${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
executable_type=`LD_PRELOAD="" file -b "${executable_path}"`;
case $executable_type in
*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}"