@@ -176,22 +176,23 @@ def build_universal_framework(frameworks_path):
176
176
# Extract list of all built platform-architecture combinations into a map.
177
177
# Map looks like this,
178
178
# {'device': ['arm64', 'armv7'], 'simulator': ['x86_64']}
179
- platform_architecture_dirs = os .listdir (framework_os_path )
180
- platform_arch_map = defaultdict (list )
181
- for platform_architecture in platform_architecture_dirs :
182
- logging .debug ('Inspecting ' + platform_architecture )
183
- platform , architecture = platform_architecture .split ('-' )
184
- platform_arch_map [ platform ].append (architecture )
179
+ platform_variant_architecture_dirs = os .listdir (framework_os_path )
180
+ platform_variant_arch_map = defaultdict (list )
181
+ for variant_architecture in platform_variant_architecture_dirs :
182
+ logging .debug ('Inspecting ' + variant_architecture )
183
+ platform_variant , architecture = variant_architecture .split ('-' )
184
+ platform_variant_arch_map [ platform_variant ].append (architecture )
185
185
186
186
build_universal = True
187
- for platform in platform_arch_map :
187
+ for platform in platform_variant_arch_map :
188
188
logging .debug ('Found architectures for platform '
189
- '{0}: {1}' .format (platform , ' ' .join (platform_arch_map [platform ])))
189
+ '{0}: {1}' .format (platform ,
190
+ ' ' .join (platform_variant_arch_map [platform ])))
190
191
missing_architectures = set (CONFIG [apple_os ][platform ]['architectures' ]) \
191
- - set (platform_arch_map [platform ])
192
+ - set (platform_variant_arch_map [platform ])
192
193
if missing_architectures :
193
- logging .error ('Following architectures are missing for platform'
194
- '{0}: {1}' .format (platform , ' ' .join (missing_architectures )))
194
+ logging .error ('Following architectures are missing for platform variant '
195
+ '{0}: {1}' .format (platform_variant , ' ' .join (missing_architectures )))
195
196
build_universal = False
196
197
break
197
198
@@ -203,7 +204,7 @@ def build_universal_framework(frameworks_path):
203
204
# Pick any of the platform-arch directories as a reference candidate mainly
204
205
# for obtaining a list of contained targets.
205
206
reference_dir_path = os .path .join (framework_os_path ,
206
- platform_architecture_dirs [0 ])
207
+ platform_variant_architecture_dirs [0 ])
207
208
logging .debug ('Using {0} as reference path for scanning '
208
209
'targets' .format (reference_dir_path ))
209
210
target_frameworks = [x for x in os .listdir (reference_dir_path )
@@ -216,15 +217,15 @@ def build_universal_framework(frameworks_path):
216
217
target_libraries = []
217
218
# Eg: split firebase_auth.framework -> firebase_auth, .framework
218
219
target , _ = os .path .splitext (target_framework )
219
- for platform_architecture_dir in platform_architecture_dirs :
220
+ for variant_architecture_dir in platform_variant_architecture_dirs :
220
221
# Since we have arm64 for both device and simulator, lipo cannot combine
221
222
# them in the same fat file. We ignore simulator-arm64.
222
- if platform_architecture_dir == 'simulator-arm64' :
223
+ if variant_architecture_dir == 'simulator-arm64' :
223
224
continue
224
225
# <build_dir>/<apple_os>/frameworks/<platform-arch>/
225
226
# <target>.framework/target
226
227
library_path = os .path .join (framework_os_path ,
227
- platform_architecture_dir ,
228
+ variant_architecture_dir ,
228
229
target_framework , target )
229
230
target_libraries .append (library_path )
230
231
@@ -265,7 +266,7 @@ def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
265
266
"""Build xcframeworks combining libraries for different operating systems.
266
267
267
268
Combine frameworks for different operating systems (ios, tvos), architectures
268
- (arm64, armv7, x86_64 etc) per platform (device, simulator).
269
+ (arm64, armv7, x86_64 etc) per platform variant (device, simulator).
269
270
This makes it super convenient for developers to use a single deliverable in
270
271
XCode and develop for multiple platforms/operating systems in one project.
271
272
@@ -327,50 +328,50 @@ def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
327
328
"""
328
329
for apple_os in os .listdir (frameworks_path ):
329
330
framework_os_path = os .path .join (frameworks_path , apple_os )
330
- platform_architecture_dirs = os .listdir (framework_os_path )
331
+ platform_variant_architecture_dirs = os .listdir (framework_os_path )
331
332
# Extract list of all built platform-architecture combinations into a map.
332
333
# Map looks like this,
333
334
# {'device': ['arm64', 'armv7'], 'simulator': ['x86_64']}
334
- platform_arch_map = defaultdict (list )
335
- for platform_architecture in platform_architecture_dirs :
335
+ platform_variant_arch_map = defaultdict (list )
336
+ for variant_architecture in platform_variant_architecture_dirs :
336
337
# Skip directories not of the format platform-arch (eg: universal)
337
- if not '-' in platform_architecture :
338
+ if not '-' in variant_architecture :
338
339
continue
339
- platform , architecture = platform_architecture .split ('-' )
340
- platform_arch_map [ platform ].append (architecture )
340
+ platform_variant , architecture = variant_architecture .split ('-' )
341
+ platform_variant_arch_map [ platform_variant ].append (architecture )
341
342
342
343
reference_dir_path = os .path .join (framework_os_path ,
343
- platform_architecture_dirs [0 ])
344
+ platform_variant_architecture_dirs [0 ])
344
345
logging .debug ('Using {0} as reference path for scanning '
345
346
'targets' .format (reference_dir_path ))
346
347
target_frameworks = [x for x in os .listdir (reference_dir_path )
347
348
if x .endswith ('.framework' )]
348
349
logging .debug ('Targets found: {0}' .format (' ' .join (target_frameworks )))
349
350
350
- # For each target, we collect all libraries for a specific platform
351
+ # For each target, we collect all libraries for a specific platform variants
351
352
# (device or simulator) and os (ios or tvos).
352
353
for target_framework in target_frameworks :
353
354
target_libraries = []
354
355
# Eg: split firebase_auth.framework -> firebase_auth, .framework
355
356
target , _ = os .path .splitext (target_framework )
356
357
xcframework_target_map = {}
357
- for platform in platform_arch_map :
358
- architectures = platform_arch_map [ platform ]
358
+ for platform_variant in platform_variant_arch_map :
359
+ architectures = platform_variant_arch_map [ platform_variant ]
359
360
xcframework_libraries = []
360
361
for architecture in architectures :
361
362
# <build_dir>/<apple_os>/frameworks/<platform-arch>/
362
363
# <target>.framework/target
363
364
library_path = os .path .join (framework_os_path ,
364
- '{0}-{1}' .format (platform , architecture ) ,
365
- target_framework , target )
365
+ '{0}-{1}' .format (platform_variant ,
366
+ architecture ), target_framework , target )
366
367
xcframework_libraries .append (library_path )
367
368
368
369
xcframework_key_parts = [apple_os ]
369
370
xcframework_key_parts .append ('_' .join (sorted (architectures )))
370
- if platform != 'device' :
371
- # device is treated as default platform and we do not add any
372
- # suffix at the end. For all other platforms , add them as suffix.
373
- xcframework_key_parts .append (platform )
371
+ if platform_variant != 'device' :
372
+ # device is treated as default platform variant and we do not add any
373
+ # suffix at the end. For all other variants , add them as suffix.
374
+ xcframework_key_parts .append (platform_variant )
374
375
# Eg: ios-arm64_armv7, tvos-x86_64-simulator
375
376
xcframework_key = '-' .join (xcframework_key_parts )
376
377
@@ -488,20 +489,21 @@ def main():
488
489
raise ValueError ('No supported targets found for {0}' .format (apple_os ))
489
490
490
491
frameworks_os_path = os .path .join (frameworks_path , apple_os )
491
- for platform in args .platform :
492
- os_platform_config = os_config .get (platform )
493
- if not os_platform_config :
492
+ for platform_variant in args .platform_variant :
493
+ os_platform_variant_config = os_config .get (platform_variant )
494
+ if not os_platform_variant_config :
494
495
raise ValueError ('Could not find configuration for platform '
495
- '{0} for os {1}' .format (platform , apple_os ))
496
+ '{0} for os {1}' .format (platform_variant , apple_os ))
496
497
497
- archs_from_config = set (os_platform_config ['architectures' ])
498
+ archs_from_config = set (os_platform_variant_config ['architectures' ])
498
499
supported_archs = archs_from_config .intersection (args .architecture )
499
500
if not supported_archs :
500
501
raise ValueError ('Could not find valid architectures for platform '
501
- '{0} for os {1}' .format (platform , apple_os ))
502
+ '{0} for os {1}' .format (platform_variant , apple_os ))
502
503
503
504
for architecture in supported_archs :
504
- platform_architecture_token = '{0}-{1}' .format (platform , architecture )
505
+ platform_architecture_token = '{0}-{1}' .format (platform_variant ,
506
+ architecture )
505
507
archive_output_path = os .path .join (frameworks_os_path ,
506
508
platform_architecture_token )
507
509
# Eg: <build_dir>/tvos_cmake_build/device-arm64
@@ -511,10 +513,10 @@ def main():
511
513
# For ios builds, we specify architecture to cmake configure.
512
514
architecture = architecture if apple_os == 'ios' else None
513
515
# For tvos builds, we pass a special cmake option PLATFORM to toolchain.
514
- toolchain_platform = os_platform_config ['toolchain_platform' ] if \
515
- apple_os == 'tvos' else None
516
+ toolchain_platform = os_platform_variant_config ['toolchain_platform' ] \
517
+ if apple_os == 'tvos' else None
516
518
cmake_configure_and_build (args .source_dir , build_path ,
517
- os_platform_config ['toolchain' ],
519
+ os_platform_variant_config ['toolchain' ],
518
520
archive_output_path , supported_targets ,
519
521
architecture , toolchain_platform )
520
522
# Arrange frameworks
@@ -538,7 +540,7 @@ def parse_cmdline_args():
538
540
parser .add_argument ('-s' , '--source_dir' ,
539
541
default = os .getcwd (),
540
542
help = 'Directory containing source code (top level CMakeLists.txt)' )
541
- parser .add_argument ('-p ' , '--platform ' , nargs = '+' ,
543
+ parser .add_argument ('-v ' , '--platform_variant ' , nargs = '+' ,
542
544
default = ('device' , 'simulator' ),
543
545
help = 'List of platforms to build for.' )
544
546
parser .add_argument ('-a' , '--architecture' , nargs = '+' ,
0 commit comments