2323_src_root_dir = os .path .join (_script_dir , '..' , '..' , '..' )
2424_out_dir = os .path .join (_src_root_dir , 'out' )
2525_bucket_directory = os .path .join (_out_dir , 'fuchsia_bucket' )
26- _fuchsia_base = 'flutter/shell/platform/fuchsia'
2726
2827
2928def IsLinux ():
@@ -33,6 +32,7 @@ def IsLinux():
3332def IsMac ():
3433 return platform .system () == 'Darwin'
3534
35+
3636def GetFuchsiaSDKPath ():
3737 # host_os references the gn host_os
3838 # https://gn.googlesource.com/gn/+/main/docs/reference.md#var_host_os
@@ -174,16 +174,20 @@ def CopyVulkanDepsToBucket(src, dst, arch):
174174 FindFileAndCopyTo ('VkLayer_khronos_validation.json' , '%s/pkg' % (sdk_path ), deps_bucket_path )
175175 FindFileAndCopyTo ('VkLayer_khronos_validation.so' , '%s/arch/%s' % (sdk_path , arch ), deps_bucket_path )
176176
177+
177178def CopyIcuDepsToBucket (src , dst ):
178179 source_root = os .path .join (_out_dir , src )
179180 deps_bucket_path = os .path .join (_bucket_directory , dst )
180181 FindFileAndCopyTo ('icudtl.dat' , source_root , deps_bucket_path )
181182
182- def BuildBucket (runtime_mode , arch , optimized , product ):
183+
184+ def CopyBuildToBucket (runtime_mode , arch , optimized , product ):
183185 unopt = "_unopt" if not optimized else ""
186+
184187 out_dir = 'fuchsia_%s%s_%s/' % (runtime_mode , unopt , arch )
185188 bucket_dir = 'flutter/%s/%s%s/' % (arch , runtime_mode , unopt )
186189 deps_dir = 'flutter/%s/deps/' % (arch )
190+
187191 CopyToBucket (out_dir , bucket_dir , product )
188192 CopyVulkanDepsToBucket (out_dir , deps_dir , arch )
189193 CopyIcuDepsToBucket (out_dir , deps_dir )
@@ -209,6 +213,7 @@ def BuildBucket(runtime_mode, arch, optimized, product):
209213 dst_path = os .path .join (bucket_root , license )
210214 CopyPath (src_path , dst_path )
211215
216+
212217def CheckCIPDPackageExists (package_name , tag ):
213218 '''Check to see if the current package/tag combo has been published'''
214219 command = [
@@ -225,6 +230,7 @@ def CheckCIPDPackageExists(package_name, tag):
225230 else :
226231 return True
227232
233+
228234def RunCIPDCommandWithRetries (command ):
229235 # Retry up to three times. We've seen CIPD fail on verification in some
230236 # instances. Normally verification takes slightly more than 1 minute when
@@ -239,6 +245,7 @@ def RunCIPDCommandWithRetries(command):
239245 if tries == num_tries - 1 :
240246 raise
241247
248+
242249def ProcessCIPDPackage (upload , engine_version ):
243250 if not upload or not IsLinux ():
244251 RunCIPDCommandWithRetries ([
@@ -267,6 +274,7 @@ def ProcessCIPDPackage(upload, engine_version):
267274 tag ,
268275 ])
269276
277+
270278def BuildTarget (runtime_mode , arch , optimized , enable_lto , enable_legacy ,
271279 asan , dart_version_git_info , prebuilt_dart_sdk , additional_targets = []):
272280 unopt = "_unopt" if not optimized else ""
@@ -281,7 +289,6 @@ def BuildTarget(runtime_mode, arch, optimized, enable_lto, enable_legacy,
281289
282290 if not optimized :
283291 flags .append ('--unoptimized' )
284-
285292 if not enable_lto :
286293 flags .append ('--no-lto' )
287294 if not enable_legacy :
@@ -368,14 +375,22 @@ def main():
368375 '--no-dart-version-git-info' ,
369376 action = 'store_true' ,
370377 default = False ,
371- help = 'If set, skips building and just creates packages .' )
378+ help = 'If set, turns off the Dart SDK git hash check .' )
372379
373380 parser .add_argument (
374381 '--no-prebuilt-dart-sdk' ,
375382 action = 'store_true' ,
376383 default = False ,
377384 help = 'If set, builds the Dart SDK locally instead of using the prebuilt Dart SDK.' )
378385
386+ parser .add_argument (
387+ '--copy-unoptimized-debug-artifacts' ,
388+ action = 'store_true' ,
389+ default = False ,
390+ help = 'If set, unoptimized debug artifacts will be copied into CIPD along '
391+ 'with optimized builds. This is a hack to allow infra to make '
392+ 'and copy two debug builds, one with ASAN and one without.' )
393+
379394 args = parser .parse_args ()
380395 RemoveDirectoryIfExists (_bucket_directory )
381396 build_mode = args .runtime_mode
@@ -390,7 +405,7 @@ def main():
390405
391406 # Build buckets
392407 for arch in archs :
393- for i in range (3 ):
408+ for i in range (len ( runtime_modes ) ):
394409 runtime_mode = runtime_modes [i ]
395410 product = product_modes [i ]
396411 if build_mode == 'all' or runtime_mode == build_mode :
@@ -399,7 +414,18 @@ def main():
399414 args .asan , not args .no_dart_version_git_info ,
400415 not args .no_prebuilt_dart_sdk ,
401416 args .targets .split ("," ) if args .targets else [])
402- BuildBucket (runtime_mode , arch , optimized , product )
417+ CopyBuildToBucket (runtime_mode , arch , optimized , product )
418+
419+ # This is a hack. The recipe for building and uploading Fuchsia to CIPD
420+ # builds both a debug build (debug without ASAN) and unoptimized debug
421+ # build (debug with ASAN). To copy both builds into CIPD, the recipe
422+ # runs build_fuchsia_artifacts.py in optimized mode and tells
423+ # build_fuchsia_artifacts.py to also copy_unoptimized_debug_artifacts.
424+ #
425+ # TODO(akbiggs): Consolidate Fuchsia's building and copying logic to
426+ # avoid ugly hacks like this.
427+ if args .copy_unoptimized_debug_artifacts and runtime_mode == 'debug' and optimized :
428+ CopyBuildToBucket (runtime_mode , arch , not optimized , product )
403429
404430 # Create and optionally upload CIPD package
405431 if args .cipd_dry_run or args .upload :
0 commit comments