Skip to content

Commit e6a4610

Browse files
richkadelarbreng
authored andcommitted
Improving support for AOT builds of Fuchsia packages
The integration test works in debug/jit mode only, and building in `profile` and `release` modes was not working, breaking some builders. The workaround was to disable the test. This PR will enable release/aot mode so it will build, and unblock both the debug-mode version of the test (tested by CI) and release mode builds of the repo. Due to the request to unblock, this PR does not yet build packages in `profile` mode that will run in Fuchsia, but it should at least build without errors. Ongoing work is in progress to also support running in release mode.
1 parent 2b0f6f3 commit e6a4610

File tree

9 files changed

+158
-153
lines changed

9 files changed

+158
-153
lines changed

build/dart/rules.gni

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ template("flutter_snapshot") {
9292
# Also, this define excludes debugging and profiling code from Flutter.
9393
args += [ "-Ddart.vm.product=true" ]
9494
} else {
95-
if (!is_debug) {
95+
if (flutter_runtime_mode == "profile") {
9696
# The following define excludes debugging code from Flutter.
9797
args += [ "-Ddart.vm.profile=true" ]
9898
}

shell/platform/fuchsia/flutter/integration_flutter_tests/BUILD.gn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44

55
group("integration_flutter_tests") {
66
testonly = true
7-
# TODO(fxbug.dev/86055): re-enable
8-
# deps = [ "embedder:tests" ]
7+
deps = [ "embedder:tests" ]
98
}

tools/fuchsia/dart/config.gni

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
import("//flutter/tools/fuchsia/dart/dart_build_config.gni")
66

77
declare_args() {
8-
# Forces all Dart apps to build in product mode which is a
9-
# stripped down version of the VM running in AOT mode.
10-
dart_force_product = false
11-
12-
# TODO(fxbug.dev/64153) renable aot builds
13-
# if (dart_force_product) {
14-
# Product AOT
15-
# dart_default_build_cfg = dart_release_build_cfg
16-
# } else if (is_debug) {
8+
# TODO(fxbug.dev/86941) enable dart_runner_integration_tests
9+
# TODO(fxbug.dev/64153) renable dart runner aot builds
10+
# if (flutter_runtime_mode == "release") {
11+
# # Product AOT
12+
# dart_default_build_cfg = dart_release_build_cfg
13+
# } else if (flutter_runtime_mode == "jit_release") {
14+
# # Product JIT
15+
# dart_default_build_cfg = dart_jit_release_build_cfg
16+
# } else if (flutter_runtime_mode == "debug") {
1717
# Non-product JIT
1818
dart_default_build_cfg = dart_debug_build_cfg
19-
20-
# } else {
21-
# Non-product AOT
22-
# dart_default_build_cfg = dart_profile_build_cfg
23-
# }
19+
# } else { # "profile"
20+
# # Non-product AOT
21+
# dart_default_build_cfg = dart_profile_build_cfg
22+
# }
2423
}

tools/fuchsia/dart/dart_build_config.gni

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
import("//flutter/common/config.gni")
6+
57
# Builds the component in a non-product JIT build. This will
68
# launch the vm service in the runner.
79
dart_debug_build_cfg = {
@@ -13,42 +15,52 @@ dart_debug_build_cfg = {
1315
enable_asserts = true
1416
}
1517

16-
# TODO(richkadel): Don't confuse these settings with those in dart_build_config.gni,
17-
# in fact, do I really need both? Can I drop flutter_build_config.gni?
18+
# Builds the component in a non-product AOT build. This will
19+
# launch the vm service in the runner.
20+
# This configuration is not compatible with a --release build since the
21+
# profile aot runner is built without asserts.
22+
dart_aot_debug_build_cfg = {
23+
runtime_meta = "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime"
24+
runner_dep = "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_runner"
25+
platform_name = "dart_runner"
26+
is_aot = true
27+
is_product = false
28+
enable_asserts = true
29+
}
1830

19-
# # Builds the component in a non-product AOT build. This will
20-
# # launch the vm service in the runner.
21-
# # This configuration is not compatible with a --release build since the
22-
# # profile aot runner is built without asserts.
23-
# dart_aot_debug_build_cfg = {
24-
# runtime_meta = "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime"
25-
# runner_dep = "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_runner"
26-
# platform_name = "dart_runner"
27-
# is_aot = true
28-
# is_product = false
29-
# enable_asserts = true
30-
# }
31+
# Builds the component in a non-product AOT build. This will
32+
# launch the vm service in the runner.
33+
dart_profile_build_cfg = {
34+
runtime_meta = "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime"
35+
runner_dep = "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_runner"
36+
platform_name = "dart_runner"
37+
is_aot = true
38+
is_product = false
39+
enable_asserts = false
40+
}
3141

32-
# # Builds the component in a non-product AOT build. This will
33-
# # launch the vm service in the runner.
34-
# dart_profile_build_cfg = {
35-
# runtime_meta = "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime"
36-
# runner_dep = "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_runner"
37-
# platform_name = "dart_runner"
38-
# is_aot = true
39-
# is_product = false
40-
# enable_asserts = false
41-
# }
42+
# Builds the component in a product JIT build. This will
43+
# not launch the vm service in the runner.
44+
dart_jit_release_build_cfg = {
45+
runtime_meta =
46+
"//flutter/shell/platform/fuchsia/dart_runner/meta/jit_product_runtime"
47+
runner_dep =
48+
"//flutter/shell/platform/fuchsia/dart_runner:dart_jit_product_runner"
49+
platform_name = "dart_runner"
50+
is_aot = true
51+
is_product = true
52+
enable_asserts = false
53+
}
4254

43-
# # Builds the component in a product AOT build. This will
44-
# # not launch the vm service in the runner.
45-
# dart_release_build_cfg = {
46-
# runtime_meta =
47-
# "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_product_runtime"
48-
# runner_dep =
49-
# "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_product_runner"
50-
# platform_name = "dart_runner"
51-
# is_aot = true
52-
# is_product = true
53-
# enable_asserts = false
54-
# }
55+
# Builds the component in a product AOT build. This will
56+
# not launch the vm service in the runner.
57+
dart_release_build_cfg = {
58+
runtime_meta =
59+
"//flutter/shell/platform/fuchsia/dart_runner/meta/aot_product_runtime"
60+
runner_dep =
61+
"//flutter/shell/platform/fuchsia/dart_runner:dart_aot_product_runner"
62+
platform_name = "dart_runner"
63+
is_aot = true
64+
is_product = true
65+
enable_asserts = false
66+
}

tools/fuchsia/dart/kernel/dart_kernel.gni

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,9 @@ template("dart_kernel") {
157157
_kernel_deps += invoker.deps
158158
}
159159

160-
# TODO(richkadel): The manifest is currently used by flutter_dart_component, to populate the file
161-
# it calls `_convert_kernel_manifest_file`, so I can't make this conditional, right? Or is it
162-
# possible to build Dart AOT Fuchsia packages/components without the data in this file (in which
163-
# case I should make it conditional there as well)?
160+
# TODO(richkadel): The manifest (if not using AOT) is used by
161+
# flutter_dart_component, to populate the file it calls
162+
# `_convert_kernel_manifest_file`.
164163
_generate_manifest = false
165164
if (invoker.is_aot) {
166165
not_needed(invoker, [ "generate_manifest" ])
@@ -291,17 +290,11 @@ template("dart_kernel") {
291290
]
292291
}
293292

294-
# TODO(richkadel): NEED TO VALIDATE AND/OR CLEAN UP `is_debug` and `is_aot`.
295-
# `is_debug` is set by the flutter `gn` script to true if --unoptimized,
296-
# but `--unoptimized` is broken for Fuchsia, according to an open bug in
297-
# github flutter/flutter issues. But I have a feeling `is_debug` from
298-
# Fuchsia scripts may have a different meaning for dart/flutter at least.
299-
# if (is_debug) {
300-
args += [ "--embed-sources" ]
301-
302-
# } else {
303-
# args += [ "--no-embed-sources" ]
304-
# }
293+
if (flutter_runtime_mode == "debug") {
294+
args += [ "--embed-sources" ]
295+
} else {
296+
args += [ "--no-embed-sources" ]
297+
}
305298

306299
if (invoker.is_aot) {
307300
args += [
@@ -320,12 +313,10 @@ template("dart_kernel") {
320313
# This define excludes debugging and profiling code from Flutter.
321314
args += [ "-Ddart.vm.product=true" ]
322315
} else {
323-
# TODO(richkadel): I'm pretty sure we want to assume is_debug even if that's
324-
# not what's set by gn flags (--unoptimized = false because true is currentlyh broken for Fuchsia?)
325-
# if (!is_debug) {
326-
# # The following define excludes debugging code from Flutter.
327-
# args += [ "-Ddart.vm.profile=true" ]
328-
# }
316+
if (flutter_runtime_mode == "profile") {
317+
# The following define excludes debugging code from Flutter.
318+
args += [ "-Ddart.vm.profile=true" ]
319+
}
329320
}
330321

331322
if (defined(invoker.main_dart)) {

tools/fuchsia/dart_kernel.gni

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ template("dart_kernel") {
4949
"--output=" + rebase_path(output),
5050
]
5151

52-
if (is_debug) {
52+
if (flutter_runtime_mode == "debug") {
5353
args += [ "--embed-sources" ]
5454
} else {
5555
args += [ "--no-embed-sources" ]
@@ -75,7 +75,7 @@ template("dart_kernel") {
7575
# Also, this define excludes debugging and profiling code from Flutter.
7676
args += [ "-Ddart.vm.product=true" ]
7777
} else {
78-
if (!is_debug) {
78+
if (flutter_runtime_mode == "profile") {
7979
# The following define excludes debugging code from Flutter.
8080
args += [ "-Ddart.vm.profile=true" ]
8181
}

tools/fuchsia/flutter/config.gni

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,17 @@
55
import("//flutter/tools/fuchsia/flutter/flutter_build_config.gni")
66

77
declare_args() {
8-
# If set to true, will force the runners to be built in
9-
# product mode which means they will not have an exposed vm service
10-
flutter_force_product = false
11-
}
12-
13-
declare_args() {
14-
# TODO(richkadel): Make sure we're using 'debug' (non-aot) consistently,
15-
# across dart and flutter rules.
16-
# Since we're not REALLY building flutter apps, can I just git rid of this
17-
# setting, and the configs in flutter/tools/fuchsia/flutter/flutter_build_config.gni?
18-
# I think it's confusing to have both that one and .../dart/dart_build_config.gni.
19-
20-
# if (flutter_force_product) {
21-
# # Product AOT
22-
# flutter_default_build_cfg = flutter_release_build_cfg
23-
# } else if (is_debug) {
24-
# Non-product JIT
25-
flutter_default_build_cfg = flutter_debug_build_cfg
26-
27-
# } else {
28-
# # Non-product AOT
29-
# flutter_default_build_cfg = flutter_profile_build_cfg
30-
# }
8+
if (flutter_runtime_mode == "release") {
9+
# Product AOT
10+
flutter_default_build_cfg = flutter_release_build_cfg
11+
} else if (flutter_runtime_mode == "jit_release") {
12+
# Product JIT
13+
flutter_default_build_cfg = flutter_jit_release_build_cfg
14+
} else if (flutter_runtime_mode == "debug") {
15+
# Non-product JIT
16+
flutter_default_build_cfg = flutter_debug_build_cfg
17+
} else { # "profile"
18+
# Non-product AOT
19+
flutter_default_build_cfg = flutter_profile_build_cfg
20+
}
3121
}

tools/fuchsia/flutter/flutter_build_config.gni

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
import("//flutter/common/config.gni")
6+
57
# Non-product JIT is "debug". It launches the vm service.
68
# Non-product AOT is "profile". It also launches the vm service, but lacks tools that rely on JIT.
9+
# Product JIT is "release". It doesn't launch the vm service.
710
# Product AOT is "release". It doesn't launch the vm service.
811

912
# Builds the component in a non-product JIT build. This will
@@ -17,43 +20,54 @@ flutter_debug_build_cfg = {
1720
enable_asserts = true
1821
}
1922

20-
# TODO(richkadel): Don't confuse these settings with those in dart_build_config.gni,
21-
# in fact, do I really need both? Can we just use the settings in dart_build_config.gni?
23+
# Builds the component in a non-product AOT build. This will
24+
# launch the vm service in the runner.
25+
# This configuration is not compatible with a --release build since the
26+
# profile aot runner is built without asserts.
27+
flutter_aot_debug_build_cfg = {
28+
runtime_meta = "//flutter/shell/platform/fuchsia/flutter/meta/aot_runtime"
29+
runner_dep = "//flutter/shell/platform/fuchsia/flutter:flutter_aot_runner"
30+
platform_name = "flutter_runner"
31+
is_aot = true
32+
is_product = false
33+
enable_asserts = true
34+
}
2235

23-
# # Builds the component in a non-product AOT build. This will
24-
# # launch the vm service in the runner.
25-
# # This configuration is not compatible with a --release build since the
26-
# # profile aot runner is built without asserts.
27-
# flutter_aot_debug_build_cfg = {
28-
# runtime_meta = "//flutter/shell/platform/fuchsia/flutter/meta/aot_runtime"
29-
# runner_dep = "//flutter/shell/platform/fuchsia/flutter:flutter_aot_runner"
30-
# platform_name = "flutter_runner"
31-
# is_aot = true
32-
# is_product = false
33-
# enable_asserts = true
34-
# }
36+
# Builds the component in a non-product AOT build. This will
37+
# launch the vm service in the runner.
38+
flutter_profile_build_cfg = {
39+
runtime_meta =
40+
"//flutter/shell/platform/fuchsia/flutter/meta/aot_runtime" # profile
41+
# runner
42+
runner_dep = "//flutter/shell/platform/fuchsia/flutter:flutter_aot_runner"
43+
platform_name = "flutter_runner"
44+
is_aot = true
45+
is_product = false
46+
enable_asserts = false
47+
}
3548

36-
# # Builds the component in a non-product AOT build. This will
37-
# # launch the vm service in the runner.
38-
# flutter_profile_build_cfg = {
39-
# runtime_meta =
40-
# "//flutter/shell/platform/fuchsia/flutter/meta/aot_runtime" # profile
41-
# # runner
42-
# runner_dep = "//flutter/shell/platform/fuchsia/flutter:flutter_aot_runner"
43-
# platform_name = "flutter_runner"
44-
# is_aot = true
45-
# is_product = false
46-
# enable_asserts = false
47-
# }
49+
# Builds the component in a product JIT build. This will
50+
# not launch the vm service in the runner.
51+
flutter_jit_release_build_cfg = {
52+
runtime_meta =
53+
"//flutter/shell/platform/fuchsia/flutter/meta/jit_product_runtime"
54+
runner_dep =
55+
"//flutter/shell/platform/fuchsia/flutter:flutter_jit_product_runner"
56+
platform_name = "flutter_runner"
57+
is_aot = false
58+
is_product = true
59+
enable_asserts = false
60+
}
4861

49-
# # Builds the component in a product AOT build. This will
50-
# # not launch the vm service in the runner.
51-
# flutter_release_build_cfg = {
52-
# runtime_meta =
53-
# "//flutter/shell/platform/fuchsia/flutter/meta/aot_product_runtime"
54-
# runner_dep = "//flutter/shell/platform/fuchsia/flutter:flutter_aot_product_runner"
55-
# platform_name = "flutter_runner"
56-
# is_aot = true
57-
# is_product = true
58-
# enable_asserts = false
59-
# }
62+
# Builds the component in a product AOT build. This will
63+
# not launch the vm service in the runner.
64+
flutter_release_build_cfg = {
65+
runtime_meta =
66+
"//flutter/shell/platform/fuchsia/flutter/meta/aot_product_runtime"
67+
runner_dep =
68+
"//flutter/shell/platform/fuchsia/flutter:flutter_aot_product_runner"
69+
platform_name = "flutter_runner"
70+
is_aot = true
71+
is_product = true
72+
enable_asserts = false
73+
}

0 commit comments

Comments
 (0)