PS: il2cpp.ps1 support for Unity 2017.1.0f3 - 2018.1.9f2
This commit is contained in:
@@ -2,8 +2,24 @@
|
||||
# All rights reserved.
|
||||
|
||||
# Compile the specified .cs files in TestSources to produce a .NET assembly DLL, the transpiled C++ source code and an IL2CPP binary for each
|
||||
# Requires Unity 2018.3.0f2 or later and Visual Studio 2017 (or MSBuild with C# 7+ support) or later to be installed
|
||||
# Requires Android NDK r13b or newer for Android test builds (https://developer.android.com/ndk/downloads)
|
||||
|
||||
# Requires Unity >= 2017.1.0f3 or later and Visual Studio 2017+ (or MSBuild with C# 7+ support or later)
|
||||
# Requires Windows Standalone IL2CPP support, Android IL2CPP support (optional)
|
||||
# Requires Android NDK for Android test builds (https://developer.android.com/ndk/downloads)
|
||||
|
||||
# Tested with Unity 2017.1.0f3 - 2020.2.0b1
|
||||
|
||||
# WARNING: The following IL2CPP versions will NOT compile correctly with the VS 2019 C++ build tools installed (use the VS 2017 C++ build tools instead):
|
||||
# 5.5.5f1, 5.5.6f1, 5.6.2f1-5.6.7f1, 2017.1.0f3-2017.4.16f1, 2018.1.0f2-2018.2.18f1
|
||||
|
||||
# Expected error when using VS 2019 C++ build tools for the above versions:
|
||||
# Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: Locale.cpp
|
||||
# ...\il2cpp\libil2cpp\os\Win32\Locale.cpp(40): error C2065: 'LC_ALL': undeclared identifier
|
||||
# ...\il2cpp\libil2cpp\os\Win32\Locale.cpp(40): error C3861: '_create_locale': identifier not found
|
||||
# ...\il2cpp\libil2cpp\os\Win32\Locale.cpp(47): error C3861: '_free_locale': identifier not found
|
||||
|
||||
# Tip: To compile a chosen source file for every installed version of Unity, try:
|
||||
# gci $env:ProgramFiles\Unity\Hub\Editor | % { ./il2cpp.ps1 <source-file-without-extension> $_.Name }
|
||||
|
||||
param (
|
||||
# Which source files in TestSources to generate aseemblies, C++ and IL2CPP binaries for
|
||||
@@ -13,6 +29,10 @@ param (
|
||||
[string] $unityVersion = "*"
|
||||
)
|
||||
|
||||
echo "Universal IL2CPP Build Utility"
|
||||
echo "(c) 2019-2020 Katy Coe - www.djkaty.com - www.github.com/djkaty"
|
||||
echo ""
|
||||
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
||||
# Function to compare two Unity versions
|
||||
@@ -71,14 +91,17 @@ $il2cpp = (gci "$UnityPath\il2cpp\build" -Recurse -Filter il2cpp.exe)[0].FullNam
|
||||
# Path to bytecode stripper
|
||||
$stripper = (gci "$UnityPath\il2cpp\build" -Recurse -Filter UnityLinker.exe)[0].FullName
|
||||
|
||||
# Path to mscorlib.dll
|
||||
# For Unity <= 2018.1.9f2, Mono\lib\mono\2.0\...
|
||||
# For Unity >= 2018.2.0f2, MonoBleedingEdge\lib\mono\unityaot\...
|
||||
$mscorlib = (gci "$UnityPath\Mono*\lib\mono\unityaot\mscorlib.dll")[0].FullName
|
||||
|
||||
# Determine the actual Unity version
|
||||
$actualUnityVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$UnityFolder\Editor\Unity.exe").FileVersion
|
||||
|
||||
# Path to mscorlib.dll
|
||||
# For Unity <= 2018.1.9f2, Mono\lib\mono\2.0\... (but also has the MonoBleedingEdge path which is incompatible)
|
||||
# For Unity >= 2018.2.0f2, MonoBleedingEdge\lib\mono\unityaot\... (but some also have the mono path which is incompatible)
|
||||
$mscorlib = "$UnityPath\Mono\lib\mono\2.0\mscorlib.dll"
|
||||
if ((Compare-UnityVersions $actualUnityVersion 2018.2.0) -ge 0) {
|
||||
$mscorlib = "$UnityPath\MonoBleedingEdge\lib\mono\unityaot\mscorlib.dll"
|
||||
}
|
||||
|
||||
# For Unity >= 2020.1.0f1, we need baselib
|
||||
if ($actualUnityVersion -and (Compare-UnityVersions $actualUnityVersion 2020.1.0) -ge 0) {
|
||||
$baselibX64 = $UnityPath + '\PlaybackEngines\windowsstandalonesupport\Variations\win64_nondevelopment_il2cpp'
|
||||
@@ -161,6 +184,7 @@ if ($AndroidBuildEnabled) {
|
||||
}
|
||||
|
||||
echo "Targeted Unity version: $actualUnityVersion"
|
||||
echo ""
|
||||
|
||||
# Workspace paths
|
||||
$src = "$PSScriptRoot/TestSources"
|
||||
@@ -171,11 +195,15 @@ $bin = "$PSScriptRoot/TestBinaries"
|
||||
# We try to make the arguments as close as possible to a real Unity build
|
||||
# "--lump-runtime-library" was added to reduce the number of C++ files generated by UnityEngine (Unity 2019)
|
||||
# "--disable-runtime-lumping" replaced the above (Unity 2019.3)
|
||||
$cppArg = '--convert-to-cpp', '-emit-null-checks', '--enable-array-bounds-check', '--dotnetprofile="unityaot"'
|
||||
$cppArg = '--convert-to-cpp', '-emit-null-checks', '--enable-array-bounds-check'
|
||||
|
||||
$compileArg = '--compile-cpp', '--libil2cpp-static', '--configuration=Release', `
|
||||
'--map-file-parser=$UnityPath\il2cpp\MapFileParser\MapFileParser.exe', '--dotnetprofile="unityaot"', `
|
||||
'--forcerebuild'
|
||||
'--map-file-parser=$UnityPath\il2cpp\MapFileParser\MapFileParser.exe', '--forcerebuild'
|
||||
|
||||
if ((Compare-UnityVersions $actualUnityVersion 2018.2.0f2) -ge 0) {
|
||||
$cppArg += '--dotnetprofile="unityaot"'
|
||||
$compileArg += '--dotnetprofile="unityaot"'
|
||||
}
|
||||
|
||||
# Prepare output folders
|
||||
md $asm, $bin 2>&1 >$null
|
||||
@@ -198,13 +226,16 @@ gci "$src/*" -Include $cs | % {
|
||||
# Strip each assembly of unnecessary code to reduce compile time
|
||||
$dll = $assemblies | % {"$_.dll"}
|
||||
|
||||
if ((Compare-UnityVersions $actualUnityVersion 2018.2.0f2) -ge 0) {
|
||||
$stripperAdditionalArguments = "--dotnetruntime=il2cpp", "--dotnetprofile=unityaot", "--use-editor-options"
|
||||
}
|
||||
|
||||
gci "$asm/*" -Include $dll | % {
|
||||
$name = $_.Name
|
||||
echo "Running bytecode stripper on $name..."
|
||||
|
||||
& $stripper "--out=$asm/$($_.BaseName)-stripped", "--i18n=none", "--core-action=link", `
|
||||
"--include-assembly=$_,$mscorlib", "--dotnetruntime=il2cpp", "--dotnetprofile=unityaot", `
|
||||
"--use-editor-options"
|
||||
"--include-assembly=$_,$mscorlib" $stripperAdditionalArguments
|
||||
}
|
||||
|
||||
# Transpile all of the DLLs to C++
|
||||
@@ -213,7 +244,7 @@ gci "$asm/*" -Include $dll | % {
|
||||
$name = $_.BaseName
|
||||
echo "Converting assembly $($_.Name) to C++..."
|
||||
rm -Force -Recurse $cpp/$name 2>&1 >$null
|
||||
& $il2cpp $cppArg "--generatedcppdir=$cpp/$name", "--assembly=$asm/$($_.BaseName)-stripped/$($_.Name)" >$null
|
||||
& $il2cpp $cppArg "--generatedcppdir=$cpp/$name", "--assembly=$asm/$($_.BaseName)-stripped/$($_.Name)", "--copy-level=None" >$null
|
||||
}
|
||||
|
||||
# Run IL2CPP on all generated assemblies for both x86 and ARM
|
||||
|
||||
Reference in New Issue
Block a user