blob: cda49e68d970d9e885c5d637ccd844ffad63ad05 [file] [log] [blame]
# Copyright 2016 The Fuchsia 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("//build/package.gni")
import("//build/tools/json_merge/json_merge.gni")
import("//third_party/dart/build/dart/dart_action.gni")
import("//topaz/runtime/dart/config.gni")
import("//topaz/runtime/dart/dart_component.gni")
import("//topaz/runtime/dart/dart_kernel.gni")
template("_dart_jit_component") {
legacy_component = false
pkg_name = target_name
if (!defined(invoker.components)) {
# If components is not specified, we are fitting main_dart into a component
# scope, and using that for the package.
#
# TODO(CP-141): Remove support for legacy_component once all existing calls
# to dart_app() have a components parameter.
legacy_component = true
if (defined(invoker.fuchsia_package_name)) {
legacy_component_name = invoker.fuchsia_package_name
} else {
legacy_component_name = target_name
}
pkg_name = legacy_component_name
pkg_sources = []
if (defined(invoker.sources)) {
pkg_sources = invoker.sources
}
components = [
{
main_dart = invoker.main_dart
component_name = legacy_component_name
component_type = "dart"
deps = invoker.deps
sources = pkg_sources
}
]
}
flutter_dart_jit_component(target_name) {
forward_variables_from(invoker, "*")
}
}
template("_dart_aot_component") {
legacy_component = false
pkg_name = target_name
if (!defined(invoker.components)) {
# If components is not specified, we are fitting main_dart into a component
# scope, and using that for the package.
#
# TODO(CP-141): Remove support for legacy_component once all existing calls
# to dart_app() have a components parameter.
legacy_component = true
if (defined(invoker.fuchsia_package_name)) {
legacy_component_name = invoker.fuchsia_package_name
} else {
legacy_component_name = target_name
}
pkg_name = legacy_component_name
pkg_sources = []
if (defined(invoker.sources)) {
pkg_sources = invoker.sources
}
components = [
{
main_dart = invoker.main_dart
component_name = legacy_component_name
component_type = "dart"
deps = invoker.deps
sources = pkg_sources
}
]
}
flutter_dart_aot_component(target_name) {
forward_variables_from(invoker, "*")
}
}
template("dart_jit_app") {
template_name = "_dart_jit_component"
if (dart_force_product) {
template_name = dart_product_app
}
target(template_name, target_name) {
forward_variables_from(invoker, "*")
}
}
template("dart_aot_app") {
template_name = "_dart_aot_component"
if (dart_force_product) {
template_name = dart_product_app
}
target(template_name, target_name) {
forward_variables_from(invoker, "*")
}
}
# Defines a Dart application that can be run in the Dart content handler
#
# Parameters
#
# package_name (optional)
# Name of the dart package.
#
# main_dart (required)
# File containing the main function of the application. Either main_dart or
# components must be defined, but not both.
#
# deps (optional)
# Dependencies of this application
#
# fuchsia_package_name (optional)
# Name of the output Fuchsia package to generate. Defaults to ${target_name}
#
# disable_analysis (optional)
# Prevents analysis from being run on this target.
#
# resources (optional)
# Resources for the package (see //build/package.gni)
#
# tests (optional)
# List of tests forwarded for the package. See the definition in //build/package.gni.
#
# product (optional)
# A boolean. Whether to build/run the app in a stripped-down Dart VM.
# Defaults to !is_debug.
#
# components (required)
# [list of scopes] Defines the components in the package. Either main_dart
# or components must be defined, but not both.
#
# Entries in a scope in the resources list:
#
# component_name (required)
# Name of the component.
#
# main_dart (required)
# File containing the main function of the component.
template("dart_app") {
assert((defined(invoker.components) && !defined(invoker.main_dart)) ||
(!defined(invoker.components) && defined(invoker.main_dart)),
"Only one of components or main_dart should be defined")
target(dart_default_app, target_name) {
forward_variables_from(invoker, "*")
}
}