blob: 0efd42755078fbc86ffe0dd8b0b711ae18745bc7 [file] [log] [blame]
# 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)
import("//build/package.gni")
import("//build/test/test_package.gni")
import("//build/testing/environments.gni")
import("//build/vulkan/config.gni")
import("//garnet/bin/ui/scenic/config.gni")
import("//topaz/runtime/dart/dart_component.gni")
import("//topaz/runtime/flutter_runner/prebuilt_framework.gni")
import("$flutter_root/shell/gpu/gpu.gni")
shell_gpu_configuration("fuchsia_gpu_configuration") {
enable_software = false
enable_gl = false
enable_vulkan = true
}
# Dependencies for flutter tooling
#
# While not required to run a flutter mod, these allow interacting
# with flutter via the fx tool and need to be built.
flutter_tool_deps = [ "//third_party/dart-pkg/git/flutter/packages/flutter_tools:fuchsia_attach($host_toolchain)" ]
# Builds a flutter_runner
#
# Parameters:
#
# output_name (required):
# The name of the resulting binary.
#
# extra_deps (required):
# Any additional dependencies.
#
# product (required):
# Whether to link against a Product mode Dart VM.
#
# extra_defines (optional):
# Any additional preprocessor defines.
template("flutter_runner") {
assert(defined(invoker.output_name), "flutter_runner must define output_name")
assert(defined(invoker.extra_deps), "flutter_runner must define extra_deps")
assert(defined(invoker.product), "flutter_runner must define product")
invoker_output_name = invoker.output_name
extra_deps = invoker.extra_deps
extra_defines = []
if (defined(invoker.extra_defines)) {
extra_defines += invoker.extra_defines
}
product_suffix = ""
if (invoker.product) {
product_suffix = "_product"
}
executable(target_name) {
output_name = invoker_output_name
defines = extra_defines
libs = []
sources = [
"component.cc",
"component.h",
"compositor_context.cc",
"compositor_context.h",
"context_writer_bridge.cc",
"context_writer_bridge.h",
"engine.cc",
"engine.h",
"fuchsia_font_manager.cc",
"fuchsia_font_manager.h",
"isolate_configurator.cc",
"isolate_configurator.h",
"logging.h",
"loop.cc",
"loop.h",
"main.cc",
"platform_view.cc",
"platform_view.h",
"runner.cc",
"runner.h",
"runner_context.cc",
"runner_context.h",
"service_provider_dir.cc",
"service_provider_dir.h",
"session_connection.cc",
"session_connection.h",
"surface.cc",
"surface.h",
"task_observers.cc",
"task_observers.h",
"task_runner_adapter.cc",
"task_runner_adapter.h",
"thread.cc",
"thread.h",
"unique_fdio_ns.h",
"vsync_recorder.cc",
"vsync_recorder.h",
"vsync_waiter.cc",
"vsync_waiter.h",
"vulkan_surface.cc",
"vulkan_surface.h",
"vulkan_surface_pool.cc",
"vulkan_surface_pool.h",
"vulkan_surface_producer.cc",
"vulkan_surface_producer.h",
]
# The use of these dependencies is temporary and will be moved behind the
# embedder API.
flutter_deps = [
":fuchsia_gpu_configuration",
"$flutter_root/assets",
"$flutter_root/common",
"$flutter_root/flow",
"$flutter_root/lib/ui",
"$flutter_root/runtime",
"$flutter_root/third_party/txt",
"$flutter_root/vulkan",
"$flutter_root/fml",
"$flutter_root/shell/common",
]
public_deps = [
"//zircon/public/lib/fit",
]
deps = [
"//garnet/public/lib/vulkan",
"//sdk/fidl/fuchsia.accessibility",
"//sdk/fidl/fuchsia.fonts",
"//sdk/fidl/fuchsia.modular",
"//sdk/fidl/fuchsia.ui.app",
"//sdk/fidl/fuchsia.ui.input",
"//sdk/fidl/fuchsia.ui.scenic",
"//sdk/fidl/fuchsia.ui.views",
"//sdk/lib/sys/cpp",
"//sdk/lib/ui/scenic/cpp",
"//sdk/lib/vfs/cpp",
"//third_party/dart/runtime/bin:libdart_builtin${product_suffix}",
"//third_party/icu",
"//third_party/rapidjson",
"//third_party/skia",
"//third_party/tonic",
"//third_party/zlib:minizip",
"//topaz/public/dart-pkg/fuchsia",
"//topaz/runtime/dart/utils",
"//topaz/runtime/dart/utils:files",
"//topaz/runtime/dart/utils:inlines",
"//topaz/runtime/dart/utils:vmo",
"//zircon/public/fidl/fuchsia-io",
"//zircon/public/lib/async-cpp",
"//zircon/public/lib/async-loop-cpp",
"//zircon/public/lib/syslog",
"//zircon/public/lib/trace",
"//zircon/public/lib/trace-provider",
"//zircon/public/lib/zx",
] + extra_deps + flutter_deps
# The flags below are needed so that Dart's CPU profiler can walk the
# C++ stack.
cflags = [
"-mno-omit-leaf-frame-pointer",
"-fno-omit-frame-pointer",
]
if (!invoker.product) {
# This flag is needed so that the call to dladdr() in Dart's native symbol
# resolver can report good symbol information for the CPU profiler.
ldflags = [ "-rdynamic" ]
}
}
}
flutter_runner("aot") {
output_name = "flutter_aot_runner"
product = false
if (flutter_profile) {
extra_defines = [ "FLUTTER_PROFILE" ]
}
extra_deps = [
"//third_party/dart/runtime:libdart_precompiled_runtime",
"//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime",
]
}
flutter_runner("aot_product") {
output_name = "flutter_aot_product_runner"
product = true
extra_defines = [ "DART_PRODUCT" ]
extra_deps = [
"//third_party/dart/runtime:libdart_precompiled_runtime_product",
"//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime_product",
]
}
flutter_runner("jit") {
output_name = "flutter_jit_runner"
product = false
if (flutter_profile) {
extra_defines = [ "FLUTTER_PROFILE" ]
}
extra_deps = [
"//third_party/dart/runtime:libdart_jit",
"//third_party/dart/runtime/platform:libdart_platform_jit",
] + flutter_tool_deps
}
flutter_runner("jit_product") {
output_name = "flutter_jit_product_runner"
product = true
extra_defines = [ "DART_PRODUCT" ]
extra_deps = [
"//third_party/dart/runtime:libdart_jit_product",
"//third_party/dart/runtime/platform:libdart_platform_jit_product",
]
}
observatory_target =
"//third_party/dart/runtime/observatory:observatory_archive"
observatory_archive_dir = get_label_info(observatory_target, "target_gen_dir")
observatory_archive_name = get_label_info(observatory_target, "name")
observatory_archive_file =
"${observatory_archive_dir}/${observatory_archive_name}.tar"
template("aot_runner") {
product = defined(invoker.product) && invoker.product
product_suffix = ""
if (product) {
product_suffix = "_product"
}
package(target_name) {
deps = [
":aot${product_suffix}",
]
if (!product) {
deps += [ observatory_target ]
}
binary = "flutter_aot${product_suffix}_runner"
resources = [
{
path = rebase_path("//third_party/icu/common/icudtl.dat")
dest = "icudtl.dat"
},
]
if (!product) {
resources += [
{
path = rebase_path(observatory_archive_file)
dest = "observatory.tar"
},
]
}
meta = [
{
path = rebase_path("meta/flutter_aot${product_suffix}_runner.cmx")
dest = "flutter_aot${product_suffix}_runner.cmx"
},
]
}
}
template("jit_runner") {
product = defined(invoker.product) && invoker.product
product_suffix = ""
if (product) {
product_suffix = "_product"
}
package(target_name) {
snapshot_label = "//topaz/runtime/flutter_runner/kernel:kernel_core_snapshot${product_suffix}"
snapshot_framework_label = "${snapshot_label}_framework"
snapshot_gen_dir = get_label_info(snapshot_label, "target_gen_dir")
deps = [
":jit${product_suffix}",
snapshot_framework_label,
snapshot_label,
]
if (!product) {
deps += [ observatory_target ]
}
binary = "flutter_jit${product_suffix}_runner"
resources = [
{
path = rebase_path(
"$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin")
dest = "vm_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin")
dest = "vm_snapshot_instructions.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin")
dest = "isolate_core_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin")
dest = "isolate_core_snapshot_instructions.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}_framework.bin")
dest = "framework_vm_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}_framework.bin")
dest = "framework_vm_snapshot_instructions.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot${product_suffix}_framework.bin")
dest = "framework_isolate_core_snapshot_data.bin"
},
{
path = rebase_path(
"$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}_framework.bin")
dest = "framework_isolate_core_snapshot_instructions.bin"
},
{
path = rebase_path("//third_party/icu/common/icudtl.dat")
dest = "icudtl.dat"
},
]
if (prebuilt_framework_path == "") {
deps += [ "//topaz/runtime/flutter_runner/kernel:framework_shim_kernel" ]
resources += [
{
path = rebase_path(
"$snapshot_gen_dir/framework_shim.dilpmanifest.frameworkversion")
dest = "runner.frameworkversion"
},
]
} else {
deps +=
[ "//topaz/runtime/flutter_runner/kernel:extract_prebuilt_framework" ]
resources += [
{
path = rebase_path(
"$snapshot_gen_dir/data/$prebuilt_framework_name/app.frameworkversion")
dest = "runner.frameworkversion"
},
]
}
if (!product) {
resources += [
{
path = rebase_path(observatory_archive_file)
dest = "observatory.tar"
},
]
}
meta = [
{
path = rebase_path("meta/flutter_jit${product_suffix}_runner.cmx")
dest = "flutter_jit${product_suffix}_runner.cmx"
},
]
}
}
aot_runner("flutter_aot_runner") {
product = false
}
aot_runner("flutter_aot_product_runner") {
product = true
}
jit_runner("flutter_jit_runner") {
product = false
}
jit_runner("flutter_jit_product_runner") {
product = true
}
executable("flutter_runner_unittests") {
testonly = true
output_name = "flutter_runner_tests"
sources = [
"fuchsia_font_manager.cc",
"fuchsia_font_manager.h",
"fuchsia_font_manager_unittest.cc",
"logging.h",
]
deps = [
"//garnet/public/lib/gtest",
"//sdk/fidl/fuchsia.fonts",
"//sdk/fidl/fuchsia.sys",
"//sdk/lib/sys/cpp",
"//third_party/googletest:gtest_main",
"//third_party/icu",
"//third_party/skia",
"//topaz/runtime/dart/utils:inlines",
"//topaz/runtime/dart/utils:vmo",
"//zircon/public/lib/fdio",
"//zircon/public/lib/trace",
"//zircon/public/lib/zx",
]
}
test_package("flutter_runner_tests") {
deps = [
":flutter_runner_unittests",
"//third_party/skia",
]
tests = [
{
name = "flutter_runner_tests"
environments = basic_envs
},
]
resources = [
{
path = rebase_path("tests/test_manifest.json")
dest = "testdata/test_fonts/manifest.json"
},
]
fonts = [
"roboto/Roboto-Regular.ttf",
"robotoslab/RobotoSlab-Regular.ttf",
]
foreach(font, fonts) {
resources += [
{
path = rebase_path("//garnet/bin/fonts/third_party/${font}")
file_name = get_path_info(font, "file")
dest = "testdata/test_fonts/${file_name}"
},
]
}
}