Skip to content

Commit

Permalink
Merge pull request #479 from CesiumGS/vcpkg
Browse files Browse the repository at this point in the history
Use vcpkg version of cesium-native
  • Loading branch information
j9liu authored Aug 16, 2024
2 parents 4b00429 + 772619f commit b0023d7
Show file tree
Hide file tree
Showing 50 changed files with 1,639 additions and 915 deletions.
73 changes: 53 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ jobs:
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: "d:/.ezvcpkg"
key: vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }}
restore-keys: |
vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
- name: Install Ninja
run: |
choco install -y ninja
- name: Install nasm
uses: ilammy/setup-nasm@v1.5.1
- name: Install wget
Expand All @@ -53,8 +63,8 @@ jobs:
del ./UnityHubSetup.exe
- name: Install Unity
run: |
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf" -Wait
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module android android-sdk-ndk-tools android-open-jdk-8u172-b11 universal-windows-platform uwp-il2cpp" -Wait
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2022.3.41f1 --changeset 0f988161febf" -Wait
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module android android-sdk-ndk-tools android-open-jdk-11.0.14.1+1 universal-windows-platform" -Wait
- name: Create SSH tunnel to Unity License Server
env:
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }}
Expand Down Expand Up @@ -93,6 +103,10 @@ jobs:
run: |
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
mv $ENV:GITHUB_WORKSPACE/* d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
# Disable Unity audio
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\ProjectSettings
$text="%YAML 1.1`n%TAG !u! tag:unity3d.com,2011:`n--- !u!11 &1`nAudioManager:`n m_DisableAudio: 1`n"
[IO.File]::WriteAllLines("d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset",$text)
- name: Build Reinterop
run: |
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
Expand All @@ -103,9 +117,20 @@ jobs:
mkdir -p d:\cesium\temp
# Store temp files on the D drive, which is much faster than the EBS-backed C drive.
$ENV:TEMP="d:\cesium\temp"
# We only need a release build of vcpkg dependencies
$ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE"
# Clear ANDROID_NDK_ROOT so that we use Unity's version
Remove-Item Env:ANDROID_NDK_ROOT
# Explicitly set the ezvcpkg path. Otherwise it will be `/.ezvcpkg` and the drive letter is ambiguous.
$ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg"
# Run the build
dotnet run --project Build~
cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log
dir d:\cesium\CesiumForUnityBuildProject
- name: Publish Logs
if: success() || failure() # run this step even if previous step failed
uses: actions/upload-artifact@v4
with:
name: Native Build Logs - Windows
path: d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
Expand All @@ -114,7 +139,7 @@ jobs:
path: d:\cesium\CesiumForUnityBuildProject\*.tgz
- name: Run Tests
run: |
start -FilePath "C:\Program Files\Unity\Hub\Editor\2021.3.13f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait
start -FilePath "C:\Program Files\Unity\Hub\Editor\2022.3.41f1\Editor\Unity.exe" -ArgumentList "-runTests -batchmode -projectPath d:\cesium\CesiumForUnityBuildProject -testResults d:\cesium\temp\TestResults.xml -testPlatform PlayMode -logFile d:\cesium\temp\test-log.txt" -Wait
cat d:\cesium\temp\test-log.txt
- name: Test Report
uses: kring/test-reporter@v1.6.2-kring
Expand All @@ -125,22 +150,23 @@ jobs:
reporter: dotnet-nunit
MacOS:
needs: [QuickChecks]
runs-on: macos-12
runs-on: macos-latest
# Only allow a single macOS build at a time, for Unity licensing reasons
concurrency: mac
steps:
- name: Set XCode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "14.1"
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Cache vcpkg artifacts
uses: actions/cache@v4
with:
path: "~/.ezvcpkg"
key: vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-${{ hashFiles('native~/extern/cesium-native/CMakeLists.txt', 'native~/CMakeLists.txt') }}
restore-keys: |
vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
- name: Install nasm
uses: ilammy/setup-nasm@v1.5.1
- name: Install jq
run: brew install jq
- name: Install Unity Hub
run: |
wget --quiet https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg
Expand All @@ -149,14 +175,14 @@ jobs:
sudo cp -R "./UnityHubSetup/Unity Hub.app" /Applications
hdiutil detach ./UnityHubSetup
rm ./UnityHubSetup.dmg
- name: Install Unity 2021.3.13f1
- name: Install Unity 2022.3.41f1
# This command sometimes returns exit code 130, despite actually succeeding.
continue-on-error: true
run: |
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf --architecture x86_64
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf --architecture arm64
- name: Install Unity iOS Support
run: |
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios --architecture x86_64
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture arm64
- name: Configure Unity to Use the License Server
run: |
sudo mkdir -p "/Library/Application Support/Unity/config"
Expand Down Expand Up @@ -196,19 +222,26 @@ jobs:
run: |
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
mv $GITHUB_WORKSPACE/* ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
# Disable Unity audio
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings
echo '%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!11 &1\nAudioManager:\n m_DisableAudio: 1\n' > ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset
- name: Build Reinterop
run: |
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
dotnet publish Reinterop~ -o .
- name: Build Package
run: |
# We only need a release build of vcpkg dependencies
export CESIUM_VCPKG_RELEASE_ONLY="TRUE"
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
dotnet run --project Build~
ls -l ~/cesium/CesiumForUnityBuildProject
- name: Print log
if: ${{ failure() }}
run: |
cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log
- name: Publish Logs
if: success() || failure() # run this step even if previous step failed
uses: actions/upload-artifact@v4
with:
name: Native Build Logs - macOS
path: ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
- name: Publish package artifact
if: ${{ success() }}
uses: actions/upload-artifact@v4
Expand All @@ -217,7 +250,7 @@ jobs:
path: ~/cesium/CesiumForUnityBuildProject/*.tgz
- name: Run Tests
run: |
/Applications/Unity/Hub/Editor/2021.3.13f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt
/Applications/Unity/Hub/Editor/2022.3.41f1/Unity.app/Contents/MacOS/Unity -runTests -batchmode -projectPath ~/cesium/CesiumForUnityBuildProject -testResults ~/cesium/CesiumForUnityBuildProject/TestResults.xml -testPlatform PlayMode -logFile ~/cesium/CesiumForUnityBuildProject/test-log.txt
cat ~/cesium/CesiumForUnityBuildProject/test-log.txt
ls /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml
- name: Test Report
Expand Down
6 changes: 5 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
url = https://github.com/htacg/tidy-html5.git
[submodule "native~/extern/enum-flags"]
path = native~/extern/enum-flags
url = https://github.com/grisumbras/enum-flags.git
url = https://github.com/kring/enum-flags.git
[submodule "native~/extern/swl-variant"]
path = native~/extern/swl-variant
url = https://github.com/kring/swl-variant.git
branch = exception-public-inheritance
42 changes: 36 additions & 6 deletions Build~/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ public void Run()
Directory.CreateDirectory(outputPackagePath);

Console.WriteLine("**** Modifying the csc.rsp files to write generated files to disk");
string generatedRuntimePath = Path.Combine(tempPath, "generated", "Runtime");
Directory.CreateDirectory(generatedRuntimePath);
string generatedEditorPath = Path.Combine(tempPath, "generated", "Editor");
Directory.CreateDirectory(generatedEditorPath);
string generatedRuntimeBasePath = Path.Combine(tempPath, "generated", "Runtime");
Directory.CreateDirectory(generatedRuntimeBasePath);
string generatedEditorBasePath = Path.Combine(tempPath, "generated", "Editor");
Directory.CreateDirectory(generatedEditorBasePath);

File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimePath + "\"" + Environment.NewLine, Encoding.UTF8);
File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorPath + "\"" + Environment.NewLine, Encoding.UTF8);
File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimeBasePath + "\"" + Environment.NewLine, Encoding.UTF8);
File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorBasePath + "\"" + Environment.NewLine, Encoding.UTF8);

string generatedRuntimePath = Path.Combine(generatedRuntimeBasePath, "Reinterop");
string generatedEditorPath = Path.Combine(generatedEditorBasePath, "Reinterop");

string sceneDirectory = Path.Combine(Utility.ProjectRoot, "Assets", "Scenes");
Directory.CreateDirectory(sceneDirectory);
Expand All @@ -57,6 +60,24 @@ public void Run()
}
}

// Disable Unity audio, because we don't need it and because it seems to take 10-20 minutes
// to time out on macOS on GitHub Actions every time we start up Unity.
string projectSettingsDirectory = Path.Combine(Utility.ProjectRoot, "ProjectSettings");
Directory.CreateDirectory(projectSettingsDirectory);
string audioManagerPath = Path.Combine(projectSettingsDirectory, "AudioManager.asset");
if (!File.Exists(audioManagerPath))
{
Console.WriteLine("**** Creating AudioManager.asset to disable Unity audio");
using (StreamWriter audioManager = new StreamWriter(audioManagerPath))
{
audioManager.WriteLine("%YAML 1.1");
audioManager.WriteLine("%TAG !u! tag:unity3d.com,2011:");
audioManager.WriteLine("--- !u!11 &1");
audioManager.WriteLine("AudioManager:");
audioManager.WriteLine(" m_DisableAudio: 1");
}
}

Console.WriteLine("**** Compiling C# code for the Editor");
unity.Run(new[]
{
Expand Down Expand Up @@ -110,6 +131,11 @@ public void Run()

if (OperatingSystem.IsMacOS())
{
configureArgs = configureArgs.Concat(new[]
{
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"
}).ToList();

// On macOS, we must build the native code twice, once for x86_64 and once for arm64.
// In theory we can build universal binaries, but some of our third party libraries don't
// handle this well.
Expand Down Expand Up @@ -161,6 +187,10 @@ public void Run()
Console.WriteLine("**** Adding generated files (for the UWP Player) to the package");
AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated"));

// Clean the generated code directory.
Directory.Delete(generatedRuntimePath, true);
Directory.CreateDirectory(generatedRuntimePath);

Console.WriteLine("**** Compiling for Windows Player");
unity.Run(new[]
{
Expand Down
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## ? - ?

##### Breaking Changes :mega:

- Player builds for macOS now require macOS 10.15+. Previously, 10.13+ was supported.

##### Additions :tada:

- Editor builds for macOS now target macOS 10.15+. Previously, macOS 12.7+ was required.

##### Fixes :wrench:

- Fixed a bug that could cause a crash in `CesiumIonSession` when the object was garbage collected or the AppDomain was unloaded while network requests were in progress.
- Fixed a bug that could cause `CesiumFlyToController` to unexpectedly interrupt a flight.

## v1.11.1 - 2024-08-01

##### Fixes :wrench:
Expand Down
10 changes: 10 additions & 0 deletions Editor/BuildCesiumForUnity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ private static void OnEditorCompilationFinished(object o)

public static void CompileForAndroidAndExit()
{
CompileCesiumForUnityNative.ExitAfterCompile = true;

string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
Expand All @@ -46,6 +48,8 @@ public static void CompileForAndroidAndExit()

public static void CompileForUWPAndExit()
{
CompileCesiumForUnityNative.ExitAfterCompile = true;

string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
Expand All @@ -62,6 +66,8 @@ public static void CompileForUWPAndExit()

public static void CompileForIOSAndExit()
{
CompileCesiumForUnityNative.ExitAfterCompile = true;

string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
Expand All @@ -85,6 +91,8 @@ public static void CompileForIOSAndExit()

public static void CompileForWindowsAndExit()
{
CompileCesiumForUnityNative.ExitAfterCompile = true;

string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
Expand All @@ -100,6 +108,8 @@ public static void CompileForWindowsAndExit()

public static void CompileForMacAndExit()
{
CompileCesiumForUnityNative.ExitAfterCompile = true;

string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(buildPath);
try
Expand Down
Loading

0 comments on commit b0023d7

Please sign in to comment.