diff --git a/engine/src/flutter/tools/fuchsia/dist/resource.gni b/engine/src/flutter/tools/fuchsia/dist/resource.gni deleted file mode 100644 index 2ce8be2315..0000000000 --- a/engine/src/flutter/tools/fuchsia/dist/resource.gni +++ /dev/null @@ -1,96 +0,0 @@ -# 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. - -# Declare data files to be accessible at runtime on the target device. -# -# A resource() target looks just like a copy() target but $outputs are -# relative target paths. Using $data_deps to this resource() target in -# each target whose code uses $outputs at runtime ensures that the files -# will be present on the system. -# -# If the file is not in the source tree, it should be generated by another -# target in the build listed in $deps. If that would be a generated_file() -# target, then use generated_resource() instead of resource(). -# -# Parameters -# -# data_deps -# Optional: Additional dependencies for the runtime image. These are -# included in the image if this target is, but are not related to the -# $sources list. -# Type: list(label) -# -# deps -# Optional: Targets that produce $sources. Any files listed in -# $sources that are produced by the build should be produced by a -# target listed here. This is the only thing that guarantees those -# files will have been built by the time the image is being packed. -# Targets reached only via this $deps list will *not* contribute their -# own contents to the image directly. For that, list them in $data_deps. -# Targets listed here are used only to produce the $sources files. -# Type: list(label) -# -# outputs -# Required: List of one runtime path. This must be a relative path (no -# leading `/`). It can use placeholders based on $sources; see copy() -# and `gn help source_expansion`. When this resource() target is in -# the dependency graph of a zbi() target, then this is the path within -# the BOOTFS, which appears at /boot in the namespace of early-boot and -# standalone Zircon processes. -# Type: list(path) -# -# sources -# Required: List of files in the source tree or build that become $outputs. -# See copy() for details. -# Type: list(file) -# -# See copy() for other parameters. -template("resource") { - if (invoker.sources != []) { - _label = get_label_info(":$target_name", "label_with_toolchain") - } - - group(target_name) { - forward_variables_from(invoker, - "*", - [ - "metadata", - "outputs", - "sources", - ]) - metadata = { - # Used by the distribution_manifest() template. - distribution_entries_barrier = [] - distribution_entries = [] - - # Used by the zbi() template. - zbi_input_barrier = [] - - if (defined(invoker.metadata)) { - forward_variables_from(invoker.metadata, "*") - } - - # Stop *_manifest() and zbi_test() from picking up files or - # zbi_input() items from the deps, but let them reach the data_deps. - if (defined(data_deps)) { - distribution_entries_barrier += data_deps - zbi_input_barrier += data_deps - } - - foreach(source, invoker.sources) { - foreach(target, process_file_template([ source ], invoker.outputs)) { - assert(rebase_path(target, "foo") != target, - "`outputs` in resource() cannot start with /") - distribution_entries += [ - { - source = rebase_path(source, root_build_dir) - destination = target - label = _label - }, - ] - } - } - } - } -} diff --git a/engine/src/flutter/tools/fuchsia/flutter/flutter_component.gni b/engine/src/flutter/tools/fuchsia/flutter/flutter_component.gni index 4be1f1a289..3e43e1634a 100644 --- a/engine/src/flutter/tools/fuchsia/flutter/flutter_component.gni +++ b/engine/src/flutter/tools/fuchsia/flutter/flutter_component.gni @@ -22,17 +22,18 @@ import("//flutter/tools/fuchsia/flutter/internal/flutter_dart_component.gni") # # Once a library is defined a flutter 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. +# be defined in the `resources` variable. # # ``` -# resource("text-file") { -# sources = [ "text_file.txt" ] -# outputs = [ "data/text_file.txt" ] -# } -# # flutter_component("my-component") { # manifest = "meta/my-component.cmx" # main_package = "my_library" +# resources = [ +# { +# path = "text_file.txt" +# dest = "data/text_file.txt" +# }, +# ] # deps = [ # ":lib", # ":text-file", @@ -133,6 +134,7 @@ template("flutter_component") { "main_dart", "main_package", "component_name", + "resources", ]) deps = _component_deps diff --git a/engine/src/flutter/tools/fuchsia/flutter/internal/flutter_dart_component.gni b/engine/src/flutter/tools/fuchsia/flutter/internal/flutter_dart_component.gni index 23c3217159..49529d23c0 100644 --- a/engine/src/flutter/tools/fuchsia/flutter/internal/flutter_dart_component.gni +++ b/engine/src/flutter/tools/fuchsia/flutter/internal/flutter_dart_component.gni @@ -7,7 +7,6 @@ import("//flutter/tools/fuchsia/dart/config.gni") import("//flutter/tools/fuchsia/dart/dart.gni") import("//flutter/tools/fuchsia/dart/dart_package_config.gni") import("//flutter/tools/fuchsia/dart/kernel/dart_kernel.gni") -import("//flutter/tools/fuchsia/dist/resource.gni") import("//flutter/tools/fuchsia/gn-sdk/cmc.gni") import("//flutter/tools/fuchsia/gn-sdk/component.gni") @@ -71,6 +70,11 @@ template("flutter_dart_component") { _component_name = target_name } + _resources = [] + if (defined(invoker.resources)) { + _resources = invoker.resources + } + # Flutter and Dart components need to run inside the runner which matches how # they were compiled, for example, a JIT component must run in the JIT runner. # We need to be able to dynamically convert the manifest files to include the @@ -231,20 +235,7 @@ template("flutter_dart_component") { args += [ rebase_path(_kernel_path, root_build_dir) ] } - # copy the snapshot as a resource - _snapshot_resource_target_name = "${target_name}_snapshot_resource" - - # TODO(richkadel): It looks like this is the _ONLY_ place resource() is used - # and maybe that logic should simply be embedded here, directly? - resource(_snapshot_resource_target_name) { - sources = [ _snapshot_path ] - outputs = [ "data/${_component_name}/app_aot_snapshot.so" ] - } - - _component_deps += [ - ":$_snapshot_resource_target_name", - ":$_snapshot_target_name", - ] + _component_deps += [ ":$_snapshot_target_name" ] } fuchsia_component(_component_name) { @@ -257,7 +248,14 @@ template("flutter_dart_component") { manifest = _manifest manifest_output_name = _manifest_output_name - if (!build_cfg.is_aot) { + if (build_cfg.is_aot) { + _resources += [ + { + path = _snapshot_path + dest = "data/${_component_name}/app_aot_snapshot.so" + }, + ] + } else { _convert_kernel_target_name = "${_kernel_target_name}_convert_kernel_manifest" _convert_kernel_manifest_file = @@ -274,6 +272,8 @@ template("flutter_dart_component") { # at some point during the build/compile phase. resources_in_json_files = [ rebase_path(_convert_kernel_manifest_file) ] } + + resources = _resources } group(target_name) { diff --git a/engine/src/flutter/tools/fuchsia/gn-sdk/component.gni b/engine/src/flutter/tools/fuchsia/gn-sdk/component.gni index e4af4e316e..6c06b45286 100644 --- a/engine/src/flutter/tools/fuchsia/gn-sdk/component.gni +++ b/engine/src/flutter/tools/fuchsia/gn-sdk/component.gni @@ -33,8 +33,10 @@ declare_args() { # fuchsia_component("my_component") { # manifest = "meta/component-manifest.cmx" # resources = [ -# path = "testdata/use_case1.json" -# dest = "data/testdata/use_case1.json" +# { +# path = "testdata/use_case1.json" +# dest = "data/testdata/use_case1.json" +# }, # ] # data_deps = [ ":hello_world_executable"] # }