chromium/fuchsia_web/runners/BUILD.gn

# Copyright 2019 The Chromium Authors
# 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/config/fuchsia/generate_runner_scripts.gni")
import("//build/config/fuchsia/symbol_archive.gni")
import("//testing/test.gni")
import("//third_party/fuchsia-gn-sdk/src/component.gni")
import("//third_party/fuchsia-gn-sdk/src/package.gni")

# Only allow use by targets in this directory unless explicitly specified.
visibility = [ ":*" ]

# Abstractions for use by runners that show web content.
source_set("common") {
  sources = [
    "common/web_component.cc",
    "common/web_component.h",
    "common/web_content_runner.cc",
    "common/web_content_runner.h",
  ]
  deps = [
    "//base",
    "//ui/gfx/geometry",
    "//url",
  ]
  public_deps = [
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.ui.app:fuchsia.ui.app_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web:fuchsia.web_hlcpp",
    "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
  ]
}

source_set("cast_runner_core") {
  sources = [
    "cast/api_bindings_client.cc",
    "cast/api_bindings_client.h",
    "cast/application_controller_impl.cc",
    "cast/application_controller_impl.h",
    "cast/cast_component.cc",
    "cast/cast_component.h",
    "cast/cast_resolver.cc",
    "cast/cast_resolver.h",
    "cast/cast_runner.cc",
    "cast/cast_runner.h",
    "cast/cast_runner_switches.cc",
    "cast/cast_runner_switches.h",
    "cast/cast_streaming.cc",
    "cast/cast_streaming.h",
    "cast/named_message_port_connector_fuchsia.cc",
    "cast/named_message_port_connector_fuchsia.h",
    "cast/pending_cast_component.cc",
    "cast/pending_cast_component.h",
  ]
  data = [ rebase_path(
          "//components/cast/named_message_port_connector/named_message_port_connector.js") ]
  deps = [
    "//base",
    "//components/cast/common:constants",
    "//components/cast/message_port",
    "//components/cast/named_message_port_connector:named_message_port_connector",
    "//components/fuchsia_component_support",
    "//components/fuchsia_component_support:dynamic_component_host",
    "//fuchsia_web/cast_streaming",
    "//fuchsia_web/webinstance_host",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component:fuchsia.component_cpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component.decl:fuchsia.component.decl_cpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.diagnostics:fuchsia.diagnostics_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.legacymetrics:fuchsia.legacymetrics_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.media.sessions2:fuchsia.media.sessions2_cpp_hlcpp_conversion",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem:fuchsia.mem_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.ui.app:fuchsia.ui.app_cpp_wire",
    "//third_party/fuchsia-sdk/sdk/pkg/component_incoming_cpp",
    "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
    "//third_party/fuchsia-sdk/sdk/pkg/trace",
    "//url",
  ]

  public_deps = [
    ":common",
    "//fuchsia_web/runners/cast/fidl:fidl_cpp",
    "//fuchsia_web/runners/cast/fidl:fidl_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component.resolution:fuchsia.component.resolution_cpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.component.runner:fuchsia.component.runner_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web:fuchsia.web_hlcpp",
  ]

  visibility += [ "//fuchsia_web/runners/cast/test:*" ]
}

executable("cast_runner_exe") {
  assert_no_deps = [
    "//content/public/common",
    "//media",
    "//third_party/blink/common",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.modular:*",
  ]

  sources = [ "cast/main.cc" ]
  deps = [
    ":cast_runner_core",
    ":common",
    "//base",
    "//build:chromecast_buildflags",
    "//components/fuchsia_component_support",
    "//fuchsia_web/common",
    "//fuchsia_web/webinstance_host",
    "//third_party/fuchsia-sdk/sdk/pkg/inspect_component_cpp",
    "//third_party/fuchsia-sdk/sdk/pkg/trace-engine",
    "//third_party/fuchsia-sdk/sdk/pkg/trace-provider-so",
  ]

  data_deps = [ ":cast_runner_core" ]
}

