Skip to content

Commit c9ea4db

Browse files
authored
[flutter_runner] Refactor our build rules to make them more inline with topaz. (#12034)
Also add flutter tool support for topaz in-tree builds that already have a dependency on the framework repository. After this the only major changes left are profiler symbols and Framework mode. This should make making topaz use our buldrules significantly easier.
1 parent 50bdbd7 commit c9ea4db

File tree

2 files changed

+174
-146
lines changed

2 files changed

+174
-146
lines changed

shell/platform/fuchsia/flutter/BUILD.gn

Lines changed: 27 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import("$flutter_root/shell/gpu/gpu.gni")
1010
import("$flutter_root/tools/fuchsia/common_libs.gni")
1111
import("$flutter_root/tools/fuchsia/dart.gni")
1212
import("$flutter_root/tools/fuchsia/package_dir.gni")
13+
import("engine_flutter_runner.gni")
1314

1415
shell_gpu_configuration("fuchsia_gpu_configuration") {
1516
enable_software = false
@@ -18,139 +19,33 @@ shell_gpu_configuration("fuchsia_gpu_configuration") {
1819
enable_metal = false
1920
}
2021

21-
# Builds a flutter_runner
22-
#
23-
# Parameters:
22+
# Things that explicitly being excluded:
23+
# 1. Kernel snapshot framework mode.
24+
# 2. Profiler symbols.
25+
26+
# Dependencies for flutter tooling
2427
#
25-
# output_name (required):
26-
# The name of the resulting binary.
28+
# While not required to run a flutter mod, these allow interacting
29+
# with flutter via the fx tool and need to be built.
2730
#
28-
# extra_deps (required):
29-
# Any additional dependencies.
30-
# extra_defines (optional):
31-
# Any additional preprocessor defines.
32-
template("flutter_runner") {
33-
assert(defined(invoker.output_name), "flutter_runner must define output_name")
34-
assert(defined(invoker.extra_deps), "flutter_runner must define extra_deps")
35-
assert(defined(invoker.product), "flutter_runner must define product")
36-
37-
invoker_output_name = invoker.output_name
38-
extra_deps = invoker.extra_deps
39-
40-
extra_defines = []
41-
if (defined(invoker.extra_defines)) {
42-
extra_defines += invoker.extra_defines
43-
}
44-
45-
executable(target_name) {
46-
output_name = invoker_output_name
47-
48-
defines = extra_defines
49-
50-
libs = []
51-
52-
sources = [
53-
"component.cc",
54-
"component.h",
55-
"compositor_context.cc",
56-
"compositor_context.h",
57-
"engine.cc",
58-
"engine.h",
59-
"isolate_configurator.cc",
60-
"isolate_configurator.h",
61-
"logging.h",
62-
"loop.cc",
63-
"loop.h",
64-
"main.cc",
65-
"platform_view.cc",
66-
"platform_view.h",
67-
"runner.cc",
68-
"runner.h",
69-
"runner_context.cc",
70-
"runner_context.h",
71-
"service_provider_dir.cc",
72-
"service_provider_dir.h",
73-
"session_connection.cc",
74-
"session_connection.h",
75-
"surface.cc",
76-
"surface.h",
77-
"task_observers.cc",
78-
"task_observers.h",
79-
"task_runner_adapter.cc",
80-
"task_runner_adapter.h",
81-
"thread.cc",
82-
"thread.h",
83-
"unique_fdio_ns.h",
84-
"vsync_recorder.cc",
85-
"vsync_recorder.h",
86-
"vsync_waiter.cc",
87-
"vsync_waiter.h",
88-
"vulkan_surface.cc",
89-
"vulkan_surface.h",
90-
"vulkan_surface_pool.cc",
91-
"vulkan_surface_pool.h",
92-
"vulkan_surface_producer.cc",
93-
"vulkan_surface_producer.h",
94-
]
31+
# This is only for builds in topaz tree.
32+
flutter_tool_deps = []
33+
if (!using_fuchsia_sdk) {
34+
flutter_tool_deps += [ "//third_party/dart-pkg/git/flutter/packages/flutter_tools:fuchsia_attach($host_toolchain)" ]
35+
}
9536

96-
deps = [
97-
":fuchsia_gpu_configuration",
98-
"$flutter_root/common",
99-
"$flutter_root/flow",
100-
"$flutter_root/fml",
101-
"$flutter_root/lib/ui",
102-
"$flutter_root/runtime",
103-
"$flutter_root/runtime:libdart",
104-
"$flutter_root/shell/common",
105-
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
106-
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
107-
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils",
108-
"$flutter_root/vulkan",
109-
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
110-
"$fuchsia_sdk_root/fidl:fuchsia.images",
111-
"$fuchsia_sdk_root/fidl:fuchsia.io",
112-
"$fuchsia_sdk_root/fidl:fuchsia.modular",
113-
"$fuchsia_sdk_root/fidl:fuchsia.sys",
114-
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
115-
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
116-
"$fuchsia_sdk_root/pkg:async-cpp",
117-
"$fuchsia_sdk_root/pkg:async-loop",
118-
"$fuchsia_sdk_root/pkg:async-loop-cpp",
119-
"$fuchsia_sdk_root/pkg:fdio",
120-
"$fuchsia_sdk_root/pkg:fidl_cpp",
121-
"$fuchsia_sdk_root/pkg:scenic_cpp",
122-
"$fuchsia_sdk_root/pkg:syslog",
123-
"$fuchsia_sdk_root/pkg:trace",
124-
"$fuchsia_sdk_root/pkg:trace-engine",
125-
"$fuchsia_sdk_root/pkg:trace-provider-so",
126-
"$fuchsia_sdk_root/pkg:zx",
127-
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
128-
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
129-
"//third_party/skia",
130-
"//third_party/tonic",
131-
] + extra_deps
132-
133-
# The flags below are needed so that Dart's CPU profiler can walk the
134-
# C++ stack.
135-
cflags = [ "-fno-omit-frame-pointer" ]
136-
137-
if (!invoker.product) {
138-
# This flag is needed so that the call to dladdr() in Dart's native symbol
139-
# resolver can report good symbol information for the CPU profiler.
140-
ldflags = [ "-rdynamic" ]
141-
}
37+
flutter_runner("jit") {
38+
output_name = "flutter_jit_runner"
39+
product = false
40+
if (flutter_runtime_mode == "profile") {
41+
extra_defines = [ "FLUTTER_PROFILE" ]
14242
}
143-
}
14443

145-
# Things that explicitly being excluded:
146-
# 1. flutter_profile flag.
147-
# 2. Injecting flutter tool specific stuff.
148-
# 3. Product mode is going to be false for now.
149-
# 4. Kernel snapshot: framework and product.
150-
# 5. Observatoory stuff.
151-
# 6. Profiler symbols.
152-
# 7. framework and product!! (_framework snapshots and dilp files.)
153-
# 8. CMX files are also ignored.
44+
extra_deps = [
45+
"//third_party/dart/runtime:libdart_jit",
46+
"//third_party/dart/runtime/platform:libdart_platform_jit",
47+
] + flutter_tool_deps
48+
}
15449

15550
flutter_runner("jit_product") {
15651
output_name = "flutter_jit_product_runner"
@@ -163,19 +58,6 @@ flutter_runner("jit_product") {
16358
]
16459
}
16560

166-
flutter_runner("jit") {
167-
output_name = "flutter_jit_runner"
168-
product = false
169-
if (flutter_runtime_mode == "profile") {
170-
extra_defines = [ "FLUTTER_PROFILE" ]
171-
}
172-
173-
extra_deps = [
174-
"//third_party/dart/runtime:libdart_jit",
175-
"//third_party/dart/runtime/platform:libdart_platform_jit",
176-
]
177-
}
178-
17961
flutter_runner("aot") {
18062
output_name = "flutter_aot_runner"
18163
product = false
@@ -208,12 +90,12 @@ template("jit_runner") {
20890
}
20991

21092
package_dir(target_name) {
211-
snapshot_gen_dir =
212-
"$root_build_dir/gen/flutter/shell/platform/fuchsia/flutter/kernel"
93+
snapshot_label = "kernel:kernel_core_snapshot${product_suffix}"
94+
snapshot_gen_dir = get_label_info(snapshot_label, "target_gen_dir")
21395

21496
deps = [
21597
":jit${product_suffix}",
216-
"kernel:kernel_core_snapshot${product_suffix}",
98+
snapshot_label,
21799
]
218100

219101
if (!product) {
@@ -346,8 +228,7 @@ executable("flutter_runner_unittests") {
346228
"sample_unittests.cc",
347229
]
348230

349-
# This is needed for //third_party/googletest for linking zircon
350-
# symbols.
231+
# This is needed for //third_party/googletest for linking zircon symbols.
351232
libs = [ "//fuchsia/sdk/$host_os/arch/$target_cpu/sysroot/lib/libzircon.so" ]
352233

353234
deps = [
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
assert(is_fuchsia)
6+
7+
import("//build/fuchsia/sdk.gni")
8+
9+
# Builds a flutter_runner
10+
#
11+
# Parameters:
12+
#
13+
# output_name (required):
14+
# The name of the resulting binary.
15+
#
16+
# extra_deps (required):
17+
# Any additional dependencies.
18+
#
19+
# product (required):
20+
# Whether to link against a Product mode Dart VM.
21+
#
22+
# extra_defines (optional):
23+
# Any additional preprocessor defines.
24+
template("flutter_runner") {
25+
assert(defined(invoker.output_name), "flutter_runner must define output_name")
26+
assert(defined(invoker.extra_deps), "flutter_runner must define extra_deps")
27+
assert(defined(invoker.product), "flutter_runner must define product")
28+
29+
invoker_output_name = invoker.output_name
30+
extra_deps = invoker.extra_deps
31+
32+
extra_defines = []
33+
if (defined(invoker.extra_defines)) {
34+
extra_defines += invoker.extra_defines
35+
}
36+
37+
executable(target_name) {
38+
output_name = invoker_output_name
39+
40+
defines = extra_defines
41+
42+
libs = []
43+
44+
sources = [
45+
"component.cc",
46+
"component.h",
47+
"compositor_context.cc",
48+
"compositor_context.h",
49+
"engine.cc",
50+
"engine.h",
51+
"isolate_configurator.cc",
52+
"isolate_configurator.h",
53+
"logging.h",
54+
"loop.cc",
55+
"loop.h",
56+
"main.cc",
57+
"platform_view.cc",
58+
"platform_view.h",
59+
"runner.cc",
60+
"runner.h",
61+
"runner_context.cc",
62+
"runner_context.h",
63+
"service_provider_dir.cc",
64+
"service_provider_dir.h",
65+
"session_connection.cc",
66+
"session_connection.h",
67+
"surface.cc",
68+
"surface.h",
69+
"task_observers.cc",
70+
"task_observers.h",
71+
"task_runner_adapter.cc",
72+
"task_runner_adapter.h",
73+
"thread.cc",
74+
"thread.h",
75+
"unique_fdio_ns.h",
76+
"vsync_recorder.cc",
77+
"vsync_recorder.h",
78+
"vsync_waiter.cc",
79+
"vsync_waiter.h",
80+
"vulkan_surface.cc",
81+
"vulkan_surface.h",
82+
"vulkan_surface_pool.cc",
83+
"vulkan_surface_pool.h",
84+
"vulkan_surface_producer.cc",
85+
"vulkan_surface_producer.h",
86+
]
87+
88+
# The use of these dependencies is temporary and will be moved behind the
89+
# embedder API.
90+
flutter_deps = [
91+
"../flutter:fuchsia_gpu_configuration",
92+
"$flutter_root/assets",
93+
"$flutter_root/common",
94+
"$flutter_root/flow",
95+
"$flutter_root/lib/ui",
96+
"$flutter_root/runtime",
97+
"$flutter_root/third_party/txt",
98+
"$flutter_root/vulkan",
99+
"$flutter_root/fml",
100+
"$flutter_root/shell/common",
101+
]
102+
103+
_fuchsia_platform = "$flutter_root/shell/platform/fuchsia"
104+
105+
# TODO(kaushikiska) evaluate if all of these are needed.
106+
fuchsia_deps = [
107+
"${_fuchsia_platform}/dart-pkg/fuchsia",
108+
"${_fuchsia_platform}/dart-pkg/zircon",
109+
"${_fuchsia_platform}/runtime/dart/utils",
110+
]
111+
112+
deps = [
113+
"$fuchsia_sdk_root/fidl:fuchsia.fonts",
114+
"$fuchsia_sdk_root/fidl:fuchsia.images",
115+
"$fuchsia_sdk_root/fidl:fuchsia.io",
116+
"$fuchsia_sdk_root/fidl:fuchsia.modular",
117+
"$fuchsia_sdk_root/fidl:fuchsia.sys",
118+
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
119+
"$fuchsia_sdk_root/fidl:fuchsia.ui.scenic",
120+
"$fuchsia_sdk_root/pkg:async-cpp",
121+
"$fuchsia_sdk_root/pkg:async-loop",
122+
"$fuchsia_sdk_root/pkg:async-loop-cpp",
123+
"$fuchsia_sdk_root/pkg:fdio",
124+
"$fuchsia_sdk_root/pkg:fidl_cpp",
125+
"$fuchsia_sdk_root/pkg:scenic_cpp",
126+
"$fuchsia_sdk_root/pkg:syslog",
127+
"$fuchsia_sdk_root/pkg:trace",
128+
"$fuchsia_sdk_root/pkg:trace-engine",
129+
"$fuchsia_sdk_root/pkg:trace-provider-so",
130+
"$fuchsia_sdk_root/pkg:zx",
131+
"$fuchsia_sdk_root/pkg/lib/sys/cpp",
132+
"$fuchsia_sdk_root/pkg/lib/vfs/cpp",
133+
"//third_party/skia",
134+
"//third_party/tonic",
135+
] + fuchsia_deps + flutter_deps + extra_deps
136+
137+
# The flags below are needed so that Dart's CPU profiler can walk the
138+
# C++ stack.
139+
cflags = [ "-fno-omit-frame-pointer" ]
140+
141+
if (!invoker.product) {
142+
# This flag is needed so that the call to dladdr() in Dart's native symbol
143+
# resolver can report good symbol information for the CPU profiler.
144+
ldflags = [ "-rdynamic" ]
145+
}
146+
}
147+
}

0 commit comments

Comments
 (0)