From 57f7120ef923a2806e2406319f0c35dc3619508b Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Sat, 11 Mar 2023 19:38:43 -0800 Subject: [PATCH] Add GN arguments that disable building host artifacts (#40242) --- common/config.gni | 8 ++++++-- tools/gn | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/common/config.gni b/common/config.gni index 48f78fbbc17c2..142701b8542ff 100644 --- a/common/config.gni +++ b/common/config.gni @@ -16,6 +16,9 @@ declare_args() { # Whether to use a prebuilt Dart SDK instead of building one. flutter_prebuilt_dart_sdk = false + + # Whether to build host-side development artifacts. + flutter_build_engine_artifacts = true } # feature_defines_list --------------------------------------------------------- @@ -122,5 +125,6 @@ if (flutter_prebuilt_dart_sdk) { # TODO: We can't build the engine artifacts for arm (32-bit) right now; # see https://github.com/flutter/flutter/issues/74322 build_engine_artifacts = - current_toolchain == host_toolchain || - (is_linux && !is_chromeos && current_cpu != "arm") || is_mac || is_win + flutter_build_engine_artifacts && + (current_toolchain == host_toolchain || + (is_linux && !is_chromeos && current_cpu != "arm") || is_mac || is_win) diff --git a/tools/gn b/tools/gn index b893752780775..072a6d289b272 100755 --- a/tools/gn +++ b/tools/gn @@ -264,7 +264,9 @@ def to_gn_args(args): gn_args['full_dart_sdk'] = args.full_dart_sdk if args.enable_unittests: - gn_args['enable_unittests'] = args.enable_unittests + gn_args['enable_unittests'] = True + if args.no_enable_unittests: + gn_args['enable_unittests'] = False # Skia GN args. gn_args['skia_enable_flutter_defines' @@ -323,6 +325,9 @@ def to_gn_args(args): gn_args['target_cpu'] = get_target_cpu(args) gn_args['dart_target_arch'] = gn_args['target_cpu'] + if not args.build_engine_artifacts: + gn_args['flutter_build_engine_artifacts'] = False + # We cannot cross-compile for 32 bit arm on a Windows host. We work around # this by leaving 'target_cpu' and 'dart_target_arch' set to 'arm' so that # Dart tools such as gen_snapshot that are built for the host will correctly @@ -660,7 +665,18 @@ def parse_args(args): parser.add_argument('--unoptimized', default=False, action='store_true') - parser.add_argument('--enable-unittests', action='store_true', default=False) + parser.add_argument( + '--enable-unittests', + action='store_true', + default=False, + help='Force enable building unit test binaries.' + ) + parser.add_argument( + '--no-enable-unittests', + default=False, + action='store_true', + help='Force disable building unit test binaries.' + ) parser.add_argument( '--runtime-mode', @@ -755,6 +771,19 @@ def parse_args(args): '--arm-float-abi', type=str, choices=['hard', 'soft', 'softfp'] ) + parser.add_argument( + '--build-engine-artifacts', + default=True, + action='store_true', + help='Build the host-side development artifacts.' + ) + parser.add_argument( + '--no-build-engine-artifacts', + dest='build_engine_artifacts', + action='store_false', + help='Do not build the host-side development artifacts.' + ) + parser.add_argument('--goma', default=True, action='store_true') parser.add_argument('--no-goma', dest='goma', action='store_false') parser.add_argument(