mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[dart_component] Add dart_component build rule for building dart components for fuchsia. (flutter/engine#33464)
This commit is contained in:
parent
a76ea0f658
commit
b9bcb4ee0b
133
engine/src/flutter/tools/fuchsia/dart/dart_component.gni
Normal file
133
engine/src/flutter/tools/fuchsia/dart/dart_component.gni
Normal file
@ -0,0 +1,133 @@
|
||||
# Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import("//flutter/tools/fuchsia/dart/config.gni")
|
||||
import("//flutter/tools/fuchsia/dart/dart.gni")
|
||||
import("//flutter/tools/fuchsia/flutter/internal/flutter_dart_component.gni")
|
||||
|
||||
# Defines a Dart component which can be used in a fuchsia package
|
||||
#
|
||||
# Dart components require at least one library which contains a main
|
||||
# entry point. The library should be defined using the dart_library.gni.
|
||||
#
|
||||
# ```
|
||||
# dart_library("lib") {
|
||||
# package_name = "my_library"
|
||||
# sources = [ "main.dart" ]
|
||||
# }
|
||||
# ```
|
||||
#
|
||||
# Once a library is defined a dart component can be created which
|
||||
# depends on this package. If the component needs any other resources they may
|
||||
# be defined using the resource target and added to the components deps.
|
||||
#
|
||||
# ```
|
||||
# resource("text-file") {
|
||||
# sources = [ "text_file.txt" ]
|
||||
# outputs = [ "data/text_file.txt" ]
|
||||
# }
|
||||
#
|
||||
# dart_component("my-component") {
|
||||
# manifest = "meta/my-component.cmx"
|
||||
# main_package = "my_library"
|
||||
# deps = [
|
||||
# ":lib",
|
||||
# ":text-file",
|
||||
# ]
|
||||
# }
|
||||
# ```
|
||||
#
|
||||
# Once a component is defined it can be added as a dep of a fuchsia_package
|
||||
# ```
|
||||
# fuchsia_package("my-package") {
|
||||
# deps = [
|
||||
# ":my-component",
|
||||
# ]
|
||||
# }
|
||||
# ```
|
||||
#
|
||||
# Parameters
|
||||
#
|
||||
# manifest (required)
|
||||
# The component manifest
|
||||
# Type: path
|
||||
#
|
||||
# main_package (optional)
|
||||
# The name of the package containing main_dart
|
||||
# Type: string
|
||||
# Default: component_name with dashes replaced by underscores, if defined.
|
||||
# Otherwise, the target_name with dashes replaced by underscores will be
|
||||
# used.
|
||||
#
|
||||
# component_name (optional)
|
||||
# The name of the component.
|
||||
# Type: string
|
||||
# Default: target_name
|
||||
#
|
||||
# main_dart (optional)
|
||||
# File containing the main function of the component.
|
||||
# Type: string
|
||||
# Default: main.dart
|
||||
#
|
||||
# package_root (optional)
|
||||
# The root of the package generated for this component. Each component must
|
||||
# have a unique package_root. For each component, there must be a
|
||||
# pubspec.yaml and an analysis_options.yaml at the package root.
|
||||
# Type: path
|
||||
# Default: "."
|
||||
#
|
||||
# build_cfg (optional)
|
||||
# Specifies the parameters for building the component.
|
||||
# See //build/dart/dart_build_config.gni for predefined configs.
|
||||
#
|
||||
# null_safe (optional)
|
||||
# If true, this component will be compiled with --sound-null-safety
|
||||
#
|
||||
# deps
|
||||
# testonly
|
||||
# visibility
|
||||
template("dart_component") {
|
||||
assert(defined(invoker.manifest), "Must define manifest")
|
||||
|
||||
if (defined(invoker.build_cfg)) {
|
||||
_build_cfg = invoker.build_cfg
|
||||
} else {
|
||||
_build_cfg = dart_default_build_cfg
|
||||
}
|
||||
|
||||
_component_deps = []
|
||||
if (defined(invoker.deps)) {
|
||||
_component_deps += invoker.deps
|
||||
}
|
||||
|
||||
if (defined(invoker.main_dart)) {
|
||||
_main_dart = invoker.main_dart
|
||||
} else {
|
||||
_main_dart = "main.dart"
|
||||
}
|
||||
|
||||
if (defined(invoker.main_package)) {
|
||||
_main_package = invoker.main_package
|
||||
} else if (defined(invoker.component_name)) {
|
||||
_main_package = string_replace(invoker.component_name, "-", "_")
|
||||
} else {
|
||||
_main_package = string_replace(target_name, "-", "_")
|
||||
}
|
||||
|
||||
flutter_dart_component(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
"*",
|
||||
[
|
||||
"main_package",
|
||||
"build_cfg",
|
||||
"deps",
|
||||
"main_dart",
|
||||
"null_safe",
|
||||
])
|
||||
main_package = _main_package
|
||||
deps = _component_deps
|
||||
main_dart = _main_dart
|
||||
build_cfg = _build_cfg
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ _gen_kernel_path =
|
||||
get_label_info(_gen_kernel_label, "root_out_dir") + "/dart-tools/gen_kernel"
|
||||
|
||||
flutter_platform_name = "flutter_runner"
|
||||
dart_platform_name = "dart_runner"
|
||||
|
||||
# Converts the kernel manifest file from fini format to JSON format and
|
||||
# registers the metadata for the fuchsia_package to pick up.
|
||||
@ -211,6 +212,9 @@ template("dart_kernel") {
|
||||
"//flutter/shell/platform/fuchsia/flutter/kernel:kernel_platform_files",
|
||||
]
|
||||
_platform_path = "$root_out_dir/flutter_runner_patched_sdk"
|
||||
} else if (invoker.platform_name == dart_platform_name) {
|
||||
_kernel_deps += [ "//flutter/shell/platform/fuchsia/dart_runner/kernel:kernel_platform_files" ]
|
||||
_platform_path = "$root_out_dir/dart_runner_patched_sdk"
|
||||
} else {
|
||||
assert(false,
|
||||
"platform_name must be either dart_runner or flutter_runner")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user