Skip to content

Commit b0023d7

Browse files
authored
Merge pull request #479 from CesiumGS/vcpkg
Use vcpkg version of cesium-native
2 parents 4b00429 + 772619f commit b0023d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1639
-915
lines changed

.github/workflows/build.yml

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ jobs:
4141
uses: actions/checkout@v4
4242
with:
4343
submodules: recursive
44+
- name: Cache vcpkg artifacts
45+
uses: actions/cache@v4
46+
with:
47+
path: "d:/.ezvcpkg"
48+
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') }}
49+
restore-keys: |
50+
vcpkg-windows-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
51+
- name: Install Ninja
52+
run: |
53+
choco install -y ninja
4454
- name: Install nasm
4555
uses: ilammy/setup-nasm@v1.5.1
4656
- name: Install wget
@@ -53,8 +63,8 @@ jobs:
5363
del ./UnityHubSetup.exe
5464
- name: Install Unity
5565
run: |
56-
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf" -Wait
57-
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
66+
Start-Process -FilePath "C:/Program Files/Unity Hub/Unity Hub.exe" -Args "-- --headless install --version 2022.3.41f1 --changeset 0f988161febf" -Wait
67+
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
5868
- name: Create SSH tunnel to Unity License Server
5969
env:
6070
UNITY_LICENSE_SERVER_SSH_KEY: ${{ secrets.UNITY_LICENSE_SERVER_SSH_KEY }}
@@ -93,6 +103,10 @@ jobs:
93103
run: |
94104
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
95105
mv $ENV:GITHUB_WORKSPACE/* d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
106+
# Disable Unity audio
107+
mkdir -p d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\ProjectSettings
108+
$text="%YAML 1.1`n%TAG !u! tag:unity3d.com,2011:`n--- !u!11 &1`nAudioManager:`n m_DisableAudio: 1`n"
109+
[IO.File]::WriteAllLines("d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings/AudioManager.asset",$text)
96110
- name: Build Reinterop
97111
run: |
98112
cd d:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity
@@ -103,9 +117,20 @@ jobs:
103117
mkdir -p d:\cesium\temp
104118
# Store temp files on the D drive, which is much faster than the EBS-backed C drive.
105119
$ENV:TEMP="d:\cesium\temp"
120+
# We only need a release build of vcpkg dependencies
121+
$ENV:CESIUM_VCPKG_RELEASE_ONLY="TRUE"
122+
# Clear ANDROID_NDK_ROOT so that we use Unity's version
123+
Remove-Item Env:ANDROID_NDK_ROOT
124+
# Explicitly set the ezvcpkg path. Otherwise it will be `/.ezvcpkg` and the drive letter is ambiguous.
125+
$ENV:EZVCPKG_BASEDIR="D:/.ezvcpkg"
126+
# Run the build
106127
dotnet run --project Build~
107-
cat D:\cesium\CesiumForUnityBuildProject\Packages\com.cesium.unity\native~\build-WSA-x86_64\build.log
108-
dir d:\cesium\CesiumForUnityBuildProject
128+
- name: Publish Logs
129+
if: success() || failure() # run this step even if previous step failed
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: Native Build Logs - Windows
133+
path: d:/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
109134
- name: Publish package artifact
110135
if: ${{ success() }}
111136
uses: actions/upload-artifact@v4
@@ -114,7 +139,7 @@ jobs:
114139
path: d:\cesium\CesiumForUnityBuildProject\*.tgz
115140
- name: Run Tests
116141
run: |
117-
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
142+
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
118143
cat d:\cesium\temp\test-log.txt
119144
- name: Test Report
120145
uses: kring/test-reporter@v1.6.2-kring
@@ -125,22 +150,23 @@ jobs:
125150
reporter: dotnet-nunit
126151
MacOS:
127152
needs: [QuickChecks]
128-
runs-on: macos-12
153+
runs-on: macos-latest
129154
# Only allow a single macOS build at a time, for Unity licensing reasons
130155
concurrency: mac
131156
steps:
132-
- name: Set XCode version
133-
uses: maxim-lobanov/setup-xcode@v1
134-
with:
135-
xcode-version: "14.1"
136157
- name: Check out repository code
137158
uses: actions/checkout@v4
138159
with:
139160
submodules: recursive
161+
- name: Cache vcpkg artifacts
162+
uses: actions/cache@v4
163+
with:
164+
path: "~/.ezvcpkg"
165+
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') }}
166+
restore-keys: |
167+
vcpkg-mac-${{ hashFiles('native~/vcpkg/ports/**/vcpkg.json', 'native~/vcpkg/triplets/**/*', 'native~/extern/*toolchain.cmake') }}-
140168
- name: Install nasm
141169
uses: ilammy/setup-nasm@v1.5.1
142-
- name: Install jq
143-
run: brew install jq
144170
- name: Install Unity Hub
145171
run: |
146172
wget --quiet https://public-cdn.cloud.unity3d.com/hub/prod/UnityHubSetup.dmg
@@ -149,14 +175,14 @@ jobs:
149175
sudo cp -R "./UnityHubSetup/Unity Hub.app" /Applications
150176
hdiutil detach ./UnityHubSetup
151177
rm ./UnityHubSetup.dmg
152-
- name: Install Unity 2021.3.13f1
178+
- name: Install Unity 2022.3.41f1
153179
# This command sometimes returns exit code 130, despite actually succeeding.
154180
continue-on-error: true
155181
run: |
156-
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2021.3.13f1 --changeset 9e7d58001ecf --architecture x86_64
182+
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install --version 2022.3.41f1 --changeset 0f988161febf --architecture arm64
157183
- name: Install Unity iOS Support
158184
run: |
159-
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2021.3.13f1 --changeset 9e7d58001ecf --module ios --architecture x86_64
185+
/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub -- --headless install-modules --version 2022.3.41f1 --changeset 0f988161febf --module ios --architecture arm64
160186
- name: Configure Unity to Use the License Server
161187
run: |
162188
sudo mkdir -p "/Library/Application Support/Unity/config"
@@ -196,19 +222,26 @@ jobs:
196222
run: |
197223
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
198224
mv $GITHUB_WORKSPACE/* ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
225+
# Disable Unity audio
226+
mkdir -p ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/ProjectSettings
227+
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
199228
- name: Build Reinterop
200229
run: |
201230
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
202231
dotnet publish Reinterop~ -o .
203232
- name: Build Package
204233
run: |
234+
# We only need a release build of vcpkg dependencies
235+
export CESIUM_VCPKG_RELEASE_ONLY="TRUE"
205236
cd ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity
206237
dotnet run --project Build~
207238
ls -l ~/cesium/CesiumForUnityBuildProject
208-
- name: Print log
209-
if: ${{ failure() }}
210-
run: |
211-
cat /Users/runner/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-iOS/build.log
239+
- name: Publish Logs
240+
if: success() || failure() # run this step even if previous step failed
241+
uses: actions/upload-artifact@v4
242+
with:
243+
name: Native Build Logs - macOS
244+
path: ~/cesium/CesiumForUnityBuildProject/Packages/com.cesium.unity/native~/build-*/build.log
212245
- name: Publish package artifact
213246
if: ${{ success() }}
214247
uses: actions/upload-artifact@v4
@@ -217,7 +250,7 @@ jobs:
217250
path: ~/cesium/CesiumForUnityBuildProject/*.tgz
218251
- name: Run Tests
219252
run: |
220-
/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
253+
/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
221254
cat ~/cesium/CesiumForUnityBuildProject/test-log.txt
222255
ls /Users/runner/cesium/CesiumForUnityBuildProject/TestResults.xml
223256
- name: Test Report

.gitmodules

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
url = https://github.com/htacg/tidy-html5.git
77
[submodule "native~/extern/enum-flags"]
88
path = native~/extern/enum-flags
9-
url = https://github.com/grisumbras/enum-flags.git
9+
url = https://github.com/kring/enum-flags.git
10+
[submodule "native~/extern/swl-variant"]
11+
path = native~/extern/swl-variant
12+
url = https://github.com/kring/swl-variant.git
13+
branch = exception-public-inheritance

Build~/Package.cs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ public void Run()
3636
Directory.CreateDirectory(outputPackagePath);
3737

3838
Console.WriteLine("**** Modifying the csc.rsp files to write generated files to disk");
39-
string generatedRuntimePath = Path.Combine(tempPath, "generated", "Runtime");
40-
Directory.CreateDirectory(generatedRuntimePath);
41-
string generatedEditorPath = Path.Combine(tempPath, "generated", "Editor");
42-
Directory.CreateDirectory(generatedEditorPath);
39+
string generatedRuntimeBasePath = Path.Combine(tempPath, "generated", "Runtime");
40+
Directory.CreateDirectory(generatedRuntimeBasePath);
41+
string generatedEditorBasePath = Path.Combine(tempPath, "generated", "Editor");
42+
Directory.CreateDirectory(generatedEditorBasePath);
4343

44-
File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimePath + "\"" + Environment.NewLine, Encoding.UTF8);
45-
File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorPath + "\"" + Environment.NewLine, Encoding.UTF8);
44+
File.AppendAllText(runtimeCscRspPath, "-generatedfilesout:\"" + generatedRuntimeBasePath + "\"" + Environment.NewLine, Encoding.UTF8);
45+
File.AppendAllText(editorCscRspPath, "-generatedfilesout:\"" + generatedEditorBasePath + "\"" + Environment.NewLine, Encoding.UTF8);
46+
47+
string generatedRuntimePath = Path.Combine(generatedRuntimeBasePath, "Reinterop");
48+
string generatedEditorPath = Path.Combine(generatedEditorBasePath, "Reinterop");
4649

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

63+
// Disable Unity audio, because we don't need it and because it seems to take 10-20 minutes
64+
// to time out on macOS on GitHub Actions every time we start up Unity.
65+
string projectSettingsDirectory = Path.Combine(Utility.ProjectRoot, "ProjectSettings");
66+
Directory.CreateDirectory(projectSettingsDirectory);
67+
string audioManagerPath = Path.Combine(projectSettingsDirectory, "AudioManager.asset");
68+
if (!File.Exists(audioManagerPath))
69+
{
70+
Console.WriteLine("**** Creating AudioManager.asset to disable Unity audio");
71+
using (StreamWriter audioManager = new StreamWriter(audioManagerPath))
72+
{
73+
audioManager.WriteLine("%YAML 1.1");
74+
audioManager.WriteLine("%TAG !u! tag:unity3d.com,2011:");
75+
audioManager.WriteLine("--- !u!11 &1");
76+
audioManager.WriteLine("AudioManager:");
77+
audioManager.WriteLine(" m_DisableAudio: 1");
78+
}
79+
}
80+
6081
Console.WriteLine("**** Compiling C# code for the Editor");
6182
unity.Run(new[]
6283
{
@@ -110,6 +131,11 @@ public void Run()
110131

111132
if (OperatingSystem.IsMacOS())
112133
{
134+
configureArgs = configureArgs.Concat(new[]
135+
{
136+
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15"
137+
}).ToList();
138+
113139
// On macOS, we must build the native code twice, once for x86_64 and once for arm64.
114140
// In theory we can build universal binaries, but some of our third party libraries don't
115141
// handle this well.
@@ -161,6 +187,10 @@ public void Run()
161187
Console.WriteLine("**** Adding generated files (for the UWP Player) to the package");
162188
AddGeneratedFiles("!UNITY_EDITOR && UNITY_WSA", generatedRuntimePath, Path.Combine(outputPackagePath, "Runtime", "generated"));
163189

190+
// Clean the generated code directory.
191+
Directory.Delete(generatedRuntimePath, true);
192+
Directory.CreateDirectory(generatedRuntimePath);
193+
164194
Console.WriteLine("**** Compiling for Windows Player");
165195
unity.Run(new[]
166196
{

CHANGES.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Change Log
22

3+
## ? - ?
4+
5+
##### Breaking Changes :mega:
6+
7+
- Player builds for macOS now require macOS 10.15+. Previously, 10.13+ was supported.
8+
9+
##### Additions :tada:
10+
11+
- Editor builds for macOS now target macOS 10.15+. Previously, macOS 12.7+ was required.
12+
13+
##### Fixes :wrench:
14+
15+
- 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.
16+
- Fixed a bug that could cause `CesiumFlyToController` to unexpectedly interrupt a flight.
17+
318
## v1.11.1 - 2024-08-01
419

520
##### Fixes :wrench:

Editor/BuildCesiumForUnity.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ private static void OnEditorCompilationFinished(object o)
2929

3030
public static void CompileForAndroidAndExit()
3131
{
32+
CompileCesiumForUnityNative.ExitAfterCompile = true;
33+
3234
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
3335
Directory.CreateDirectory(buildPath);
3436
try
@@ -46,6 +48,8 @@ public static void CompileForAndroidAndExit()
4648

4749
public static void CompileForUWPAndExit()
4850
{
51+
CompileCesiumForUnityNative.ExitAfterCompile = true;
52+
4953
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
5054
Directory.CreateDirectory(buildPath);
5155
try
@@ -62,6 +66,8 @@ public static void CompileForUWPAndExit()
6266

6367
public static void CompileForIOSAndExit()
6468
{
69+
CompileCesiumForUnityNative.ExitAfterCompile = true;
70+
6571
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
6672
Directory.CreateDirectory(buildPath);
6773
try
@@ -85,6 +91,8 @@ public static void CompileForIOSAndExit()
8591

8692
public static void CompileForWindowsAndExit()
8793
{
94+
CompileCesiumForUnityNative.ExitAfterCompile = true;
95+
8896
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
8997
Directory.CreateDirectory(buildPath);
9098
try
@@ -100,6 +108,8 @@ public static void CompileForWindowsAndExit()
100108

101109
public static void CompileForMacAndExit()
102110
{
111+
CompileCesiumForUnityNative.ExitAfterCompile = true;
112+
103113
string buildPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
104114
Directory.CreateDirectory(buildPath);
105115
try

0 commit comments

Comments
 (0)