chromium/chrome/browser/devtools/BUILD.gn

# Copyright 2014 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("//printing/buildflags/buildflags.gni")

if (!is_android) {
  import("//build/config/features.gni")
  import("//chrome/common/features.gni")
  import("//tools/grit/grit_rule.gni")
}

if (!is_android) {
  _inspector_protocol = "//third_party/inspector_protocol"
  import("$_inspector_protocol/inspector_protocol.gni")

  _protocol_generated = [
    "protocol/autofill.cc",
    "protocol/autofill.h",
    "protocol/extensions.cc",
    "protocol/extensions.h",
    "protocol/browser.cc",
    "protocol/browser.h",
    "protocol/cast.cc",
    "protocol/cast.h",
    "protocol/emulation.cc",
    "protocol/emulation.h",
    "protocol/page.cc",
    "protocol/page.h",
    "protocol/protocol.h",
    "protocol/pwa.cc",
    "protocol/pwa.h",
    "protocol/security.cc",
    "protocol/security.h",
    "protocol/storage.cc",
    "protocol/storage.h",
    "protocol/system_info.cc",
    "protocol/system_info.h",
    "protocol/target.cc",
    "protocol/target.h",
  ]

  if (is_chromeos_ash) {
    _protocol_generated += [
      "protocol/window_manager.cc",
      "protocol/window_manager.h",
    ]
  }

  _concatenated_protocol_path =
      "$root_gen_dir/chrome/browser/devtools/protocol.json"
  action("concatenate_protocols") {
    script = _inspector_protocol + "/concatenate_protocols.py"

    deps = [ "//third_party/blink/public/devtools_protocol:protocol_version" ]

    _blink_protocol_path =
        "$root_gen_dir/third_party/blink/public/devtools_protocol/protocol.json"
    inputs = [ _blink_protocol_path ]
    output_file = _concatenated_protocol_path
    outputs = [ output_file ]

    args = [ rebase_path(_blink_protocol_path, root_build_dir) ]
    if (is_chromeos_ash) {
      inputs += [ "cros_protocol.pdl" ]
      args += [ rebase_path("cros_protocol.pdl", root_build_dir) ]
    }

    args += [ rebase_path(output_file, root_build_dir) ]
  }

  inspector_protocol_generate("protocol_generated_sources") {
    inspector_protocol_dir = _inspector_protocol
    visibility = [ ":*" ]  # Only targets in this file can depend on this.
    deps = [ ":concatenate_protocols" ]
    out_dir = target_gen_dir
    config_file = "inspector_protocol_config.json"
    use_embedder_types = true

    protocol_path = rebase_path(_concatenated_protocol_path, root_build_dir)
    config_values = [ "protocol.path=$protocol_path" ]

    inputs = [
      _concatenated_protocol_path,
      "inspector_protocol_config.json",
    ]

    outputs = _protocol_generated
  }
}

