Skip to content

Commit 2585976

Browse files
author
Rich Kadel
authored
Fix building Dart Fuchsia components and packages (flutter#28413)
1 parent b64a83a commit 2585976

39 files changed

Lines changed: 1249 additions & 452 deletions

‎DEPS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ deps = {
393393
'src/third_party/fontconfig/src':
394394
Var('chromium_git') + '/external/fontconfig.git' + '@' + 'c336b8471877371f0190ba06f7547c54e2b890ba',
395395

396+
'src/third_party/pyyaml':
397+
Var('fuchsia_git') + '/third_party/pyyaml.git' + '@' + '25e97546488eee166b1abb229a27856cecd8b7ac',
398+
396399
# Headers for Vulkan 1.1
397400
'src/third_party/vulkan':
398401
Var('github_git') + '/KhronosGroup/Vulkan-Docs.git' + '@' + 'v1.1.91',

‎ci/licenses_golden/tool_signature‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: 556bb3a9c92c7ac1fb27943070183aae
1+
Signature: 0836a8bd0db33f4a7dc3d5cd71458955
22

‎shell/platform/fuchsia/dart-pkg/zircon/BUILD.gn‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ source_set("zircon") {
3535
"//flutter/third_party/tonic",
3636
]
3737
}
38+
39+
source_set("test") {
40+
testonly = true
41+
deps = [ "test" ]
42+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
import("//build/fuchsia/sdk.gni")
6+
import("//flutter/tools/fuchsia/dart/dart_library.gni")
7+
import("//flutter/tools/fuchsia/flutter/flutter_component.gni")
8+
import("//flutter/tools/fuchsia/gn-sdk/package.gni")
9+
10+
dart_library("dart_library") {
11+
testonly = true
12+
package_name = "channel_test"
13+
14+
language_version = "2.12"
15+
16+
source_dir = "."
17+
18+
sources = [
19+
"channel_test.dart",
20+
"eventpair_test.dart",
21+
"handle_disposition_test.dart",
22+
"handle_test.dart",
23+
"socket_test.dart",
24+
"vmo_test.dart",
25+
]
26+
27+
deps = [
28+
"//flutter/shell/platform/fuchsia/dart:litetest",
29+
"//flutter/tools/fuchsia/dart:zircon",
30+
]
31+
}
32+
33+
flutter_component("channel_test_flutter_component") {
34+
testonly = true
35+
36+
main_package = "channel_test"
37+
component_name = "channel_test"
38+
main_dart = "channel_test.dart"
39+
manifest = rebase_path("meta/channel_test.cmx")
40+
deps = [ ":dart_library" ]
41+
}
42+
43+
# TODO(richkadel): The target name is set differently compared to fuchsia.git's flutter_app().
44+
# Unlike in fuchsia.git's version of fuchsia_component, the Fuchsia GN SDK
45+
# version passes the component name to fuchsia_component via it's target_name only.
46+
# GN SDK's fuchsia_component doesn't have a `component_name` argument! So I'm forced to set
47+
# the component name via "target_name". This is a problem in fuchsia_package, which uses
48+
# the target_name to name the fuchsia_pm_tool target, creating duplicate target IDs!
49+
# So I have to change the fuchsia_package name to something that is NOT the component name,
50+
# and then set the package_name (which fuchsia_package does support).
51+
fuchsia_package("channel_test_package") {
52+
testonly = true
53+
package_name = "channel_test"
54+
deps = [ ":channel_test_flutter_component" ]
55+
}
56+
57+
group("test") {
58+
testonly = true
59+
deps = [ ":channel_test_package" ]
60+
}

‎shell/platform/fuchsia/dart-pkg/zircon/test/channel_test.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import 'dart:async';
66
import 'dart:convert';
77
import 'dart:typed_data';
88

9-
import 'package:test/test.dart';
9+
import 'package:litetest/litetest.dart';
10+
1011
import 'package:zircon/zircon.dart';
1112

1213
/// Helper method to turn a [String] into a [ByteData] containing the
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"program": {
3+
"data": "data/channel_test"
4+
},
5+
"sandbox": {
6+
"services": [
7+
"fuchsia.sys.Environment"
8+
]
9+
}
10+
}

‎shell/platform/fuchsia/dart/BUILD.gn‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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/tools/fuchsia/dart/dart_library.gni")
56
import("//third_party/dart/build/dart/dart_action.gni")
67
import("//third_party/dart/utils/application_snapshot.gni")
78
import("//third_party/dart/utils/compile_platform.gni")
@@ -48,3 +49,68 @@ application_snapshot("list_libraries") {
4849
"/flutter/shell/platform/fuchsia/dart/list_libraries.dart.dill"),
4950
]
5051
}
52+
53+
dart_library("async_helper") {
54+
package_root = "//third_party/dart/pkg/async_helper"
55+
package_name = "async_helper"
56+
57+
language_version = "2.12"
58+
59+
deps = []
60+
61+
sources = [
62+
"async_helper.dart",
63+
"async_minitest.dart",
64+
]
65+
}
66+
67+
dart_library("expect") {
68+
package_root = "//third_party/dart/pkg/expect"
69+
package_name = "expect"
70+
71+
language_version = "2.12"
72+
73+
deps = [ ":meta" ]
74+
75+
sources = [
76+
"expect.dart",
77+
"minitest.dart",
78+
]
79+
}
80+
81+
dart_library("litetest") {
82+
package_root = "//flutter/testing/litetest"
83+
package_name = "litetest"
84+
85+
language_version = "2.12"
86+
87+
source_dir = "lib"
88+
89+
deps = [
90+
":async_helper",
91+
":expect",
92+
":meta",
93+
]
94+
95+
sources = [
96+
"litetest.dart",
97+
"src/matchers.dart",
98+
"src/test.dart",
99+
"src/test_suite.dart",
100+
]
101+
}
102+
103+
dart_library("meta") {
104+
package_root = "//third_party/dart/pkg/meta"
105+
package_name = "meta"
106+
107+
language_version = "2.12"
108+
109+
deps = []
110+
111+
sources = [
112+
"dart2js.dart",
113+
"meta.dart",
114+
"meta_meta.dart",
115+
]
116+
}

