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

Commit f372d23

Browse files
authored
[fuchsia] Create DartComponentController for CFv2. (#28613)
Bug: fxb/79871 The code is still using the CFv1 implementation, so this should not affect the existing behavior. For this version of the PR, I forked the existing DartComponentController. There were a few reasons for this: Reduces the chance of the change breaking existing tests during Fuchsia GI. Makes the V2 version of the DartComponentController simpler to read. Makes it easier to switch over to using the V2 version of the DartComponentController once the migration is ready to happen (less cleanup). The rate of changes to the DartComponentController is slow so there shouldn't be much maintenance required for the fork. Changes to the DartRunner itself will happen in a follow-up PR - this PR only verifies that the ComponentController builds. Relands GN and C++ changes for #27226 after rollback in #28036.
1 parent c93be1a commit f372d23

File tree

7 files changed

+624
-4
lines changed

7 files changed

+624
-4
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,8 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/builtin_libraries.cc
13701370
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/builtin_libraries.h
13711371
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.cc
13721372
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_component_controller.h
1373+
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc
1374+
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_component_controller_v2.h
13731375
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_runner.cc
13741376
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/dart_runner.h
13751377
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/embedder/builtin.dart

shell/platform/fuchsia/dart-pkg/fuchsia/sdk_ext/fuchsia.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,13 @@ void Initialize(fidl::InterfaceHandle<fuchsia::sys::Environment> environment,
117117
dart_state->class_library().add_provider("fuchsia",
118118
std::move(fuchsia_class_provider));
119119

120-
result = Dart_SetField(
121-
library, ToDart("_environment"),
122-
ToDart(zircon::dart::Handle::Create(environment.TakeChannel())));
123-
FML_CHECK(!tonic::LogIfError(result));
120+
// V2 components do not use the environment.
121+
if (environment) {
122+
result = Dart_SetField(
123+
library, ToDart("_environment"),
124+
ToDart(zircon::dart::Handle::Create(environment.TakeChannel())));
125+
FML_CHECK(!tonic::LogIfError(result));
126+
}
124127

125128
if (directory_request) {
126129
result = Dart_SetField(

shell/platform/fuchsia/dart-pkg/fuchsia/sdk_ext/fuchsia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace fuchsia {
1111
namespace dart {
1212

13+
/// Initializes Dart bindings for the Fuchsia application model.
1314
void Initialize(fidl::InterfaceHandle<fuchsia::sys::Environment> environment,
1415
zx::channel directory_request,
1516
std::optional<zx::eventpair> view_ref);

shell/platform/fuchsia/dart_runner/BUILD.gn

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ template("runner") {
3838
"builtin_libraries.h",
3939
"dart_component_controller.cc",
4040
"dart_component_controller.h",
41+
"dart_component_controller_v2.cc",
42+
"dart_component_controller_v2.h",
4143
"dart_runner.cc",
4244
"dart_runner.h",
4345
"logging.h",
@@ -69,6 +71,7 @@ template("runner") {
6971
"//flutter/fml",
7072
"//flutter/shell/platform/fuchsia/dart-pkg/fuchsia",
7173
"//flutter/shell/platform/fuchsia/dart-pkg/zircon",
74+
"$fuchsia_sdk_root/fidl:fuchsia.component.runner",
7275
"$fuchsia_sdk_root/pkg:async",
7376
"$fuchsia_sdk_root/pkg:async-cpp",
7477
"$fuchsia_sdk_root/pkg:async-default",
@@ -160,6 +163,7 @@ template("aot_runner_package") {
160163
binary = "dart_aot${product_suffix}_runner"
161164

162165
cmx_file = rebase_path("meta/dart_aot${product_suffix}_runner.cmx")
166+
cml_file = rebase_path("meta/dart_aot${product_suffix}_runner.cml")
163167

164168
libraries = _common_runner_libs
165169

@@ -220,6 +224,7 @@ template("jit_runner_package") {
220224
binary = "dart_jit${product_suffix}_runner"
221225

222226
cmx_file = rebase_path("meta/dart_jit${product_suffix}_runner.cmx")
227+
cml_file = rebase_path("meta/dart_jit${product_suffix}_runner.cml")
223228

224229
libraries = _common_runner_libs
225230

0 commit comments

Comments
 (0)