chromium/device/vr/public/mojom/BUILD.gn

# Copyright 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//device/vr/buildflags/buildflags.gni")
import("//mojo/public/tools/bindings/mojom.gni")

mojom_component("vr_service") {
  output_prefix = "device_vr_service_mojo_bindings"
  macro_prefix = "DEVICE_VR_SERVICE_MOJO_BINDINGS"

  sources = [ "vr_service.mojom" ]

  public_deps = [
    ":test_mojom",
    ":xr_common",
    "//device/gamepad/public/mojom",
    "//gpu/ipc/common:interfaces",
    "//mojo/public/mojom/base",
    "//services/viz/public/mojom:shared_image_format",
    "//ui/display/mojom:mojom",
    "//ui/gfx/geometry/mojom",
    "//ui/gfx/mojom",
  ]

  shared_cpp_typemap = {
    types = [
      {
        mojom = "device.mojom.RgbaTupleF16"
        cpp = "::device::RgbaTupleF16"
      },
      {
        mojom = "device.mojom.RgbTupleF32"
        cpp = "::device::RgbTupleF32"
      },
      {
        mojom = "device.mojom.Pose"
        cpp = "::device::Pose"
      },
    ]
    traits_headers = [ "//device/vr/public/mojom/vr_service_mojom_traits.h" ]
    traits_public_deps = [ ":vr_public_typemaps" ]
  }

  cpp_typemaps = [ shared_cpp_typemap ]
  blink_cpp_typemaps = [ shared_cpp_typemap ]
}

# Separating the public mojom interface into vr_service and isolated_xr_service
# components allows us to add dependencies to isolated_xr_service without having
# a blink variant. The blink variant tends to cause problematic, unresolved externals.
mojom_component("isolated_xr_service") {
  output_prefix = "device_vr_isolated_xr_service_mojo_bindings"
  macro_prefix = "DEVICE_VR_ISOLATED_XR_SERVICE_MOJO_BINDINGS"

  sources = [ "isolated_xr_service.mojom" ]

  disable_variants = true

  public_deps = [
    ":test_mojom",
    ":vr_service",
    ":xr_common",
    "//gpu/ipc/common:interfaces",
    "//mojo/public/mojom/base",
    "//sandbox/policy/mojom",
    "//skia/public/mojom",
    "//ui/gfx/geometry/mojom",
  ]

  deps = [ "//services/viz/public/mojom" ]
}

mojom_component("test_mojom") {
  output_prefix = "device_vr_test_mojo_bindings"
  macro_prefix = "DEVICE_VR_TEST_MOJO_BINDINGS"

  sources = [ "browser_test_interfaces.mojom" ]

  public_deps = [
    ":xr_common",
    "//ui/gfx/geometry/mojom",
    "//ui/gfx/mojom",
  ]
}

component("vr_public_typemaps") {
  output_name = "device_vr_public_typemaps"

  defines = [ "IS_VR_PUBLIC_TYPEMAPS_IMPL" ]

  sources = [
    "pose.cc",
    "pose.h",
  ]

  deps = [
    "//base:base",
    "//skia",
    "//ui/gfx/geometry",
    "//ui/gfx/geometry:geometry_skia",
  ]

  configs += [ "//build/config/compiler:wexit_time_destructors" ]
}

mojom_component("xr_common") {
  output_prefix = "device_xr_common_mojo_bindings"
  macro_prefix = "DEVICE_XR_COMMON_MOJO_BINDINGS"

  sources = [
    "openxr_interaction_profile_type.mojom",
    "xr_device.mojom",
    "xr_session.mojom",
  ]

  public_deps = [
    "//skia/public/mojom",
    "//ui/gfx/geometry/mojom",
    "//ui/gfx/mojom",
  ]

  enabled_features = []
  if (enable_openxr) {
    enabled_features += [ "enable_openxr" ]
  }

  if (enable_cardboard) {
    enabled_features += [ "enable_cardboard" ]
  }

  if (enable_arcore) {
    enabled_features += [ "enable_arcore" ]
  }

  webui_module_path = "/"
  generate_legacy_js_bindings = true
}