| # 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/package.gni") |
| import("//build/tools/json_merge/json_merge.gni") |
| import("//peridot/build/module_manifest.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") |
| |
| # Defines JIT runtime components to be further distributed in one package. |
| # |
| # Takes a set of flutter components and puts them into one fuchsia package with |
| # the flutter_jit_runner as its runtime. Also supports legacy calls where the |
| # components parameter isn't specified, in which we will create one default |
| # component for the package. |
| # |
| # Parameters |
| # |
| # 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. |
| # |
| # main_dart (required) |
| # File containing the main function of the application. Either main_dart or |
| # components must be defined, but not both. |
| template("_flutter_jit_component") { |
| pkg_name = target_name |
| legacy_component = false |
| 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-140): Remove support for legacy_component once all existing calls |
| # to flutter_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 = "flutter" |
| deps = invoker.deps |
| sources = pkg_sources |
| } |
| ] |
| } |
| flutter_dart_jit_component(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| } |
| |
| # Defines AOT runtime components to be further distributed in one package. |
| # |
| # Takes a set of flutter components and puts them into one fuchsia package with |
| # the flutter_aot_runner as its runtime. Also supports legacy calls where the |
| # components parameter isn't specified, in which we will create one default |
| # component for the package. |
| # |
| # Parameters |
| # |
| # 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. |
| # |
| # main_dart (required) |
| # File containing the main function of the application. Either main_dart or |
| # components must be defined, but not both. |
| template("_flutter_aot_component") { |
| # This variable isn't needed in AOT builds. |
| if (defined(invoker.flutter_driver_extendable)) { |
| not_needed(invoker, ["flutter_driver_extendable",]) |
| } |
| pkg_name = target_name |
| legacy_component = false |
| 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-140): Remove support for legacy_component once all existing calls |
| # to flutter_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 = "flutter" |
| deps = invoker.deps |
| sources = pkg_sources |
| } |
| ] |
| } |
| flutter_dart_aot_component(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| } |
| |
| template("flutter_jit_app") { |
| template_name = "_flutter_jit_component" |
| if (dart_force_product) { |
| template_name = flutter_product_app |
| } |
| |
| target(template_name, target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| } |
| |
| template("flutter_aot_app") { |
| template_name = "_flutter_aot_component" |
| if (dart_force_product) { |
| template_name = flutter_product_app |
| } |
| |
| target(template_name, target_name) { |
| forward_variables_from(invoker, "*", ["space_dart"]) |
| } |
| } |
| |
| # Defines a Flutter application |
| # |
| # Parameters |
| # |
| # main_dart (required) |
| # Name of the Dart file containing the main function. Either main_dart or |
| # components must be defined, but not both. |
| # |
| # package_name (optional) |
| # Name of the Dart package. |
| # |
| # fuchsia_package_name (optional) |
| # Name of the Fuchsia package. |
| # |
| # 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. |
| # |
| # product (optional) |
| # A boolean. Whether to build/run the app in a stripped-down Dart VM. |
| # Defaults to !is_debug. |
| # |
| # flutter_driver_extendable (optional) |
| # A boolean. Determines if, in a debug build, this package will be built |
| # with a wrapper that auto-enables flutter driver extensions when running |
| # the application in a an environment that includes TestRunner. Does not |
| # affect AOT or release builds. |
| # |
| # 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("flutter_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(flutter_default_app, target_name) { |
| forward_variables_from(invoker, "*", [ "aot" ]) |
| } |
| } |