提交 dcb02618 编写于 作者: J James Robinson 提交者: GitHub

[build] Add new flutter_app GN template for Fuchsia style package management (#2999)

上级 9dc8de12
...@@ -2,37 +2,60 @@ ...@@ -2,37 +2,60 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
template("flx") { assert(is_fuchsia)
import("//build/dart/dart_package.gni")
# Defines a Flutter application
#
# Parameters
#
# main_dart (required)
# Name of the Dart file containing the main function.
#
# package_name (optional)
# Name of the Dart package.
#
# output_name (optional)
# Name of output to generate. Defaults to $target_name.flx.
#
# deps (optional)
# List of Dart packages the application depends on.
template("flutter_app") {
assert(defined(invoker.main_dart), "Must define main_dart")
dart_package_name = target_name + "_dart_package"
dart_package(dart_package_name) {
forward_variables_from(invoker, [ "deps" ])
if (defined(invoker.package_name)) {
package_name = invoker.package_name
} else {
infer_package_name = true
}
}
if (defined(invoker.output_name)) { if (defined(invoker.output_name)) {
bundle_name = invoker.output_name bundle_name = invoker.output_name
} else { } else {
bundle_name = "${target_name}.flx" bundle_name = "${target_name}.flx"
} }
flutter_snapshot_label = "//flutter/snapshotter($host_toolchain)"
flutter_snapshot_dir = get_label_info(flutter_snapshot_label, "root_out_dir")
flutter_snapshot = "$flutter_snapshot_dir/sky_snapshot"
bundle_path = "$root_out_dir/$bundle_name" bundle_path = "$root_out_dir/$bundle_name"
snapshot_path = "$target_gen_dir/${target_name}_snapshot.bin" snapshot_path = "$target_gen_dir/${target_name}_snapshot.bin"
depfile_path = "${snapshot_path}.d" depfile_path = "${snapshot_path}.d"
main_dart = invoker.main_dart main_dart = invoker.main_dart
if (defined(invoker.packages)) {
packages_path = invoker.packages
} else {
main_dir = get_path_info(main_dart, "dir")
package_dir = get_path_info(main_dir, "dir")
packages_path = "$package_dir/.packages"
}
sky_snapshot_label = "//flutter/snapshotter($host_toolchain)"
sky_snapshot_dir = get_label_info(sky_snapshot_label, "root_out_dir")
sky_snapshot = "$sky_snapshot_dir/sky_snapshot"
action(target_name) { action(target_name) {
depfile = depfile_path depfile = depfile_path
inputs = [ inputs = [
main_dart, main_dart,
packages_path,
] ]
outputs = [ outputs = [
...@@ -47,18 +70,26 @@ template("flx") { ...@@ -47,18 +70,26 @@ template("flx") {
script = "//flutter/build/package.py" script = "//flutter/build/package.py"
args = [ args = [
"--snapshotter", rebase_path(sky_snapshot), "--snapshotter",
"--main-dart", rebase_path(main_dart), rebase_path(flutter_snapshot),
"--packages", rebase_path(packages_path), "--main-dart",
"--bundle", rebase_path(bundle_path), rebase_path(main_dart),
"--bundle-header", "#!mojo mojo:flutter_content_handler", "--packages",
"--snapshot", rebase_path(snapshot_path), rebase_path("$target_gen_dir/.packages"),
"--depfile", rebase_path(depfile_path), "--bundle",
"--build-output", rebase_path(bundle_path, root_build_dir), rebase_path(bundle_path),
"--bundle-header",
"#!mojo mojo:flutter_content_handler",
"--snapshot",
rebase_path(snapshot_path),
"--depfile",
rebase_path(depfile_path),
"--build-output",
rebase_path(bundle_path, root_build_dir),
] ]
deps = [ deps = [
sky_snapshot_label, flutter_snapshot_label,
] ]
if (defined(invoker.deps)) { if (defined(invoker.deps)) {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//flutter/build/flx.gni") import("//flutter/build/flutter_app.gni")
flx("spinning_square") { flutter_app("spinning_square") {
main_dart = "lib/main.dart" main_dart = "lib/main.dart"
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册