@@ -22,6 +22,12 @@ internal struct PlatformToBuild
22
22
public bool isCleanBuild ;
23
23
}
24
24
25
+ internal enum LibraryCpuArchitecture
26
+ {
27
+ x86_64 ,
28
+ ARM64
29
+ }
30
+
25
31
/// <summary>
26
32
/// When the user builds a Player (built game) in the Unity Editor, this class manages
27
33
/// automatically compiling a suitable version of the native C++ CesiumForUnityNative
@@ -36,7 +42,7 @@ internal class LibraryToBuild
36
42
{
37
43
public BuildTarget Platform = BuildTarget . StandaloneWindows64 ;
38
44
public BuildTargetGroup PlatformGroup = BuildTargetGroup . Standalone ;
39
- public string Cpu = null ;
45
+ public LibraryCpuArchitecture ? Cpu = null ;
40
46
public string SourceDirectory = "" ;
41
47
public string BuildDirectory = "build" ;
42
48
public string GeneratedDirectoryName = "generated-Unknown" ;
@@ -110,6 +116,7 @@ private static string GetSharedLibraryFilename(string baseName, BuildTarget targ
110
116
{
111
117
case BuildTarget . StandaloneWindows :
112
118
case BuildTarget . StandaloneWindows64 :
119
+ case BuildTarget . WSAPlayer :
113
120
return $ "{ baseName } .dll";
114
121
case BuildTarget . iOS :
115
122
return $ "lib{ baseName } .a";
@@ -144,14 +151,21 @@ private static void ConfigurePlugin(LibraryToBuild library, PluginImporter impor
144
151
importer . SetCompatibleWithEditor ( false ) ;
145
152
importer . SetCompatibleWithPlatform ( library . Platform , true ) ;
146
153
147
- if ( library . Platform == BuildTarget . Android )
154
+ if ( library . Platform == BuildTarget . Android ||
155
+ library . Platform == BuildTarget . StandaloneOSX )
148
156
{
149
- importer . SetPlatformData ( BuildTarget . Android , "CPU" , library . Cpu == "arm64" ? "ARM64" : library . Cpu ) ;
157
+ importer . SetPlatformData ( library . Platform , "CPU" , library . Cpu == LibraryCpuArchitecture . ARM64 ? "ARM64" : null ) ;
150
158
}
151
- else if ( library . Platform == BuildTarget . StandaloneOSX )
159
+ else if ( library . Platform == BuildTarget . WSAPlayer )
152
160
{
153
- if ( library . Cpu != null )
154
- importer . SetPlatformData ( BuildTarget . StandaloneOSX , "CPU" , library . Cpu == "arm64" ? "ARM64" : library . Cpu ) ;
161
+ string wsaPlatform = null ;
162
+ if ( library . Cpu == LibraryCpuArchitecture . ARM64 )
163
+ wsaPlatform = "ARM64" ;
164
+ else if ( library . Cpu == LibraryCpuArchitecture . x86_64 )
165
+ wsaPlatform = "X64" ;
166
+ else
167
+ UnityEngine . Debug . LogAssertion ( "Unsupported processor: " + library . Cpu ) ;
168
+ importer . SetPlatformData ( library . Platform , "CPU" , wsaPlatform ) ;
155
169
}
156
170
}
157
171
@@ -241,8 +255,8 @@ private static LibraryToBuild[] GetLibrariesToBuildForPlatform(BuildSummary summ
241
255
}
242
256
else
243
257
{
244
- result . Add ( GetLibraryToBuild ( summary , " x86_64" ) ) ;
245
- result . Add ( GetLibraryToBuild ( summary , "arm64" ) ) ;
258
+ result . Add ( GetLibraryToBuild ( summary , LibraryCpuArchitecture . x86_64 ) ) ;
259
+ result . Add ( GetLibraryToBuild ( summary , LibraryCpuArchitecture . ARM64 ) ) ;
246
260
}
247
261
}
248
262
else if ( summary . platform == BuildTarget . Android )
@@ -253,9 +267,14 @@ private static LibraryToBuild[] GetLibrariesToBuildForPlatform(BuildSummary summ
253
267
UnityEngine . Debug . LogWarning ( "Cesium for Unity only supports the ARM64 and x86_64 CPU architectures on Android. Other architectures will not work." ) ;
254
268
255
269
if ( PlayerSettings . Android . targetArchitectures . HasFlag ( AndroidArchitecture . ARM64 ) )
256
- result . Add ( GetLibraryToBuild ( summary , "arm64" ) ) ;
270
+ result . Add ( GetLibraryToBuild ( summary , LibraryCpuArchitecture . ARM64 ) ) ;
257
271
if ( PlayerSettings . Android . targetArchitectures . HasFlag ( AndroidArchitecture . X86_64 ) )
258
- result . Add ( GetLibraryToBuild ( summary , "x86_64" ) ) ;
272
+ result . Add ( GetLibraryToBuild ( summary , LibraryCpuArchitecture . x86_64 ) ) ;
273
+ }
274
+ else if ( summary . platform == BuildTarget . WSAPlayer )
275
+ {
276
+ result . Add ( GetLibraryToBuild ( summary , LibraryCpuArchitecture . x86_64 ) ) ;
277
+ result . Add ( GetLibraryToBuild ( summary , LibraryCpuArchitecture . ARM64 ) ) ;
259
278
}
260
279
else
261
280
{
@@ -265,7 +284,7 @@ private static LibraryToBuild[] GetLibrariesToBuildForPlatform(BuildSummary summ
265
284
return result . ToArray ( ) ;
266
285
}
267
286
268
- public static LibraryToBuild GetLibraryToBuild ( BuildSummary summary , string cpu = null )
287
+ public static LibraryToBuild GetLibraryToBuild ( BuildSummary summary , LibraryCpuArchitecture ? cpu = null )
269
288
{
270
289
return GetLibraryToBuild ( new PlatformToBuild ( )
271
290
{
@@ -276,7 +295,7 @@ public static LibraryToBuild GetLibraryToBuild(BuildSummary summary, string cpu
276
295
} , cpu ) ;
277
296
}
278
297
279
- public static LibraryToBuild GetLibraryToBuild ( PlatformToBuild platform , string cpu = null )
298
+ public static LibraryToBuild GetLibraryToBuild ( PlatformToBuild platform , LibraryCpuArchitecture ? cpu = null )
280
299
{
281
300
string sourceFilename = GetSourceFilePathName ( ) ;
282
301
string packagePath = Path . GetFullPath ( Path . Combine ( Path . GetDirectoryName ( sourceFilename ) , $ "..") ) ;
@@ -304,8 +323,8 @@ public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, string
304
323
{
305
324
library . Toolchain = $ "extern/android-toolchain.cmake";
306
325
if ( cpu == null )
307
- cpu = "arm64" ;
308
- if ( cpu == " x86_64" )
326
+ cpu = LibraryCpuArchitecture . ARM64 ;
327
+ if ( cpu == LibraryCpuArchitecture . x86_64 )
309
328
library . ExtraConfigureArgs . Add ( "-DCMAKE_ANDROID_ARCH_ABI=x86_64" ) ;
310
329
else
311
330
library . ExtraConfigureArgs . Add ( "-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" ) ;
@@ -323,13 +342,30 @@ public static LibraryToBuild GetLibraryToBuild(PlatformToBuild platform, string
323
342
if ( platform . platform == BuildTarget . StandaloneOSX )
324
343
{
325
344
if ( cpu != null )
326
- library . ExtraConfigureArgs . Add ( "-DCMAKE_OSX_ARCHITECTURES=" + cpu ) ;
345
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_OSX_ARCHITECTURES=" + cpu . ToString ( ) . ToLowerInvariant ( ) ) ;
346
+ }
347
+
348
+ if ( platform . platform == BuildTarget . WSAPlayer )
349
+ {
350
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_SYSTEM_NAME=WindowsStore" ) ;
351
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_SYSTEM_VERSION=10.0" ) ;
352
+ switch ( cpu )
353
+ {
354
+ case LibraryCpuArchitecture . x86_64 :
355
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_SYSTEM_PROCESSOR=AMD64" ) ;
356
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_GENERATOR_PLATFORM=x64" ) ;
357
+ break ;
358
+ case LibraryCpuArchitecture . ARM64 :
359
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_SYSTEM_PROCESSOR=ARM64" ) ;
360
+ library . ExtraConfigureArgs . Add ( "-DCMAKE_GENERATOR_PLATFORM=ARM64" ) ;
361
+ break ;
362
+ }
327
363
}
328
364
329
365
if ( cpu != null )
330
366
{
331
- library . InstallDirectory = Path . Combine ( library . InstallDirectory , cpu ) ;
332
- library . BuildDirectory += "-" + cpu ;
367
+ library . InstallDirectory = Path . Combine ( library . InstallDirectory , cpu . ToString ( ) . ToLowerInvariant ( ) ) ;
368
+ library . BuildDirectory += "-" + cpu . ToString ( ) . ToLowerInvariant ( ) ;
333
369
}
334
370
335
371
return library ;
@@ -345,7 +381,8 @@ private static bool IsEditor(BuildTargetGroup platformGroup, BuildTarget platfor
345
381
return platformGroup == BuildTargetGroup . Unknown && platform == BuildTarget . NoTarget ;
346
382
}
347
383
348
- private static bool IsIOS ( BuildTargetGroup platformGroup , BuildTarget platform ) {
384
+ private static bool IsIOS ( BuildTargetGroup platformGroup , BuildTarget platform )
385
+ {
349
386
return platformGroup == BuildTargetGroup . iOS && platform == BuildTarget . iOS ;
350
387
}
351
388
@@ -388,10 +425,12 @@ internal static void BuildNativeLibrary(LibraryToBuild library)
388
425
{
389
426
ProcessStartInfo startInfo = new ProcessStartInfo ( ) ;
390
427
startInfo . UseShellExecute = false ;
391
- if ( library . Platform == BuildTarget . StandaloneOSX || library . Platform == BuildTarget . iOS ) {
428
+ if ( library . Platform == BuildTarget . StandaloneOSX || library . Platform == BuildTarget . iOS )
429
+ {
392
430
startInfo . FileName = File . Exists ( "/Applications/CMake.app/Contents/bin/cmake" ) ? "/Applications/CMake.app/Contents/bin/cmake" : "cmake" ;
393
431
}
394
- else {
432
+ else
433
+ {
395
434
startInfo . FileName = "cmake" ;
396
435
}
397
436
startInfo . CreateNoWindow = true ;
@@ -412,7 +451,7 @@ internal static void BuildNativeLibrary(LibraryToBuild library)
412
451
$ "-DREINTEROP_GENERATED_DIRECTORY={ library . GeneratedDirectoryName } ",
413
452
} ;
414
453
args . AddRange ( library . ExtraConfigureArgs ) ;
415
-
454
+
416
455
if ( library . Toolchain != null )
417
456
args . Add ( $ "-DCMAKE_TOOLCHAIN_FILE=\" { library . Toolchain } \" ") ;
418
457
@@ -434,8 +473,8 @@ internal static void BuildNativeLibrary(LibraryToBuild library)
434
473
args . AddRange ( library . ExtraBuildArgs ) ;
435
474
startInfo . Arguments = string . Join ( ' ' , args ) ;
436
475
RunAndLog ( startInfo , log , logFilename ) ;
437
-
438
- if ( library . Platform == BuildTarget . iOS )
476
+
477
+ if ( library . Platform == BuildTarget . iOS )
439
478
AssetDatabase . Refresh ( ) ;
440
479
}
441
480
}
0 commit comments