blob: 8632ea3f8db0bcdea13b7b17e51c332510575da3 [file] [log] [blame]
# Copyright 2022 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.
# Package for the Flutter embedder for Fuchsia.
load(
"@rules_fuchsia//fuchsia:defs.bzl",
"fuchsia_component",
"fuchsia_component_manifest",
"fuchsia_package",
"fuchsia_package_archive",
"fuchsia_package_resource",
)
# ELF binary that takes Flutter app assets and runs a Flutter app.
cc_binary(
name = "flutter_embedder_binary",
srcs = [
# ABI-stable interface for the Flutter embedder platform. Copied from the Flutter Engine.
"embedder.h",
"main.cc",
"libflutter_engine.so",
],
deps = [
"@fuchsia_sdk//pkg/async-loop-cpp",
"@fuchsia_sdk//pkg/async-loop-default",
"@fuchsia_sdk//pkg/syslog",
],
)
fuchsia_component_manifest(
name = "flutter_embedder_manifest",
src = "meta/flutter_embedder.cml",
)
# The implementation of the embedder platform for the Flutter Engine.
# TODO(akbiggs): This should come from a CIPD bucket instead.
fuchsia_package_resource(
name = "flutter_engine",
src = ":libflutter_engine.so",
dest = "lib/libflutter_engine.so",
)
filegroup(
name = "flutter_embedder_libs",
srcs = [
"@fuchsia_sdk//:arch/x64/lib/libasync-default.so",
"@fuchsia_sdk//:arch/x64/lib/libfdio.so",
"@fuchsia_sdk//:arch/x64/lib/libsyslog.so",
"@fuchsia_sdk//:arch/x64/lib/libtrace-engine.so",
"@fuchsia_sdk//:arch/x64/sysroot/dist/lib/ld.so.1",
],
)
# To rebuild the Flutter app with new changes:
# ~/workstation $ cd flutter_embedder/examples/flutter_sample_app
# flutter_sample_app $ flutter build bundle
#
# TODO(akbiggs): Grab subdirectories and ensure their names are preserved
# in the output package's data.
# TODO(akbiggs): Build these assets using a build rule like flutter_application
# instead of building them using the Flutter tool and then copying them over.
# TODO(fxbug.dev/96417): Support folders/globs in fuchsia_package_resource.
filegroup(
name = "flutter_sample_app_assets",
srcs = glob([
"examples/flutter_sample_app/build/flutter_assets/*",
]),
)
# The embedder manifest specifies that the bundled assets for the Flutter application
# to run will be located at /pkg/data/flutter_assets. To create a component that
# runs a specific Flutter app, we package the embedder manifest together with the
# embedder binary and the assets for the specific Flutter app we want to run.
#
# TODO(akbiggs): After writing a few more example apps, simplify into a build rule
# like flutter_application.
fuchsia_component(
name = "flutter_sample_app_component",
content = {
":flutter_embedder_binary": "bin/flutter_embedder",
":flutter_embedder_libs": "lib/",
"@fuchsia_clang//:dist": "lib/",
":flutter_sample_app_assets": "data/flutter_assets/",
},
manifest = ":flutter_embedder_manifest",
)
fuchsia_package(
name = "flutter_sample_app_package",
package_name = "flutter_sample_app",
deps = [
":flutter_engine",
":flutter_sample_app_component",
],
)
fuchsia_package_archive(
name = "flutter_sample_app_far",
package = ":flutter_sample_app_package",
)