@@ -176,22 +176,23 @@ def build_universal_framework(frameworks_path):
176176 # Extract list of all built platform-architecture combinations into a map.
177177 # Map looks like this,
178178 # {'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 )
185185
186186 build_universal = True
187- for platform in platform_arch_map :
187+ for platform in platform_variant_arch_map :
188188 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 ])))
190191 missing_architectures = set (CONFIG [apple_os ][platform ]['architectures' ]) \
191- - set (platform_arch_map [platform ])
192+ - set (platform_variant_arch_map [platform ])
192193 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 )))
195196 build_universal = False
196197 break
197198
@@ -203,7 +204,7 @@ def build_universal_framework(frameworks_path):
203204 # Pick any of the platform-arch directories as a reference candidate mainly
204205 # for obtaining a list of contained targets.
205206 reference_dir_path = os .path .join (framework_os_path ,
206- platform_architecture_dirs [0 ])
207+ platform_variant_architecture_dirs [0 ])
207208 logging .debug ('Using {0} as reference path for scanning '
208209 'targets' .format (reference_dir_path ))
209210 target_frameworks = [x for x in os .listdir (reference_dir_path )
@@ -216,15 +217,15 @@ def build_universal_framework(frameworks_path):
216217 target_libraries = []
217218 # Eg: split firebase_auth.framework -> firebase_auth, .framework
218219 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 :
220221 # Since we have arm64 for both device and simulator, lipo cannot combine
221222 # them in the same fat file. We ignore simulator-arm64.
222- if platform_architecture_dir == 'simulator-arm64' :
223+ if variant_architecture_dir == 'simulator-arm64' :
223224 continue
224225 # <build_dir>/<apple_os>/frameworks/<platform-arch>/
225226 # <target>.framework/target
226227 library_path = os .path .join (framework_os_path ,
227- platform_architecture_dir ,
228+ variant_architecture_dir ,
228229 target_framework , target )
229230 target_libraries .append (library_path )
230231
@@ -265,7 +266,7 @@ def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
265266 """Build xcframeworks combining libraries for different operating systems.
266267
267268 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).
269270 This makes it super convenient for developers to use a single deliverable in
270271 XCode and develop for multiple platforms/operating systems in one project.
271272
@@ -327,50 +328,50 @@ def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
327328 """
328329 for apple_os in os .listdir (frameworks_path ):
329330 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 )
331332 # Extract list of all built platform-architecture combinations into a map.
332333 # Map looks like this,
333334 # {'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 :
336337 # Skip directories not of the format platform-arch (eg: universal)
337- if not '-' in platform_architecture :
338+ if not '-' in variant_architecture :
338339 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 )
341342
342343 reference_dir_path = os .path .join (framework_os_path ,
343- platform_architecture_dirs [0 ])
344+ platform_variant_architecture_dirs [0 ])
344345 logging .debug ('Using {0} as reference path for scanning '
345346 'targets' .format (reference_dir_path ))
346347 target_frameworks = [x for x in os .listdir (reference_dir_path )
347348 if x .endswith ('.framework' )]
348349 logging .debug ('Targets found: {0}' .format (' ' .join (target_frameworks )))
349350
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
351352 # (device or simulator) and os (ios or tvos).
352353 for target_framework in target_frameworks :
353354 target_libraries = []
354355 # Eg: split firebase_auth.framework -> firebase_auth, .framework
355356 target , _ = os .path .splitext (target_framework )
356357 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 ]
359360 xcframework_libraries = []
360361 for architecture in architectures :
361362 # <build_dir>/<apple_os>/frameworks/<platform-arch>/
362363 # <target>.framework/target
363364 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 )
366367 xcframework_libraries .append (library_path )
367368
368369 xcframework_key_parts = [apple_os ]
369370 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 )
374375 # Eg: ios-arm64_armv7, tvos-x86_64-simulator
375376 xcframework_key = '-' .join (xcframework_key_parts )
376377
@@ -488,20 +489,21 @@ def main():
488489 raise ValueError ('No supported targets found for {0}' .format (apple_os ))
489490
490491 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 :
494495 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 ))
496497
497- archs_from_config = set (os_platform_config ['architectures' ])
498+ archs_from_config = set (os_platform_variant_config ['architectures' ])
498499 supported_archs = archs_from_config .intersection (args .architecture )
499500 if not supported_archs :
500501 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 ))
502503
503504 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 )
505507 archive_output_path = os .path .join (frameworks_os_path ,
506508 platform_architecture_token )
507509 # Eg: <build_dir>/tvos_cmake_build/device-arm64
@@ -511,10 +513,10 @@ def main():
511513 # For ios builds, we specify architecture to cmake configure.
512514 architecture = architecture if apple_os == 'ios' else None
513515 # 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
516518 cmake_configure_and_build (args .source_dir , build_path ,
517- os_platform_config ['toolchain' ],
519+ os_platform_variant_config ['toolchain' ],
518520 archive_output_path , supported_targets ,
519521 architecture , toolchain_platform )
520522 # Arrange frameworks
@@ -538,7 +540,7 @@ def parse_cmdline_args():
538540 parser .add_argument ('-s' , '--source_dir' ,
539541 default = os .getcwd (),
540542 help = 'Directory containing source code (top level CMakeLists.txt)' )
541- parser .add_argument ('-p ' , '--platform ' , nargs = '+' ,
543+ parser .add_argument ('-v ' , '--platform_variant ' , nargs = '+' ,
542544 default = ('device' , 'simulator' ),
543545 help = 'List of platforms to build for.' )
544546 parser .add_argument ('-a' , '--architecture' , nargs = '+' ,
0 commit comments