chromium/extensions/browser/api/BUILD.gn

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

import("//build/config/chromeos/ui_mode.gni")
import("//extensions/buildflags/buildflags.gni")
import("//extensions/common/api/schema.gni")
import("//tools/json_schema_compiler/json_schema_api.gni")

assert(enable_extensions_core)

# The set of all targets needed to build out the extension API implementations
# and any necessary steps to register or instantiate them.
# Embedders should usually depend on this.
group("api") {
  public_deps = [
    "//extensions/browser/api:api_implementations",
    "//extensions/browser/api:api_provider",
    "//extensions/browser/api:api_registration",
  ]
}

# The collection of API implementations.
# TODO(https://crbug.com/356905053): Remove this if-block once APIs are compiled
# on desktop android. Individual APIs can be toggled instead of the entire
# group.
group("api_implementations") {
  # The group of APIs included in both normal desktop builds and the
  # experimental desktop-android build.
  # TODO(https://crbug.com/356905053): Continue moving more APIs here.
  public_deps = [ "//extensions/browser/api/test" ]

  # APIs that are currently not supported on desktop-android.
  if (enable_extensions) {
    public_deps += [
      "//extensions/browser:browser_sources",
      "//extensions/browser/api/alarms",
      "//extensions/browser/api/app_current_window_internal",
      "//extensions/browser/api/app_runtime",
      "//extensions/browser/api/app_window",
      "//extensions/browser/api/audio",
      "//extensions/browser/api/automation_internal",
      "//extensions/browser/api/bluetooth",
      "//extensions/browser/api/bluetooth_low_energy",
      "//extensions/browser/api/bluetooth_socket",
      "//extensions/browser/api/declarative_net_request",
      "//extensions/browser/api/dns",
      "//extensions/browser/api/feedback_private",
      "//extensions/browser/api/file_handlers",
      "//extensions/browser/api/file_system",
      "//extensions/browser/api/i18n",
      "//extensions/browser/api/idle",
      "//extensions/browser/api/management",
      "//extensions/browser/api/messaging",
      "//extensions/browser/api/messaging:native_messaging",
      "//extensions/browser/api/metrics_private",
      "//extensions/browser/api/mime_handler_private",
      "//extensions/browser/api/networking_private",
      "//extensions/browser/api/offscreen",
      "//extensions/browser/api/power",
      "//extensions/browser/api/printer_provider",
      "//extensions/browser/api/runtime",
      "//extensions/browser/api/serial",
      "//extensions/browser/api/socket",
      "//extensions/browser/api/sockets_tcp",
      "//extensions/browser/api/sockets_tcp_server",
      "//extensions/browser/api/sockets_udp",
      "//extensions/browser/api/storage",
      "//extensions/browser/api/system_cpu",
      "//extensions/browser/api/system_info",
      "//extensions/browser/api/system_memory",
      "//extensions/browser/api/system_network",
      "//extensions/browser/api/system_storage",
      "//extensions/browser/api/user_scripts",
      "//extensions/browser/api/virtual_keyboard_private",
    ]

    if (is_chromeos) {
      public_deps += [
        "//extensions/browser/api/cec_private",
        "//extensions/browser/api/virtual_keyboard",
        "//extensions/browser/api/webcam_private",
      ]
    }

    if (is_chromeos_ash) {
      public_deps += [
        "//extensions/browser/api/diagnostics",
        "//extensions/browser/api/lock_screen_data",
        "//extensions/browser/api/media_perception_private",
      ]
    }
  }
}

# A helper to instantiate all keyed service factories needed for any extension
# APIs.
source_set("api_keyed_service_factories") {
  sources = [
    "api_browser_context_keyed_service_factories.cc",
    "api_browser_context_keyed_service_factories.h",
  ]

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

  deps = [
    "//build:chromeos_buildflags",
    "//extensions/browser/api",
    "//extensions/browser/api:api_implementations",
    "//extensions/buildflags:buildflags",
  ]
}

# The "glue" layer that adds relevant API registrations to the extensions
# client.
source_set("api_provider") {
  sources = [
    "core_extensions_browser_api_provider.cc",
    "core_extensions_browser_api_provider.h",
  ]

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

  deps = [
    "//extensions/browser:browser_sources",
    "//extensions/browser/api:api_registration",
  ]
}

# The step necessary to generate the code to register the corresponding
# ExtensionFunctions in order to map the function string name with their
# implementation.
function_registration("api_registration") {
  sources = extensions_api_schema_files + extensions_api_uncompiled_sources
  impl_dir = "//extensions/browser/api"
  bundle_name = ""
  root_namespace = extensions_api_root_namespace

  deps = [
    "//extensions/browser/api:api_implementations",
    "//extensions/common/api",
    "//skia",
  ]
}