Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4dc8662

Browse files
authored
fuchsia: Convert legacy permutations to build flag (#20647)
1 parent 6caad8e commit 4dc8662

File tree

14 files changed

+134
-546
lines changed

14 files changed

+134
-546
lines changed

BUILD.gn

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@ config("config") {
1919
cflags = [ "/WX" ] # Treat warnings as errors.
2020
}
2121
}
22-
}
2322

24-
# This "fuchsia_legacy" configuration includes old, non-embedder API sources and
25-
# defines the LEGACY_FUCHSIA_EMBEDDER symbol. This config and its associated
26-
# template are both transitional and will be removed after the embedder API
27-
# transition is complete.
28-
#
29-
# See `source_set_maybe_fuchsia_legacy` in //flutter/common/config.gni
30-
#
31-
# TODO(fxb/54041): Remove when no longer neccesary.
32-
config("fuchsia_legacy") {
33-
if (is_fuchsia) {
23+
# This define is transitional and will be removed after the embedder API
24+
# transition is complete.
25+
#
26+
# TODO(bugs.fuchsia.dev/54041): Remove when no longer neccesary.
27+
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
3428
defines = [ "LEGACY_FUCHSIA_EMBEDDER" ]
3529
}
3630
}

common/config.gni

Lines changed: 3 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ declare_args() {
1616

1717
# Whether to use the Skia text shaper module
1818
flutter_enable_skshaper = false
19+
20+
# Whether to use the legacy embedder when building for Fuchsia.
21+
flutter_enable_legacy_fuchsia_embedder = true
1922
}
2023

2124
# feature_defines_list ---------------------------------------------------------
@@ -56,119 +59,3 @@ if (is_ios || is_mac) {
5659
]
5760
flutter_cflags_objcc = flutter_cflags_objc
5861
}
59-
60-
# This template creates a `source_set` in both standard and "fuchsia_legacy"
61-
# configurations.
62-
#
63-
# The "fuchsia_legacy" configuration includes old, non-embedder API sources and
64-
# defines the LEGACY_FUCHSIA_EMBEDDER symbol. This template and the config
65-
# are both transitional and will be removed after the embedder API transition
66-
# is complete.
67-
# TODO(fxb/54041): Remove when no longer neccesary.
68-
#
69-
# `sources`, `defines`, `public_configs`, `configs`, `public_deps`, `deps` work
70-
# as they do in a normal `source_set`.
71-
#
72-
# `legacy_deps` is the list of dependencies which should be mutated by
73-
# appending '_fuchsia_legacy' when creating the 2 `source_set`'s. The template adds
74-
# `legacy_deps` to `public_deps`, whether it mutates them or not.
75-
template("source_set_maybe_fuchsia_legacy") {
76-
public_deps_non_legacy = []
77-
deps_non_legacy = []
78-
if (defined(invoker.public_deps)) {
79-
public_deps_non_legacy += invoker.public_deps
80-
}
81-
if (defined(invoker.deps)) {
82-
deps_non_legacy += invoker.deps
83-
}
84-
if (defined(invoker.public_deps_legacy_and_next)) {
85-
foreach(legacy_dep, invoker.public_deps_legacy_and_next) {
86-
public_deps_non_legacy += [ legacy_dep ]
87-
}
88-
}
89-
if (defined(invoker.deps_legacy_and_next)) {
90-
foreach(legacy_dep, invoker.deps_legacy_and_next) {
91-
deps_non_legacy += [ legacy_dep ]
92-
}
93-
}
94-
95-
source_set(target_name) {
96-
forward_variables_from(invoker,
97-
[
98-
"testonly",
99-
"sources",
100-
"defines",
101-
"public_configs",
102-
"configs",
103-
])
104-
public_deps = public_deps_non_legacy
105-
deps = deps_non_legacy
106-
}
107-
108-
if (is_fuchsia) {
109-
legagcy_suffix = "_fuchsia_legacy"
110-
111-
sources_legacy = []
112-
if (defined(invoker.sources_legacy)) {
113-
sources_legacy += invoker.sources_legacy
114-
}
115-
if (defined(invoker.sources)) {
116-
sources_legacy += invoker.sources
117-
}
118-
119-
public_configs_legacy = [ "//flutter:fuchsia_legacy" ]
120-
if (defined(invoker.public_configs)) {
121-
public_configs_legacy += invoker.public_configs
122-
}
123-
124-
public_deps_legacy = []
125-
deps_legacy = []
126-
if (defined(invoker.public_deps)) {
127-
public_deps_legacy += invoker.public_deps
128-
}
129-
if (defined(invoker.deps)) {
130-
deps_legacy += invoker.deps
131-
}
132-
if (defined(invoker.public_deps_legacy)) {
133-
public_deps_legacy += invoker.public_deps_legacy
134-
}
135-
if (defined(invoker.deps_legacy)) {
136-
deps_legacy += invoker.deps_legacy
137-
}
138-
if (defined(invoker.public_deps_legacy_and_next)) {
139-
foreach(legacy_dep, invoker.public_deps_legacy_and_next) {
140-
public_deps_legacy += [ legacy_dep + legagcy_suffix ]
141-
}
142-
}
143-
if (defined(invoker.deps_legacy_and_next)) {
144-
foreach(legacy_dep, invoker.deps_legacy_and_next) {
145-
deps_legacy += [ legacy_dep + legagcy_suffix ]
146-
}
147-
}
148-
149-
source_set(target_name + legagcy_suffix) {
150-
forward_variables_from(invoker,
151-
[
152-
"testonly",
153-
"defines",
154-
"configs",
155-
])
156-
sources = sources_legacy
157-
158-
public_configs = public_configs_legacy
159-
160-
public_deps = public_deps_legacy
161-
deps = deps_legacy
162-
}
163-
} else {
164-
if (defined(invoker.sources_legacy)) {
165-
not_needed(invoker, [ "sources_legacy" ])
166-
}
167-
if (defined(invoker.public_deps_legacy)) {
168-
not_needed(invoker, [ "public_deps_legacy" ])
169-
}
170-
if (defined(invoker.deps_legacy)) {
171-
not_needed(invoker, [ "deps_legacy" ])
172-
}
173-
}
174-
}

