PS: More robust pathing in generate-binaries (Unity 2019.3-compat)
This commit is contained in:
@@ -1,14 +1,10 @@
|
|||||||
# Copyright 2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
# Copyright 2019-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
|
||||||
# Compile all of the test items in TestSources via IL2CPP to produce the binaries necessary to run the tests
|
# Compile all of the test items in TestSources via IL2CPP to produce the binaries necessary to run the tests
|
||||||
# Requires Unity 2019.2.8f1 or later and Visual Studio 2017 (or MSBuild with C# 7+ support) or later to be installed
|
# Requires Unity 2019.2.8f1 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 Android NDK r13b or newer for Android test builds (https://developer.android.com/ndk/downloads)
|
||||||
|
|
||||||
# Path to C¤ compiler (14.0 = Visual Studio 2017, 15.0 = Visual Studio 2019 etc.)
|
|
||||||
# These are ordered from least to most preferred. If no files exist at the specified path,
|
|
||||||
# a silent exception will be thrown and the variable will not be re-assigned.
|
|
||||||
|
|
||||||
param (
|
param (
|
||||||
# Which assemblies in the TestAssemblies folder to generate binaries for with il2cpp
|
# Which assemblies in the TestAssemblies folder to generate binaries for with il2cpp
|
||||||
[string]$assemblies = "*"
|
[string]$assemblies = "*"
|
||||||
@@ -16,6 +12,10 @@ param (
|
|||||||
|
|
||||||
$ErrorActionPreference = "SilentlyContinue"
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Path to C¤ compiler (14.0 = Visual Studio 2017, 15.0 = Visual Studio 2019 etc.)
|
||||||
|
# These are ordered from least to most preferred. If no files exist at the specified path,
|
||||||
|
# a silent exception will be thrown and the variable will not be re-assigned.
|
||||||
|
|
||||||
# Look for Unity Roslyn installs
|
# Look for Unity Roslyn installs
|
||||||
$CSC = (gci "$env:ProgramFiles\Unity\Hub\Editor\*\Editor\Data\Tools\Roslyn\csc.exe" | sort FullName)[-1].FullName
|
$CSC = (gci "$env:ProgramFiles\Unity\Hub\Editor\*\Editor\Data\Tools\Roslyn\csc.exe" | sort FullName)[-1].FullName
|
||||||
# Look for .NET Framework installs
|
# Look for .NET Framework installs
|
||||||
@@ -27,47 +27,63 @@ $CSC = (gci "${env:ProgramFiles(x86)}\Microsoft Visual Studio\*\*\MSBuild\*\Bin\
|
|||||||
# The introduction of Unity Hub changed the base path of the Unity editor
|
# The introduction of Unity Hub changed the base path of the Unity editor
|
||||||
$UnityPath = (gci "$env:ProgramFiles\Unity\Hub\Editor\*\Editor\Data" | sort FullName)[-1].FullName
|
$UnityPath = (gci "$env:ProgramFiles\Unity\Hub\Editor\*\Editor\Data" | sort FullName)[-1].FullName
|
||||||
|
|
||||||
$ErrorActionPreference = "Continue"
|
# Path to il2cpp.exe
|
||||||
|
# Up to Unity 2019.2, il2cpp\build\il2cpp.exe
|
||||||
|
# From Unity 2019.3, il2cpp\build\deploy\net471\il2cpp.exe
|
||||||
|
$il2cpp = (gci "$UnityPath\il2cpp\build" -Recurse -Filter il2cpp.exe)[0].FullName
|
||||||
|
|
||||||
# Calculate Unity paths
|
# Path to mscorlib.dll
|
||||||
$il2cpp = $UnityPath + '\il2cpp\build\il2cpp.exe'
|
# Up to Unity 2019.2, Mono\lib\mono\unity\...
|
||||||
$mscorlib = $UnityPath + '\Mono\lib\mono\unity\mscorlib.dll'
|
# From Unity 2019.3, MonoBleedingEdge\lib\mono\unityaot\...
|
||||||
$AndroidPlayer = $UnityPath + '\PlaybackEngines\AndroidPlayer'
|
$mscorlib = (gci "$UnityPath\Mono*\lib\mono\unityaot\mscorlib.dll")[0].FullName
|
||||||
|
|
||||||
# Path to the Android NDK
|
# Path to the Android NDK
|
||||||
# Different Unity versions require specific NDKs, see the section Change the NDK at:
|
# Different Unity versions require specific NDKs, see the section Change the NDK at:
|
||||||
# The NDK can also be installed standalone without AndroidPlayer
|
# The NDK can also be installed standalone without AndroidPlayer
|
||||||
# https://docs.unity3d.com/2019.1/Documentation/Manual/android-sdksetup.html
|
# https://docs.unity3d.com/2019.1/Documentation/Manual/android-sdksetup.html
|
||||||
|
$AndroidPlayer = $UnityPath + '\PlaybackEngines\AndroidPlayer'
|
||||||
$AndroidNDK = $AndroidPlayer + '\NDK'
|
$AndroidNDK = $AndroidPlayer + '\NDK'
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Continue"
|
||||||
|
|
||||||
# Check that everything is installed
|
# Check that everything is installed
|
||||||
if (!$CSC) {
|
if (!$CSC) {
|
||||||
Write-Error "Could not find C¤ compiler csc.exe - aborting"
|
Write-Error "Could not find C¤ compiler csc.exe - aborting"
|
||||||
Exit
|
Exit
|
||||||
} else {
|
|
||||||
echo "Using C# compiler at '$CSC'"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$UnityPath) {
|
if (!$UnityPath) {
|
||||||
Write-Error "Could not find Unity editor - aborting"
|
Write-Error "Could not find Unity editor - aborting"
|
||||||
Exit
|
Exit
|
||||||
} else {
|
|
||||||
echo "Using Unity installation at '$UnityPath'"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(Test-Path -Path $AndroidNDK -PathType container)) {
|
if (!(Test-Path -Path $AndroidNDK -PathType container)) {
|
||||||
Write-Error "Could not find Android NDK at '$AndroidNDK' - aborting"
|
Write-Error "Could not find Android NDK at '$AndroidNDK' - aborting"
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
if (!(Test-Path -Path $il2cpp -PathType leaf)) {
|
|
||||||
|
if (!$il2cpp) {
|
||||||
Write-Error "Could not find Unity IL2CPP build support - aborting"
|
Write-Error "Could not find Unity IL2CPP build support - aborting"
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$mscorlib) {
|
||||||
|
Write-Error "Could not find Unity mscorlib assembly - aborting"
|
||||||
|
Exit
|
||||||
|
}
|
||||||
|
|
||||||
if (!(Test-Path -Path $AndroidPlayer -PathType container)) {
|
if (!(Test-Path -Path $AndroidPlayer -PathType container)) {
|
||||||
Write-Error "Could not find Unity Android build support - aborting"
|
Write-Error "Could not find Unity Android build support - aborting"
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Using C# compiler at '$CSC'"
|
||||||
|
echo "Using Unity installation at '$UnityPath'"
|
||||||
|
echo "Using IL2CPP toolchain at '$il2cpp'"
|
||||||
|
echo "Using Unity mscorlib assembly at '$mscorlib'"
|
||||||
|
echo "Using Android player at '$AndroidPlayer'"
|
||||||
|
echo "Using Android NDK at '$AndroidNDK'"
|
||||||
|
|
||||||
# Workspace paths
|
# Workspace paths
|
||||||
$src = "$PSScriptRoot/TestSources"
|
$src = "$PSScriptRoot/TestSources"
|
||||||
$asm = "$PSScriptRoot/TestAssemblies"
|
$asm = "$PSScriptRoot/TestAssemblies"
|
||||||
@@ -75,9 +91,10 @@ $bin = "$PSScriptRoot/TestBinaries"
|
|||||||
|
|
||||||
# We try to make the arguments as close as possible to a real Unity build
|
# 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)
|
# "--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)
|
||||||
$arg = '--convert-to-cpp', '--compile-cpp', '--libil2cpp-static', '--configuration=Release', `
|
$arg = '--convert-to-cpp', '--compile-cpp', '--libil2cpp-static', '--configuration=Release', `
|
||||||
'--emit-null-checks', '--enable-array-bounds-check', '--forcerebuild', `
|
'--emit-null-checks', '--enable-array-bounds-check', '--forcerebuild', `
|
||||||
'--map-file-parser=$UnityPath\il2cpp\MapFileParser\MapFileParser.exe'
|
'--map-file-parser=$UnityPath\il2cpp\MapFileParser\MapFileParser.exe', '--dotnetprofile="unityaot"'
|
||||||
|
|
||||||
# Prepare output folders
|
# Prepare output folders
|
||||||
md $asm, $bin 2>&1 >$null
|
md $asm, $bin 2>&1 >$null
|
||||||
@@ -85,6 +102,8 @@ md $asm, $bin 2>&1 >$null
|
|||||||
# Compile all .cs files in TestSources
|
# Compile all .cs files in TestSources
|
||||||
echo "Compiling source code..."
|
echo "Compiling source code..."
|
||||||
gci $src | % {
|
gci $src | % {
|
||||||
|
echo $_.BaseName
|
||||||
|
|
||||||
& $csc "/t:library" "/nologo" "/unsafe" "/out:$asm/$($_.BaseName).dll" "$src/$_"
|
& $csc "/t:library" "/nologo" "/unsafe" "/out:$asm/$($_.BaseName).dll" "$src/$_"
|
||||||
|
|
||||||
if ($LastExitCode -ne 0) {
|
if ($LastExitCode -ne 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user