static_library("devtools") {
  # Note: new sources and deps should be generally added in (!is_android) below.
  sources = []

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

  public_deps = [
    "//chrome/browser:browser_public_dependencies",
    "//chrome/browser:primitives",
  ]

  deps = [
    "//base",
    "//chrome/browser/search",
    "//chrome/browser/search_engines",
    "//chrome/browser/sync",

    # To prevent circular GN dependencies, this target does not depend on
    # //chrome/browser:browser, even though it has a real build dependency on
    # it.  However, depending on the order in which this target and
    # //chrome/browser:browser are built it's possible that the connectors
    # proto header (which //chrome/browser:browser depends on) is not generated
    # yet causing devtools not to compile.  Adding this indirect dependency to
    # the proto to fix that.
    "//components/enterprise/common/proto:connectors_proto",

    # Similar bandaid as the above. Since we cannot depend on
    # //chrome/browser:browser, we include indirect dependencies here.
    "//chrome/browser/autofill:autofill",
    "//components/autofill/content/browser:browser",
    "//components/autofill/core/browser:browser",
    "//components/enterprise/buildflags",
    "//components/paint_preview/buildflags:buildflags",
    "//components/variations/service:service",
    "//components/webapps/common:common",
    "//content/public/browser",
    "//net",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/viz/privileged/mojom/compositing",
    "//third_party/blink/public:buildflags",
    "//ui/events:dom_keycode_converter",
  ]

  if (!is_android) {
    deps += [
      "//build:chromeos_buildflags",
      "//chrome:extra_resources",
      "//chrome:resources",
      "//chrome:strings",
      "//chrome/app/theme:theme_resources",
      "//chrome/browser:browser_process",
      "//chrome/browser/apps/app_service:constants",
      "//chrome/browser/media/router:media_router_feature",
      "//chrome/browser/profiles:profile",
      "//chrome/browser/task_manager",
      "//chrome/browser/themes",
      "//chrome/browser/ui:browser_navigator_params_headers",
      "//chrome/browser/ui/exclusive_access",
      "//chrome/browser/web_applications",
      "//chrome/common",
      "//components/flags_ui",
      "//components/guest_view/browser",
      "//components/infobars/content",
      "//components/infobars/core",
      "//components/input",
      "//components/javascript_dialogs",
      "//components/keep_alive_registry",
      "//components/keyed_service/content",
      "//components/language/core/browser",
      "//components/metrics/structured:structured_events",
      "//components/pref_registry",
      "//components/prefs",
      "//components/search_engines:search_engines",
      "//components/sessions",
      "//components/signin/public/identity_manager:identity_manager",
      "//components/sync/service",
      "//components/sync_preferences",
      "//components/viz/host",
      "//components/web_modal",
      "//components/zoom",
      "//net",
      "//skia",
      "//third_party/icu",
      "//third_party/leveldatabase",
      "//ui/base/cursor",
      "//ui/base/cursor/mojom:cursor_type",
      "//ui/shell_dialogs",
      "//ui/views/controls/webview",
    ]
    if (is_chromeos) {
      deps += [ "//chromeos/constants" ]
    }
    if (is_chromeos_ash) {
      deps += [ "//ash/constants" ]
    }
    sources += [
      "aida_client.cc",
      "aida_client.h",
      "chrome_devtools_manager_delegate.cc",
      "chrome_devtools_manager_delegate.h",
      "chrome_devtools_session.cc",
      "chrome_devtools_session.h",
      "device/adb/adb_client_socket.cc",
      "device/adb/adb_client_socket.h",
      "device/adb/adb_device_provider.cc",
      "device/adb/adb_device_provider.h",
      "device/android_device_info_query.cc",
      "device/android_device_manager.cc",
      "device/android_device_manager.h",
      "device/android_web_socket.cc",
      "device/devtools_android_bridge.cc",
      "device/devtools_android_bridge.h",
      "device/devtools_device_discovery.cc",
      "device/devtools_device_discovery.h",
      "device/port_forwarding_controller.cc",
      "device/port_forwarding_controller.h",
      "device/tcp_device_provider.cc",
      "device/tcp_device_provider.h",
      "device/usb/android_rsa.cc",
      "device/usb/android_rsa.h",
      "device/usb/android_usb_device.cc",
      "device/usb/android_usb_device.h",
      "device/usb/android_usb_socket.cc",
      "device/usb/android_usb_socket.h",
      "device/usb/usb_device_manager_helper.cc",
      "device/usb/usb_device_manager_helper.h",
      "device/usb/usb_device_provider.cc",
      "device/usb/usb_device_provider.h",
      "devtools_auto_opener.cc",
      "devtools_auto_opener.h",
      "devtools_browser_context_manager.cc",
      "devtools_browser_context_manager.h",
      "devtools_contents_resizing_strategy.cc",
      "devtools_contents_resizing_strategy.h",
      "devtools_dock_tile.h",
      "devtools_embedder_message_dispatcher.cc",
      "devtools_embedder_message_dispatcher.h",
      "devtools_eye_dropper.cc",
      "devtools_eye_dropper.h",
      "devtools_file_helper.cc",
      "devtools_file_helper.h",
      "devtools_file_system_indexer.cc",
      "devtools_file_system_indexer.h",
      "devtools_file_watcher.cc",
      "devtools_file_watcher.h",
      "devtools_infobar_delegate.cc",
      "devtools_infobar_delegate.h",
      "devtools_settings.cc",
      "devtools_settings.h",
      "devtools_targets_ui.cc",
      "devtools_targets_ui.h",
      "devtools_toggle_action.cc",
      "devtools_toggle_action.h",
      "devtools_ui_bindings.cc",
      "devtools_ui_bindings.h",
      "devtools_window.cc",
      "devtools_window.h",
      "global_confirm_info_bar.cc",
      "global_confirm_info_bar.h",
      "process_sharing_infobar_delegate.cc",
      "process_sharing_infobar_delegate.h",
      "remote_debugging_server.cc",
      "remote_debugging_server.h",
      "serialize_host_descriptions.cc",
      "serialize_host_descriptions.h",
      "url_constants.cc",
      "url_constants.h",
      "visual_logging.cc",
      "visual_logging.h",
    ]
    if (enable_service_discovery) {
      sources += [
        "device/cast_device_provider.cc",
        "device/cast_device_provider.h",
      ]
    }
  }

  if (is_mac) {
    sources += [ "devtools_dock_tile_mac.mm" ]
  } else {
    sources += [ "devtools_dock_tile.cc" ]
  }
  if (!is_android) {
    deps += [
      ":protocol_generated_sources",
      "//chrome/app:command_ids",
      "//components/custom_handlers",
      "//components/media_router/browser",
      "//components/media_router/common/mojom:media_router",
      "//components/payments/content",
      "//components/privacy_sandbox/privacy_sandbox_attestations",
      "//components/security_state/content",
      "//components/subresource_filter/content/browser:browser",
      "//components/webapps/browser",
      "//third_party/blink/public/common:headers",
      "//third_party/inspector_protocol:crdtp",
    ]
    sources += [
      "protocol/autofill_handler.cc",
      "protocol/autofill_handler.h",
      "protocol/browser_handler.cc",
      "protocol/browser_handler.h",
      "protocol/cast_handler.cc",
      "protocol/cast_handler.h",
      "protocol/emulation_handler.cc",
      "protocol/emulation_handler.h",
      "protocol/extensions_handler.cc",
      "protocol/extensions_handler.h",
      "protocol/page_handler.cc",
      "protocol/page_handler.h",
      "protocol/pwa_handler.cc",
      "protocol/pwa_handler.h",
      "protocol/security_handler.cc",
      "protocol/security_handler.h",
      "protocol/storage_handler.cc",
      "protocol/storage_handler.h",
      "protocol/system_info_handler.cc",
      "protocol/system_info_handler.h",
      "protocol/target_handler.cc",
      "protocol/target_handler.h",
    ]
    if (is_chromeos_ash) {
      deps += [ "//ash" ]
      sources += [
        "protocol/window_manager_handler.cc",
        "protocol/window_manager_handler.h",
      ]
    }
    if (enable_printing) {
      deps += [
        "//components/printing/browser/headless",
        "//components/printing/browser/print_to_pdf",
      ]
      if (enable_oop_printing) {
        # protocol/page_handler.cc directly includes
        # chrome/browser/printing/print_view_manager.h, and thus is dependent
        # upon some mojom files.  This could go away and have a cleaner dep on
        # //chrome/browser/printing if the //chrome build layer could get
        # sufficiently untangled.
        deps += [ "//chrome/services/printing/public/mojom" ]
      }
    }
    sources += rebase_path(_protocol_generated, ".", target_gen_dir)
  }

  if (enable_extensions) {
    deps += [
      "//chrome/common/extensions/api",
      "//extensions/browser",
    ]
  }
}

static_library("test_support") {
  sources = []
  deps = []
  testonly = true

  if (!is_android) {
    deps += [
      ":devtools",
      "//base",
      "//chrome/browser",
      "//chrome/browser/ui",
      "//content/public/browser",
      "//content/test:test_support",
      "//net",
      "//net/traffic_annotation:test_support",
    ]

    sources += [
      "device/adb/mock_adb_server.cc",
      "device/adb/mock_adb_server.h",
      "devtools_window_testing.cc",
      "devtools_window_testing.h",
    ]

    defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ]
  }
}