[go: nahoru, domu]

Skip to content

Commit

Permalink
Adding missing snapshot to the fuchsia package in AOT builds (flutter…
Browse files Browse the repository at this point in the history
…#29268)

The initial implementation tried to leverage the fuchsia.git approach to
adding resources via GN template, but the GN SDK does not use the same
format or approach. This PR adds the snapshot resource in the way the
GN SDK expects.
  • Loading branch information
richkadel committed Oct 21, 2021
1 parent 7bc99ca commit d4e2709
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 120 deletions.
96 changes: 0 additions & 96 deletions tools/fuchsia/dist/resource.gni

This file was deleted.

14 changes: 8 additions & 6 deletions tools/fuchsia/flutter/flutter_component.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -133,6 +134,7 @@ template("flutter_component") {
"main_dart",
"main_package",
"component_name",
"resources",
])
deps = _component_deps

Expand Down
32 changes: 16 additions & 16 deletions tools/fuchsia/flutter/internal/flutter_dart_component.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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 =
Expand All @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions tools/fuchsia/gn-sdk/component.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
# }
Expand Down

0 comments on commit d4e2709

Please sign in to comment.