‎testing/litetest/lib/litetest.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:expect/expect.dart'; // ignore: unused_import
1010
import 'src/matchers.dart'; // ignore: unused_import
1111
import 'src/test_suite.dart';
1212

13-
export 'package:async_helper/async_minitest.dart' hide group, test;
13+
export 'package:async_helper/async_minitest.dart' hide test;
1414
export 'package:expect/expect.dart';
1515
export 'src/matchers.dart';
1616

‎tools/fuchsia/dart/dart_build_config.gni‎

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,42 @@ dart_debug_build_cfg = {
1313
enable_asserts = true
1414
}
1515

16-
# Builds the component in a non-product AOT build. This will
17-
# launch the vm service in the runner.
18-
# This configuration is not compatible with a --release build since the
19-
# profile aot runner is built without asserts.
20-
dart_aot_debug_build_cfg = {
21-
runtime_meta = "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime"
22-
runner_dep = "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_runner"
23-
platform_name = "dart_runner"
24-
is_aot = true
25-
is_product = false
26-
enable_asserts = true
27-
}
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?
2818

29-
# Builds the component in a non-product AOT build. This will
30-
# launch the vm service in the runner.
31-
dart_profile_build_cfg = {
32-
runtime_meta = "//flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime"
33-
runner_dep = "//flutter/shell/platform/fuchsia/dart_runner:dart_aot_runner"
34-
platform_name = "dart_runner"
35-
is_aot = true
36-
is_product = false
37-
enable_asserts = false
38-
}
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+
# }
3931

40-
# Builds the component in a product AOT build. This will
41-
# not launch the vm service in the runner.
42-
dart_release_build_cfg = {
43-
runtime_meta =
44-
"//flutter/shell/platform/fuchsia/dart_runner/meta/aot_product_runtime"
45-
runner_dep =
46-
"//flutter/shell/platform/fuchsia/dart_runner:dart_aot_product_runner"
47-
platform_name = "dart_runner"
48-
is_aot = true
49-
is_product = true
50-
enable_asserts = false
51-
}
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+
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+
# }

‎tools/fuchsia/dart/dart_library.gni‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import("//flutter/tools/fuchsia/dart/dart.gni")
66
import("//flutter/tools/fuchsia/dart/dart_package_config.gni")
77
import("//flutter/tools/fuchsia/dart/toolchain.gni")
8-
import("//flutter/tools/python/python3_action.gni")
98

109
# Defines a Dart library
1110
#
@@ -248,7 +247,7 @@ if (current_toolchain == dart_toolchain) {
248247
# Also warn if nonexistent files are included in sources.
249248
if (!disable_source_verification) {
250249
source_verification_target_name = "${target_name}_source_verification"
251-
python3_action(source_verification_target_name) {
250+
action(source_verification_target_name) {
252251
script = "//flutter/tools/fuchsia/dart/verify_sources.py"
253252
output_file = "$target_gen_dir/$target_name.missing"
254253

@@ -293,7 +292,7 @@ if (current_toolchain == dart_toolchain) {
293292
# analyzer, which recursively reads all sources.
294293
_all_deps_sources_target = "${target_name}.all_deps_sources"
295294
_all_deps_sources_file = "${target_gen_dir}/${target_name}.all_deps_sources"
296-
python3_action(_all_deps_sources_target) {
295+
action(_all_deps_sources_target) {
297296
forward_variables_from(invoker, [ "testonly" ])
298297

299298
script = "//flutter/tools/fuchsia/dart/merge_deps_sources.py"

0 commit comments

Comments
 (0)