flow/BUILD.gn

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import("//build/fuchsia/sdk.gni")
66
import("//flutter/common/config.gni")
77
import("//flutter/testing/testing.gni")
88

9-
source_set_maybe_fuchsia_legacy("flow") {
9+
source_set("flow") {
1010
sources = [
1111
"compositor_context.cc",
1212
"compositor_context.h",
@@ -78,28 +78,31 @@ source_set_maybe_fuchsia_legacy("flow") {
7878
"//third_party/skia",
7979
]
8080

81-
sources_legacy = [
82-
"layers/child_scene_layer.cc",
83-
"layers/child_scene_layer.h",
84-
"scene_update_context.cc",
85-
"scene_update_context.h",
86-
"view_holder.cc",
87-
"view_holder.h",
88-
]
81+
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
82+
sources += [
83+
"layers/child_scene_layer.cc",
84+
"layers/child_scene_layer.h",
85+
"scene_update_context.cc",
86+
"scene_update_context.h",
87+
"view_holder.cc",
88+
"view_holder.h",
89+
]
8990

90-
public_deps_legacy = [
91-
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
92-
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
93-
"$fuchsia_sdk_root/pkg:scenic_cpp",
94-
]
91+
public_deps = [
92+
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
93+
"$fuchsia_sdk_root/fidl:fuchsia.ui.gfx",
94+
"$fuchsia_sdk_root/fidl:fuchsia.ui.views",
95+
"$fuchsia_sdk_root/pkg:scenic_cpp",
96+
]
97+
}
9598
}
9699

97100
if (enable_unittests) {
98101
test_fixtures("flow_fixtures") {
99102
fixtures = []
100103
}
101104

102-
source_set_maybe_fuchsia_legacy("flow_testing") {
105+
source_set("flow_testing") {
103106
testonly = true
104107

105108
sources = [
@@ -121,10 +124,10 @@ if (enable_unittests) {
121124
"//third_party/googletest:gtest",
122125
]
123126

124-
deps_legacy_and_next = [ ":flow" ]
127+
deps = [ ":flow" ]
125128
}
126129

127-
source_set_maybe_fuchsia_legacy("flow_unittests_common") {
130+
executable("flow_unittests") {
128131
testonly = true
129132

130133
sources = [
@@ -160,7 +163,9 @@ if (enable_unittests) {
160163
]
161164

162165
deps = [
166+
":flow",
163167
":flow_fixtures",
168+
":flow_testing",
164169
"//flutter/fml",
165170
"//flutter/testing:skia",
166171
"//flutter/testing:testing_lib",
@@ -169,32 +174,10 @@ if (enable_unittests) {
169174
"//third_party/skia",
170175
]
171176

172-
sources_legacy = [ "layers/fuchsia_layer_unittests.cc" ]
173-
174-
deps_legacy = [ "//build/fuchsia/pkg:sys_cpp_testing" ]
175-
176-
deps_legacy_and_next = [
177-
":flow",
178-
":flow_testing",
179-
]
180-
}
181-
182-
if (is_fuchsia) {
183-
executable("flow_unittests") {
184-
testonly = true
185-
186-
deps = [ ":flow_unittests_common_fuchsia_legacy" ]
187-
}
188-
executable("flow_unittests_next") {
189-
testonly = true
190-
191-
deps = [ ":flow_unittests_common" ]
192-
}
193-
} else {
194-
executable("flow_unittests") {
195-
testonly = true
177+
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
178+
sources += [ "layers/fuchsia_layer_unittests.cc" ]
196179

197-
deps = [ ":flow_unittests_common" ]
180+
deps += [ "//build/fuchsia/pkg:sys_cpp_testing" ]
198181
}
199182
}
200183
}

lib/ui/BUILD.gn

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import("//build/fuchsia/sdk.gni")
66
import("//flutter/common/config.gni")
77
import("//flutter/testing/testing.gni")
88

9-
source_set_maybe_fuchsia_legacy("ui") {
9+
source_set("ui") {
1010
sources = [
1111
"compositing/scene.cc",
1212
"compositing/scene.h",
@@ -120,6 +120,7 @@ source_set_maybe_fuchsia_legacy("ui") {
120120
deps = [
121121
"//flutter/assets",
122122
"//flutter/common",
123+
"//flutter/flow",
123124
"//flutter/fml",
124125
"//flutter/runtime:test_font",
125126
"//flutter/third_party/tonic",
@@ -132,18 +133,18 @@ source_set_maybe_fuchsia_legacy("ui") {
132133
defines = [ "FLUTTER_ENABLE_SKSHAPER" ]
133134
}
134135

135-
sources_legacy = [
136-
"compositing/scene_host.cc",
137-
"compositing/scene_host.h",
138-
]
139-
140-
deps_legacy = [
141-
"$fuchsia_sdk_root/pkg:async-cpp",
142-
"//flutter/shell/platform/fuchsia/dart-pkg/fuchsia",
143-
"//flutter/shell/platform/fuchsia/dart-pkg/zircon",
144-
]
136+
if (is_fuchsia && flutter_enable_legacy_fuchsia_embedder) {
137+
sources += [
138+
"compositing/scene_host.cc",
139+
"compositing/scene_host.h",
140+
]
145141

146-
deps_legacy_and_next = [ "//flutter/flow:flow" ]
142+
deps += [
143+
"$fuchsia_sdk_root/pkg:async-cpp",
144+
"//flutter/shell/platform/fuchsia/dart-pkg/fuchsia",
145+
"//flutter/shell/platform/fuchsia/dart-pkg/zircon",
146+
]
147+
}
147148
}
148149

149150
if (enable_unittests) {
@@ -174,7 +175,7 @@ if (enable_unittests) {
174175
]
175176
}
176177

177-
source_set_maybe_fuchsia_legacy("ui_unittests_common") {
178+
executable("ui_unittests") {
178179
testonly = true
179180

180181
public_configs = [ "//flutter:export_dynamic_symbols" ]
@@ -187,44 +188,22 @@ if (enable_unittests) {
187188
]
188189

189190
deps = [
191+
":ui",
190192
":ui_unittests_fixtures",
191193
"//flutter/common",
194+
"//flutter/shell/common:shell_test_fixture_sources",
192195
"//flutter/testing",
196+
"//flutter/testing:dart",
197+
"//flutter/testing:fixture_test",
193198
"//flutter/third_party/tonic",
194199
"//third_party/dart/runtime/bin:elf_loader",
195200
]
196201

197-
# TODO(): This test is hard-coded to use a TestGLSurface so it cannot run on fuchsia.
202+
# TODO(https://github.com/flutter/flutter/issues/63837): This test is hard-coded to use a TestGLSurface so it cannot run on fuchsia.
198203
if (!is_fuchsia) {
199204
sources += [ "painting/image_decoder_unittests.cc" ]
200205

201206
deps += [ "//flutter/testing:opengl" ]
202207
}
203-
204-
deps_legacy_and_next = [
205-
":ui",
206-
"//flutter/shell/common:shell_test_fixture_sources",
207-
"//flutter/testing:dart",
208-
"//flutter/testing:fixture_test",
209-
]
210-
}
211-
212-
if (is_fuchsia) {
213-
executable("ui_unittests") {
214-
testonly = true
215-
216-
deps = [ ":ui_unittests_common_fuchsia_legacy" ]
217-
}
218-
executable("ui_unittests_next") {
219-
testonly = true
220-
221-
deps = [ ":ui_unittests_common" ]
222-
}
223-
} else {
224-
executable("ui_unittests") {
225-
testonly = true
226-
227-
deps = [ ":ui_unittests_common" ]
228-
}
229208
}
230209
}

0 commit comments

Comments
 (0)