# web_instance_host's deps, especially //content/public/common, adds these.
# TODO(crbug.com/42050285): Moving flag parsing to web_instance should
# eliminate the dependencies that cause these files to be added. Remove them
# and add the targets that generate these to assert_no_deps in
# cast_runner_core.
_web_instance_host_deps_files_to_exclude = [
  "lib/libEGL.so",
  "lib/libGLESv2.so",
  "lib/libvulkan.so",

  # TODO(crbug.com/42050042): SwiftShader is not used in cast_runner.
  # This list should match the list of SwiftShader files excluded from the
  # web_engine package (see fuchsia_web/webengine/BUILD.gn).
  "lib/libvk_swiftshader.so",
  "vk_swiftshader_icd.json",
]

# This file is required for both component and coverage builds.
if (!is_component_build && !fuchsia_code_coverage) {
  _web_instance_host_deps_files_to_exclude += [ "lib/libfuchsia_egl.so" ]
}

fuchsia_component("cast_runner_component") {
  manifest = "cast/cast_runner.cml"
  data_deps = [ ":cast_runner_exe" ]
}

fuchsia_package("cast_runner_pkg") {
  package_name = "cast_runner"
  deps = [ ":cast_runner_component" ]
  excluded_files = _web_instance_host_deps_files_to_exclude
}

fuchsia_package_installer("cast_runner") {
  visibility += [ "//fuchsia_web:gn_all" ]
  package = ":cast_runner_pkg"
  package_name = "cast_runner"
  package_deps = [ [
        "//fuchsia_web/webengine:web_engine",
        "web_engine",
      ] ]
}

test("cast_runner_unittests") {
  sources = [ "cast/application_controller_impl_unittest.cc" ]
  deps = [
    ":cast_runner_core",
    "//base",
    "//base/test:run_all_unittests",
    "//base/test:test_support",
    "//fuchsia_web/common/test:test_support",
    "//fuchsia_web/runners/cast/fidl:fidl_cpp",
    "//fuchsia_web/runners/cast/fidl:fidl_cpp_testing",
    "//fuchsia_web/runners/cast/test:test_support",
    "//net:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web:fuchsia.web_hlcpp",
  ]
  data_deps = [ ":cast_runner_core" ]
}

test("cast_runner_integration_tests") {
  sources = [ "cast/cast_runner_integration_test.cc" ]
  data = [ "cast/testdata" ]
  deps = [
    ":cast_runner_core",
    "//base/test:test_support",
    "//build:chromecast_buildflags",
    "//components/cast/message_port",
    "//components/fuchsia_component_support:dynamic_component_host",
    "//fuchsia_web/common",
    "//fuchsia_web/common/test:run_all_integration_tests",
    "//fuchsia_web/common/test:test_support",
    "//fuchsia_web/runners/cast/test:integration",
    "//fuchsia_web/runners/cast/test:test_support",
    "//net:test_support",
    "//testing/gtest",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.camera3:fuchsia.camera3_hlcpp",
    "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.legacymetrics:fuchsia.legacymetrics_hlcpp",
    "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
  ]

  # Include cast_runner.cm as a component in the test's package.
  fuchsia_package_deps = [ ":cast_runner_component" ]

  # Deploy the web_engine packages
  package_deps = [ [
        "//fuchsia_web/webengine:web_engine",
        "web_engine",
      ] ]
  additional_manifest_fragments = [
    "//build/config/fuchsia/test/fonts.shard.test-cml",
    "//build/config/fuchsia/test/network.shard.test-cml",
    "//fuchsia_web/runners/cast/cast_runner_integration_test.shard.test-cml",
    "//third_party/fuchsia-sdk/sdk/pkg/sys/component/realm_builder_absolute.shard.cml",
    "//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
  ]
}

test("cast_runner_browsertests") {
  sources = [
    "cast/api_bindings_client_browsertest.cc",
    "cast/named_message_port_connector_fuchsia_browsertest.cc",
  ]
  defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  data = [ "cast/testdata" ]
  deps = [
    ":cast_runner_core",
    "//base/test:test_support",
    "//components/cast/message_port",
    "//components/cast/message_port:test_message_port_receiver",
    "//content/public/browser",
    "//content/test:test_support",
    "//fuchsia_web/common/test:test_support",
    "//fuchsia_web/runners/cast/test:test_support",
    "//fuchsia_web/webengine:browsertest_core",
    "//testing/gmock",
    "//testing/gtest",
    "//ui/ozone",
  ]
  additional_manifest_fragments = [
    "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
    "//build/config/fuchsia/test/network.shard.test-cml",
    "//build/config/fuchsia/test/test_ui_stack.shard.test-cml",
    "//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
  ]
}