Skip to content

Commit 75d506b

Browse files
authored
Experimental/m138 lw exclude chrome (#7291)
This PR enables the use of exclude_chrome_build=true for lightweight Linux builds. With this change, it is possible to build essential Chromium components without including the full Chrome browser dependencies. It also ensures that chromedriver remains available for testing and automation, even in lightweight builds. This is applied to Linux only as exclude_chrome_build currently supports Linux, and Android lightweight builds don't require GN-level exclusion.
1 parent 7d694f3 commit 75d506b

File tree

7 files changed

+459
-408
lines changed

7 files changed

+459
-408
lines changed

BUILD.gn

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# file to your new one or GN won't know about it.
1010

1111
import("//build/config/cast.gni")
12+
import("//build/config/chrome_exclude.gni")
1213
import("//build/config/compiler/compiler.gni")
1314
import("//build/config/cronet/config.gni")
1415
import("//build/config/dcheck_always_on.gni")
@@ -149,7 +150,7 @@ group("gn_all") {
149150
}
150151

151152
if (!is_ios && !is_android && !is_castos) {
152-
if (!is_fuchsia) {
153+
if (!exclude_chrome_build) {
153154
deps += [
154155
"//chrome",
155156
"//chrome/browser/ui/actions:dump_actions",
@@ -171,15 +172,15 @@ group("gn_all") {
171172
]
172173
}
173174

174-
if (!is_castos && !is_fuchsia) {
175+
if (!exclude_chrome_build) {
175176
deps += [ "//chrome/installer" ]
176177
}
177178

178-
if (!is_fuchsia && enable_updater) {
179+
if (!exclude_chrome_build && enable_updater) {
179180
deps += [ "//chrome/updater" ]
180181
}
181182

182-
if (enable_enterprise_companion) {
183+
if (enable_enterprise_companion && !exclude_chrome_build) {
183184
deps += [ "//chrome/enterprise_companion" ]
184185
}
185186

@@ -191,7 +192,7 @@ group("gn_all") {
191192
}
192193

193194
if (!is_ios && !is_castos) {
194-
if (!is_fuchsia) {
195+
if (!exclude_chrome_build) {
195196
deps += [ "//chrome/test:unit_tests" ]
196197
}
197198
deps += [ "//ui/accessibility:accessibility_unittests" ]
@@ -261,7 +262,7 @@ group("gn_all") {
261262
"//third_party/catapult/telemetry:bitmaptools($host_toolchain)",
262263
]
263264
if (!is_android) {
264-
if (!is_castos && !is_fuchsia) {
265+
if (!exclude_chrome_build) {
265266
deps += [ "//chrome/test:telemetry_perf_unittests" ]
266267
}
267268
} else {
@@ -331,7 +332,7 @@ group("gn_all") {
331332
]
332333
}
333334

334-
if (enterprise_watermark) {
335+
if (enterprise_watermark && !exclude_chrome_build) {
335336
deps += [ "//chrome/browser/enterprise/watermark:watermark_app" ]
336337
}
337338

@@ -497,7 +498,7 @@ group("gn_all") {
497498
deps += [ "//testing:empty_main" ]
498499
}
499500

500-
if (!is_castos) {
501+
if (!exclude_chrome_build) {
501502
deps += [ "//chrome:xdg_mime" ]
502503
}
503504

@@ -555,7 +556,7 @@ group("gn_all") {
555556
]
556557
}
557558

558-
if (!is_android && !is_castos && !is_ios && !is_fuchsia) {
559+
if (!is_android && !is_ios && !exclude_chrome_build) {
559560
deps += [
560561
"//chrome/test:load_library_perf_tests",
561562
"//chrome/test:sync_performance_tests",
@@ -626,7 +627,7 @@ group("gn_all") {
626627
"//ui/snapshot:snapshot_unittests",
627628
]
628629

629-
if (!is_castos) {
630+
if (!exclude_chrome_build) {
630631
deps += [ "//chrome/test:chrome_app_unittests" ]
631632
}
632633

@@ -757,8 +758,6 @@ group("gn_all") {
757758
# TODO(https://crbug.com/1329673): Figure out if any of these should be in
758759
# gn_all and figure out how cross-platform they are.
759760
deps += [
760-
"//chrome/installer/util:strings",
761-
"//chrome/tools/convert_dict",
762761
"//components/constrained_window:unit_tests",
763762
"//components/metrics:serialization",
764763
"//components/sessions:unit_tests",
@@ -778,8 +777,15 @@ group("gn_all") {
778777
"//ui/shell_dialogs:shell_dialogs_unittests",
779778
]
780779

780+
if (!exclude_chrome_build) {
781+
deps += [
782+
"//chrome/installer/util:strings",
783+
"//chrome/tools/convert_dict",
784+
]
785+
}
786+
781787
if (target_cpu == "x86" || target_cpu == "x64") {
782-
if (!is_android) {
788+
if (!is_android && !exclude_chrome_build) {
783789
deps += [ "//chrome/test:load_library_perf_tests" ]
784790
}
785791
deps += [ "//third_party/libjpeg_turbo:simd_asm" ]
@@ -817,7 +823,7 @@ group("gn_all") {
817823
]
818824
}
819825

820-
if (enable_vr) {
826+
if (enable_vr && !exclude_chrome_build) {
821827
deps += [
822828
"//chrome/browser/vr:vr_common_perftests",
823829
"//chrome/browser/vr:vr_common_unittests",
@@ -1127,7 +1133,7 @@ if (use_blink && !is_cronet_build) {
11271133
"//third_party/blink/public:all_blink",
11281134
]
11291135

1130-
if (!is_chromeos && !is_ios && !is_fuchsia && !is_android && !is_castos) {
1136+
if (!is_chromeos && !is_ios && !is_android && !exclude_chrome_build) {
11311137
deps += [
11321138
":chrome_wpt_tests",
11331139
":headless_shell_wpt",
@@ -1181,7 +1187,7 @@ if (use_blink && !is_cronet_build) {
11811187
]
11821188
}
11831189

1184-
if (!is_chromeos && !is_ios && !is_fuchsia && !is_android && !is_castos) {
1190+
if (!is_chromeos && !is_ios && !is_android && !exclude_chrome_build) {
11851191
# https://chromium.googlesource.com/chromium/src/+/HEAD/docs/testing/run_web_platform_tests.md
11861192
script_test("chrome_wpt_tests") {
11871193
script = "//third_party/blink/tools/run_wpt_tests.py"
@@ -1731,14 +1737,14 @@ group("chromium_builder_perf") {
17311737
"//tools/perf/chrome_telemetry_build:telemetry_chrome_test",
17321738
]
17331739

1734-
if (!is_fuchsia) {
1740+
if (!exclude_chrome_build) {
17351741
data_deps += [
17361742
"//chrome/test:load_library_perf_tests",
17371743
"//chrome/test:performance_test_suite",
17381744
]
17391745
}
17401746

1741-
if (!is_chromeos && !is_fuchsia) {
1747+
if (!is_chromeos && !exclude_chrome_build) {
17421748
data_deps += [ "//chrome/test:performance_browser_tests" ]
17431749
}
17441750

@@ -1776,7 +1782,7 @@ if (!is_ios && !is_android && !is_castos && !is_cronet_build) {
17761782
"//third_party/blink/public/mojom:mojom_modules_js",
17771783
"//v8:d8",
17781784
]
1779-
if (!is_fuchsia) {
1785+
if (!exclude_chrome_build) {
17801786
deps += [ "//chrome:chrome" ]
17811787
}
17821788
if (!is_win) {

build/config/chrome_exclude.gni

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2025 The Chromium Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("//build/config/cast.gni")
6+
import("//build/config/lightweight.gni")
7+
8+
declare_args() {
9+
# Controls whether to exclude //chrome directory from the build graph.
10+
# This prevents unnecessary GN failures caused by //chrome dependencies when
11+
# building only specific Chromium components without the Chrome browser.
12+
#
13+
# When true:
14+
# - //chrome targets are excluded from the build
15+
# - Prevents GN failures from unwanted //chrome dependencies
16+
#
17+
# Supported platforms:
18+
# - Fuchsia, CastOS: Always true
19+
# - Linux: Optional
20+
#
21+
# TODO: Consider adding is_cast_android support.
22+
exclude_chrome_build =
23+
is_fuchsia || is_castos || (enable_lightweight && !is_android)
24+
}
25+
26+
if (exclude_chrome_build && !(is_fuchsia || is_castos || is_linux)) {
27+
print("WARNING: exclude_chrome_build=true is only supported on Fuchsia, " +
28+
"CastOS, and Linux platforms.")
29+
}
30+
31+
# For Fuchsia and CastOS, exclude_chrome_build must be true.
32+
assert(!(is_fuchsia || is_castos) || exclude_chrome_build,
33+
"exclude_chrome_build must be true for Fuchsia and CastOS.")

0 commit comments

Comments
 (0)