Support DDC library bundle format and remove support for DDC module format (#161276)

This gets us closer to enabling [hot
reload](https://github.com/dart-lang/sdk/issues/54934) on the web as
this format is a prerequisite. Historically, we added support for the
DDC module format only to enable hot reload, but that format is not
feasible for the goal, so we added the DDC library bundle format. The
DDC library bundle format is currently represented as the combination of
the `ddc` module format and `canary`. We no longer need to support the
old DDC module format.

- Adds build artifacts to build the SDKs for this format (but only in
sound mode as unsound is unsupported), and removes said artifacts for
the DDC module format.
- Update artifact maps and constants to add the new format and remove
the old format.
- Adds handling of the `canaryFeatures` flag.
- Update dwds to 24.3.0 and use the new
`FrontendServerDdcLibraryBundleStrategyProvider`.
- Add bootstrap code for the new format. Kept DDC module format
bootstrap code as it's used internally.
- Updates tests.

I ran `spinning_square` with the new module format to verify that it can
run.

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [X] All existing and new tests are passing.
This commit is contained in:
Srujan Gaddam
2025-01-09 12:36:43 -08:00
committed by GitHub
parent fe73879f95
commit a38abc864c
14 changed files with 449 additions and 438 deletions

View File

@@ -336,13 +336,17 @@ group("flutter_platform_dills") {
]
}
template("_compile_ddc_modules") {
template("_compile_ddc_module") {
assert(defined(invoker.sound_null_safety),
"sound_null_safety must be defined for $target_name")
assert(defined(invoker.use_skia),
"use_skia must be defined for $target_name")
assert(defined(invoker.use_skia), "use_skia must be defined for $target_name")
assert(defined(invoker.auto_detect),
"auto_detect must be defined for $target_name")
assert(defined(invoker.sdk_path_prefix),
"sdk_path_prefix must be defined for $target_name")
assert(defined(invoker.module_format),
"module_name must be defined for $target_name")
assert(defined(invoker.canary), "canary must be defined for $target_name")
_dartdevc(target_name) {
inputs = [ "sdk_rewriter.dart" ] + web_ui_sources
@@ -360,17 +364,11 @@ template("_compile_ddc_modules") {
name_suffix += "-sound"
}
amd_js_path =
"$root_out_dir/flutter_web_sdk/kernel/amd${name_suffix}/dart_sdk.js"
ddc_js_path =
"$root_out_dir/flutter_web_sdk/kernel/ddc${name_suffix}/dart_sdk.js"
dart_sdk_js_path = "$root_out_dir/flutter_web_sdk/kernel/${invoker.sdk_path_prefix}${name_suffix}/dart_sdk.js"
outputs = [
amd_js_path,
amd_js_path + ".map",
ddc_js_path,
ddc_js_path + ".map",
dart_sdk_js_path,
dart_sdk_js_path + ".map",
]
if (invoker.sound_null_safety) {
@@ -405,14 +403,13 @@ template("_compile_ddc_modules") {
"-DFLUTTER_WEB_USE_SKIA=${invoker.use_skia}",
"-DFLUTTER_WEB_AUTO_DETECT=${invoker.auto_detect}",
"--modules",
"amd",
invoker.module_format,
"-o",
rebase_path(amd_js_path),
"--modules",
"ddc",
"-o",
rebase_path(ddc_js_path),
rebase_path(dart_sdk_js_path),
]
if (invoker.canary) {
args += [ "--canary" ]
}
if (flutter_prebuilt_dart_sdk) {
args += [
"--multi-root",
@@ -427,6 +424,30 @@ template("_compile_ddc_modules") {
}
}
template("_compile_ddc_modules") {
assert(defined(invoker.sound_null_safety),
"sound_null_safety must be defined for $target_name")
forward_variables_from(invoker, "*")
# We compile multiple times instead of passing multiple modules to a single
# compile as the DDC library bundle format cannot be used when passing
# multiple module formats as arguments.
_compile_ddc_module("${target_name}_amd") {
sdk_path_prefix = "amd"
module_format = "amd"
canary = false
}
# No support for unsound null safety with the DDC library bundle format.
if (sound_null_safety) {
_compile_ddc_module("${target_name}_ddcLibraryBundle") {
sdk_path_prefix = "ddcLibraryBundle"
module_format = "ddc"
canary = true
}
}
}
# Compiles the unsound html only renderer.
_compile_ddc_modules("flutter_dartdevc_kernel_sdk") {
sound_null_safety = false
@@ -471,12 +492,15 @@ _compile_ddc_modules("flutter_dartdevc_canvaskit_html_kernel_sdk_sound") {
group("flutter_ddc_modules") {
public_deps = [
":flutter_dartdevc_canvaskit_html_kernel_sdk",
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound",
":flutter_dartdevc_canvaskit_kernel_sdk",
":flutter_dartdevc_canvaskit_kernel_sdk_sound",
":flutter_dartdevc_kernel_sdk",
":flutter_dartdevc_kernel_sdk_sound",
":flutter_dartdevc_canvaskit_html_kernel_sdk_amd",
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound_amd",
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound_ddcLibraryBundle",
":flutter_dartdevc_canvaskit_kernel_sdk_amd",
":flutter_dartdevc_canvaskit_kernel_sdk_sound_amd",
":flutter_dartdevc_canvaskit_kernel_sdk_sound_ddcLibraryBundle",
":flutter_dartdevc_kernel_sdk_amd",
":flutter_dartdevc_kernel_sdk_sound_amd",
":flutter_dartdevc_kernel_sdk_sound_ddcLibraryBundle",
]
}
@@ -500,14 +524,21 @@ if (!is_fuchsia) {
deps += [ "//flutter/lib/web_ui/flutter_js" ]
# flutter_ddc_modules
sources = get_target_outputs(":flutter_dartdevc_kernel_sdk")
sources += get_target_outputs(":flutter_dartdevc_canvaskit_kernel_sdk")
sources += get_target_outputs(":flutter_dartdevc_canvaskit_html_kernel_sdk")
sources += get_target_outputs(":flutter_dartdevc_kernel_sdk_sound")
sources = get_target_outputs(":flutter_dartdevc_kernel_sdk_amd")
sources += get_target_outputs(":flutter_dartdevc_canvaskit_kernel_sdk_amd")
sources +=
get_target_outputs(":flutter_dartdevc_canvaskit_kernel_sdk_sound")
get_target_outputs(":flutter_dartdevc_canvaskit_html_kernel_sdk_amd")
sources += get_target_outputs(":flutter_dartdevc_kernel_sdk_sound_amd")
sources +=
get_target_outputs(":flutter_dartdevc_canvaskit_html_kernel_sdk_sound")
get_target_outputs(":flutter_dartdevc_canvaskit_kernel_sdk_sound_amd")
sources += get_target_outputs(
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound_amd")
sources += get_target_outputs(
":flutter_dartdevc_kernel_sdk_sound_ddcLibraryBundle")
sources += get_target_outputs(
":flutter_dartdevc_canvaskit_kernel_sdk_sound_ddcLibraryBundle")
sources += get_target_outputs(
":flutter_dartdevc_canvaskit_html_kernel_sdk_sound_ddcLibraryBundle")
# flutter_platform_dills
sources +=