mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
413 lines
11 KiB
Plaintext
413 lines
11 KiB
Plaintext
# Copyright 2016 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
assert(is_fuchsia || is_fuchsia_host)
|
|
|
|
import("//build/dart/dart_package.gni")
|
|
import("//build/dart/toolchain.gni")
|
|
import("$flutter_root/lib/ui/dart_ui.gni")
|
|
import("//topaz/public/dart-pkg/fuchsia/sdk_ext.gni")
|
|
import("//topaz/public/dart-pkg/zircon/sdk_ext.gni")
|
|
import("//topaz/public/lib/ui/flutter/sdk_ext/sdk_ext.gni")
|
|
|
|
declare_args() {
|
|
flutter_app_default_is_jit = true
|
|
}
|
|
|
|
gen_snapshot_label = "//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)"
|
|
gen_snapshot_dir = get_label_info(gen_snapshot_label, "root_out_dir")
|
|
gen_snapshot = "$gen_snapshot_dir/gen_snapshot"
|
|
|
|
flutter_base = "//third_party/dart-pkg/git/flutter"
|
|
flutter_tools_label =
|
|
"$flutter_base/packages/flutter_tools:fuchsia_builder($host_toolchain)"
|
|
flutter_tools_out_dir = get_label_info(flutter_tools_label, "root_out_dir")
|
|
flutter_tools_bin = "$flutter_tools_out_dir/dart-tools/fuchsia_builder"
|
|
|
|
template("flutter_jit_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",
|
|
"disable_analysis",
|
|
"source_dir",
|
|
])
|
|
if (defined(invoker.package_name)) {
|
|
package_name = invoker.package_name
|
|
} else {
|
|
infer_package_name = true
|
|
}
|
|
}
|
|
|
|
if (defined(invoker.output_name)) {
|
|
bundle_path = "$root_build_dir/${invoker.output_name}"
|
|
} else {
|
|
bundle_path = "$target_gen_dir/${target_name}.flx"
|
|
}
|
|
|
|
flutter_core_snapshot_label = "$flutter_root/lib/snapshot:generate_snapshot_bin"
|
|
flutter_core_snapshot_gen_dir =
|
|
get_label_info(flutter_core_snapshot_label, "target_gen_dir")
|
|
flutter_core_snapshot_vm_data =
|
|
"$flutter_core_snapshot_gen_dir/vm_isolate_snapshot.bin"
|
|
flutter_core_snapshot_vm_instructions =
|
|
"$flutter_core_snapshot_gen_dir/vm_snapshot_instructions.bin"
|
|
flutter_core_snapshot_isolate_data =
|
|
"$flutter_core_snapshot_gen_dir/isolate_snapshot.bin"
|
|
flutter_core_snapshot_isolate_instructions =
|
|
"$flutter_core_snapshot_gen_dir/isolate_snapshot_instructions.bin"
|
|
|
|
dart_target_gen_dir = get_label_info(":bogus($dart_toolchain)", "target_gen_dir")
|
|
dot_packages = "$dart_target_gen_dir/$dart_package_name.packages"
|
|
bundle_depfile = "$bundle_path.d"
|
|
snapshot_path = "$target_gen_dir/${target_name}_snapshot.bin"
|
|
snapshot_depfile = "${snapshot_path}.d"
|
|
|
|
main_dart = invoker.main_dart
|
|
|
|
script_snapshot_label = target_name + "_snapshot"
|
|
|
|
action(script_snapshot_label) {
|
|
depfile = snapshot_depfile
|
|
|
|
inputs = [
|
|
main_dart,
|
|
flutter_core_snapshot_vm_data,
|
|
flutter_core_snapshot_vm_instructions,
|
|
flutter_core_snapshot_isolate_data,
|
|
flutter_core_snapshot_isolate_instructions,
|
|
]
|
|
|
|
outputs = [
|
|
snapshot_path,
|
|
]
|
|
|
|
if (defined(invoker.sources)) {
|
|
sources = invoker.sources
|
|
}
|
|
|
|
script = "$flutter_root/build/script_snapshot.py"
|
|
|
|
args = [
|
|
"--snapshotter-path",
|
|
rebase_path(gen_snapshot),
|
|
"--vm-snapshot-data",
|
|
rebase_path(flutter_core_snapshot_vm_data),
|
|
"--vm-snapshot-instructions",
|
|
rebase_path(flutter_core_snapshot_vm_instructions),
|
|
"--isolate-snapshot-data",
|
|
rebase_path(flutter_core_snapshot_isolate_data),
|
|
"--isolate-snapshot-instructions",
|
|
rebase_path(flutter_core_snapshot_isolate_instructions),
|
|
"--main-dart",
|
|
rebase_path(main_dart),
|
|
"--packages",
|
|
rebase_path(dot_packages),
|
|
"--snapshot",
|
|
rebase_path(snapshot_path, root_build_dir),
|
|
"--depfile",
|
|
rebase_path(snapshot_depfile),
|
|
"--root-build-dir",
|
|
rebase_path(root_build_dir),
|
|
]
|
|
if (is_debug) {
|
|
args += [ "--checked" ]
|
|
}
|
|
|
|
deps = [
|
|
":$dart_package_name",
|
|
flutter_core_snapshot_label,
|
|
gen_snapshot_label,
|
|
]
|
|
|
|
if (defined(invoker.deps)) {
|
|
deps += invoker.deps
|
|
}
|
|
}
|
|
|
|
action(target_name) {
|
|
depfile = bundle_depfile
|
|
|
|
inputs = [
|
|
snapshot_path,
|
|
]
|
|
if (defined(invoker.manifest)) {
|
|
inputs += [ rebase_path(invoker.manifest) ]
|
|
}
|
|
|
|
outputs = [
|
|
bundle_path,
|
|
]
|
|
|
|
script = "$flutter_root/build/package.py"
|
|
|
|
args = [
|
|
"--flutter-root",
|
|
rebase_path(flutter_base),
|
|
"--flutter-tools",
|
|
rebase_path(flutter_tools_bin),
|
|
"--working-dir",
|
|
rebase_path("$target_gen_dir/$target_name/build"),
|
|
"--app-dir",
|
|
rebase_path("."),
|
|
"--packages",
|
|
rebase_path(dot_packages),
|
|
"--output-file",
|
|
rebase_path(bundle_path),
|
|
"--snapshot",
|
|
rebase_path(snapshot_path),
|
|
"--build-root",
|
|
rebase_path(root_build_dir),
|
|
"--depfile",
|
|
rebase_path(bundle_depfile),
|
|
"--interpreter",
|
|
"flutter_jit_runner",
|
|
]
|
|
if (defined(invoker.manifest)) {
|
|
args += [
|
|
"--manifest",
|
|
rebase_path(invoker.manifest),
|
|
]
|
|
}
|
|
|
|
deps = [
|
|
":$script_snapshot_label",
|
|
flutter_tools_label,
|
|
]
|
|
}
|
|
}
|
|
|
|
template("flutter_aot_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",
|
|
"disable_analysis",
|
|
"source_dir",
|
|
])
|
|
if (defined(invoker.package_name)) {
|
|
package_name = invoker.package_name
|
|
} else {
|
|
infer_package_name = true
|
|
}
|
|
}
|
|
|
|
if (defined(invoker.output_name)) {
|
|
bundle_path = "$root_build_dir/${invoker.output_name}"
|
|
} else {
|
|
bundle_path = "$target_gen_dir/${target_name}.flx"
|
|
}
|
|
|
|
dart_target_gen_dir = get_label_info(":bogus($dart_toolchain)", "target_gen_dir")
|
|
dot_packages = "$dart_target_gen_dir/$dart_package_name.packages"
|
|
bundle_depfile = "$bundle_path.d"
|
|
assembly_path = "$target_gen_dir/$target_name.S"
|
|
assembly_depfile = "${assembly_path}.d"
|
|
|
|
main_dart = invoker.main_dart
|
|
|
|
assembly_label = target_name + "_assembly"
|
|
|
|
action(assembly_label) {
|
|
depfile = assembly_depfile
|
|
|
|
inputs = fuchsia_sdk_ext_files + zircon_sdk_ext_files +
|
|
mozart_dart_sdk_ext_files +
|
|
[
|
|
main_dart,
|
|
"$flutter_root/runtime/dart_vm_entry_points.txt",
|
|
"$flutter_root/runtime/dart_vm_entry_points_fuchsia.txt",
|
|
"//third_party/dart/runtime/bin/dart_io_entries.txt",
|
|
]
|
|
|
|
outputs = [
|
|
assembly_path,
|
|
]
|
|
|
|
if (defined(invoker.sources)) {
|
|
sources = invoker.sources
|
|
}
|
|
|
|
script = "$flutter_root/build/aot_snapshot.py"
|
|
args = [
|
|
"--snapshotter-path",
|
|
rebase_path(gen_snapshot),
|
|
"--assembly",
|
|
rebase_path(assembly_path, root_build_dir),
|
|
"--packages",
|
|
rebase_path(dot_packages),
|
|
"--depfile",
|
|
rebase_path(assembly_depfile),
|
|
|
|
"--url-mapping",
|
|
"dart:ui," + rebase_path(dart_ui_path),
|
|
"--url-mapping",
|
|
"dart:zircon," + rebase_path(zircon_sdk_ext_lib),
|
|
"--url-mapping",
|
|
"dart:fuchsia," + rebase_path(fuchsia_sdk_ext_lib),
|
|
"--url-mapping",
|
|
"dart:mozart.internal," + rebase_path(mozart_dart_sdk_ext_lib),
|
|
"--url-mapping",
|
|
"dart:vmservice_io," + rebase_path(
|
|
"$dart_root_gen_dir/dart-pkg/sky_engine/sdk_ext/vmservice_io.dart"),
|
|
|
|
"--entry-points-manifest",
|
|
rebase_path("$flutter_root/runtime/dart_vm_entry_points.txt"),
|
|
"--entry-points-manifest",
|
|
rebase_path("$flutter_root/runtime/dart_vm_entry_points_fuchsia.txt"),
|
|
"--entry-points-manifest",
|
|
rebase_path("//third_party/dart/runtime/bin/dart_io_entries.txt"),
|
|
|
|
"--main-dart",
|
|
rebase_path(main_dart),
|
|
"--root-build-dir",
|
|
rebase_path(root_build_dir),
|
|
]
|
|
if (is_debug) {
|
|
args += [ "--checked" ]
|
|
}
|
|
|
|
deps = [
|
|
":$dart_package_name",
|
|
"$flutter_root/lib/snapshot:generate_dart_ui",
|
|
gen_snapshot_label,
|
|
]
|
|
|
|
if (defined(invoker.deps)) {
|
|
deps += invoker.deps
|
|
}
|
|
}
|
|
|
|
dylib_label = target_name + "_dylib"
|
|
|
|
outer_target_name = target_name
|
|
shared_library(dylib_label) {
|
|
deps = [
|
|
":$assembly_label",
|
|
]
|
|
sources = [
|
|
assembly_path,
|
|
]
|
|
cflags = [
|
|
"-nostdlib",
|
|
"-nostartfiles",
|
|
]
|
|
output_name = outer_target_name
|
|
}
|
|
|
|
dylib_path =
|
|
get_label_info(":$dylib_label($shlib_toolchain)", "root_out_dir") +
|
|
"/lib.unstripped/lib$target_name.so"
|
|
|
|
action(target_name) {
|
|
depfile = bundle_depfile
|
|
|
|
inputs = [
|
|
dylib_path,
|
|
]
|
|
if (defined(invoker.manifest)) {
|
|
inputs += [ rebase_path(invoker.manifest) ]
|
|
}
|
|
|
|
outputs = [
|
|
bundle_path,
|
|
]
|
|
|
|
script = "$flutter_root/build/package.py"
|
|
|
|
args = [
|
|
"--flutter-root",
|
|
rebase_path(flutter_base),
|
|
"--flutter-tools",
|
|
rebase_path(flutter_tools_bin),
|
|
"--working-dir",
|
|
rebase_path("$target_gen_dir/$target_name/build"),
|
|
"--app-dir",
|
|
rebase_path("."),
|
|
"--packages",
|
|
rebase_path(dot_packages),
|
|
"--output-file",
|
|
rebase_path(bundle_path),
|
|
"--dylib",
|
|
rebase_path(dylib_path),
|
|
"--build-root",
|
|
rebase_path(root_build_dir),
|
|
"--depfile",
|
|
rebase_path(bundle_depfile),
|
|
"--interpreter",
|
|
"flutter_aot_runner",
|
|
]
|
|
if (defined(invoker.manifest)) {
|
|
args += [
|
|
"--manifest",
|
|
rebase_path(invoker.manifest),
|
|
]
|
|
}
|
|
|
|
deps = [
|
|
":$dylib_label",
|
|
flutter_tools_label,
|
|
]
|
|
}
|
|
}
|
|
|
|
# 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.
|
|
#
|
|
# manifest (optional)
|
|
# Path to the manifest file
|
|
#
|
|
# disable_analysis (optional)
|
|
# Prevents analysis from being run on this target.
|
|
template("flutter_app") {
|
|
if (flutter_app_default_is_jit) {
|
|
flutter_jit_app(target_name) {
|
|
forward_variables_from(invoker,
|
|
[
|
|
"main_dart",
|
|
"package_name",
|
|
"output_name",
|
|
"deps",
|
|
"manifest",
|
|
"disable_analysis",
|
|
"source_dir",
|
|
])
|
|
}
|
|
} else {
|
|
flutter_aot_app(target_name) {
|
|
forward_variables_from(invoker,
|
|
[
|
|
"main_dart",
|
|
"package_name",
|
|
"output_name",
|
|
"deps",
|
|
"manifest",
|
|
"disable_analysis",
|
|
"source_dir",
|
|
])
|
|
}
|
|
}
|
|
}
|