334 parser = argparse.ArgumentParser()
335
336 parser.add_argument(
337 '--cipd-dry-run',
338 default=False,
339 action='store_true',
340 help='If set, creates the CIPD package but does not upload it.'
341 )
342
343 parser.add_argument(
344 '--upload',
345 default=False,
346 action='store_true',
347 help='If set, uploads the CIPD package and tags it as the latest.'
348 )
349
350 parser.add_argument('--engine-version', required=False, help='Specifies the flutter engine SHA.')
351
352 parser.add_argument(
353 '--unoptimized',
354 action='store_true',
355 default=False,
356 help='If set, disables compiler optimization for the build.'
357 )
358
359 parser.add_argument(
360 '--runtime-mode', type=str, choices=['debug', 'profile', 'release', 'all'], default='all'
361 )
362
363 parser.add_argument('--archs', type=str, choices=['x64', 'arm64', 'all'], default='all')
364
365 parser.add_argument(
366 '--asan',
367 action='store_true',
368 default=False,
369 help='If set, enables address sanitization (including leak sanitization) for the build.'
370 )
371
372 parser.add_argument(
373 '--no-lto', action='store_true', default=False, help='If set, disables LTO for the build.'
374 )
375
376 parser.add_argument(
377 '--no-legacy',
378 action='store_true',
379 default=False,
380 help='If set, disables legacy code for the build.'
381 )
382
383 parser.add_argument(
384 '--skip-build',
385 action='store_true',
386 default=False,
387 help='If set, skips building and just creates packages.'
388 )
389
390 parser.add_argument(
391 '--targets',
392 default='',
393 help=('Comma-separated list; adds additional targets to build for '
394 'Fuchsia.')
395 )
396
397 parser.add_argument(
398 '--no-dart-version-git-info',
399 action='store_true',
400 default=False,
401 help='If set, turns off the Dart SDK git hash check.'
402 )
403
404 parser.add_argument(
405 '--no-prebuilt-dart-sdk',
406 action='store_true',
407 default=False,
408 help='If set, builds the Dart SDK locally instead of using the prebuilt Dart SDK.'
409 )
410
411 parser.add_argument(
412 '--copy-unoptimized-debug-artifacts',
413 action='store_true',
414 default=False,
415 help='If set, unoptimized debug artifacts will be copied into CIPD along '
416 'with optimized builds. This is a hack to allow infra to make '
417 'and copy two debug builds, one with ASAN and one without.'
418 )
419
420
421 parser.add_argument(
422 '--skip-remove-buckets',
423 action='store_true',
424 default=False,
425 help='This allows for multiple runtimes to exist in the default bucket directory. If '
426 'set, will skip over the removal of existing artifacts in the bucket directory '
427 '(which is the default behavior).'
428 )
429
430 args = parser.parse_args()
431 build_mode = args.runtime_mode
432 if (not args.skip_remove_buckets):
433 RemoveDirectoryIfExists(_bucket_directory)
434
435 archs = ['x64', 'arm64'] if args.archs == 'all' else [args.archs]
436 runtime_modes = ['debug', 'profile', 'release']
437 product_modes = [False, False, True]
438
439 optimized = not args.unoptimized
440 enable_lto = not args.no_lto
441 enable_legacy = not args.no_legacy
442
443
444 for arch in archs:
445 for i in range(len(runtime_modes)):
446 runtime_mode = runtime_modes[i]
447 product = product_modes[i]
448 if build_mode == 'all' or runtime_mode == build_mode:
449 if not args.skip_build:
450 BuildTarget(
451 runtime_mode, arch, optimized, enable_lto, enable_legacy, args.asan,
452 not args.no_dart_version_git_info, not args.no_prebuilt_dart_sdk,
453 args.targets.split(",") if args.targets else ['flutter']
454 )
455 CopyBuildToBucket(runtime_mode, arch, optimized, product)
456
457
458
459
460
461
462
463
464
465 if args.copy_unoptimized_debug_artifacts and runtime_mode == 'debug' and optimized:
466 CopyBuildToBucket(runtime_mode, arch, not optimized, product)
467
468
469
470 should_upload = args.upload
471 engine_version = args.engine_version
472 if not engine_version:
473 engine_version = 'HEAD'
474 should_upload = False
475
476
477 if args.cipd_dry_run or args.upload:
478 ProcessCIPDPackage(should_upload, engine_version)
479
480 return 0
481
482