Skip to content

Commit ded8566

Browse files
committed
build only for specified targets
1 parent 1cbf67d commit ded8566

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

scripts/gha/build_ios_tvos.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,16 @@ def arrange_frameworks(archive_output_path):
124124
os.remove(os.path.join(root, f))
125125

126126

127-
def build_universal_framework(frameworks_path):
127+
def build_universal_framework(frameworks_path, targets):
128128
"""Create universal frameworks if possible.
129129
130130
If all architectures (eg: arm64, armv7 etc) and platforms (device, simulator)
131131
were built, combine all of the libraries into a single universal framework.
132132
Args:
133133
frameworks_path (str): Root path containing subdirectories for each
134134
operating system and its frameworks.
135+
targets iterable(str): List of firebase libraries to process.
136+
(eg: [firebase_auth, firebase_remote_config])
135137
Eg: <build_dir>/frameworks <------------- <frameworks_path>
136138
- ios
137139
- device-arm64
@@ -208,8 +210,11 @@ def build_universal_framework(frameworks_path):
208210
platform_variant_architecture_dirs[0])
209211
logging.debug('Using {0} as reference path for scanning '
210212
'targets'.format(reference_dir_path))
213+
# Filter only .framework directories and make sure the framework is
214+
# in list of supported targets.
211215
target_frameworks = [x for x in os.listdir(reference_dir_path)
212-
if x.endswith('.framework')]
216+
if x.endswith('.framework') and
217+
x.split('.')[0] in targets]
213218
logging.debug('Targets found: {0}'.format(' '.join(target_frameworks)))
214219

215220
# Collect a list of libraries from various platform-arch combinations for
@@ -263,7 +268,8 @@ def build_universal_framework(frameworks_path):
263268
universal_firebase_framework_headers_path)
264269

265270

266-
def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
271+
def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist,
272+
targets):
267273
"""Build xcframeworks combining libraries for different operating systems.
268274
269275
Combine frameworks for different operating systems (ios, tvos), architectures
@@ -276,6 +282,8 @@ def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
276282
xcframeworks_path (str): Absolute path to create xcframeworks in.
277283
template_info_plist (str): Absolute path to a template Info.plist that
278284
will be copied over to each xcframework and provides metadata to XCode.
285+
targets iterable(str): List of firebase target libraries.
286+
(eg: [firebase_auth, firebase_remote_config])
279287
280288
Eg: <build_dir>/frameworks <------------- <frameworks_path>
281289
- ios <---------- <frameworks_os_path>
@@ -345,8 +353,12 @@ def build_xcframeworks(frameworks_path, xcframeworks_path, template_info_plist):
345353
platform_variant_architecture_dirs[0])
346354
logging.debug('Using {0} as reference path for scanning '
347355
'targets'.format(reference_dir_path))
356+
357+
# Filter only .framework directories and make sure the framework is
358+
# in list of supported targets.
348359
target_frameworks = [x for x in os.listdir(reference_dir_path)
349-
if x.endswith('.framework')]
360+
if x.endswith('.framework') and
361+
x.split('.')[0] in targets]
350362
logging.debug('Targets found: {0}'.format(' '.join(target_frameworks)))
351363

352364
# For each target, we collect all libraries for a specific platform variants
@@ -545,15 +557,19 @@ def main():
545557
# Reorganize frameworks (renaming, copying over headers etc)
546558
arrange_frameworks(archive_output_path)
547559

560+
# Since we renamed firebase_app.framework to firebase.framework we add that
561+
# to our list of targets.
562+
supported_targets.add('firebase')
563+
548564
# if we built for all architectures build universal framework as well.
549-
build_universal_framework(frameworks_path)
565+
build_universal_framework(frameworks_path, supported_targets)
550566

551567
# Build xcframeworks
552568
xcframeworks_path = os.path.join(args.build_dir, 'xcframeworks')
553569
template_info_plist_path = os.path.join(args.source_dir, 'build_scripts',
554570
'tvos', 'Info_ios_and_tvos.plist')
555571
build_xcframeworks(frameworks_path, xcframeworks_path,
556-
template_info_plist_path)
572+
template_info_plist_path, supported_targets)
557573

558574

559575
def parse_cmdline_args():

0 commit comments

Comments
 (0)