chromium/services/device/hid/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("//build/config/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

source_set("hid") {
  # HID is not implemented on Android and we want to be particularly careful
  # about not bloating binary size by accidentially including it.
  assert(!is_android)

  sources = [
    "hid_connection.cc",
    "hid_connection.h",
    "hid_connection_impl.cc",
    "hid_connection_impl.h",
    "hid_device_info.cc",
    "hid_device_info.h",
    "hid_manager_impl.cc",
    "hid_manager_impl.h",
    "hid_service.cc",
    "hid_service.h",
  ]

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

  deps = [
    "//base",
    "//build:chromeos_buildflags",
    "//components/device_event_log",
    "//device/base",
    "//services/device:utility",
    "//services/device/public/cpp/hid",
    "//services/device/public/mojom",
  ]

  if ((is_linux || is_chromeos) && use_udev) {
    sources += [
      "hid_connection_linux.cc",
      "hid_connection_linux.h",
      "hid_service_linux.cc",
      "hid_service_linux.h",
      "input_service_linux.cc",
      "input_service_linux.h",
    ]
    deps += [ "//device/udev_linux" ]
  }

  if (is_chromeos_ash) {
    deps += [ "//chromeos/dbus/permission_broker" ]
  }

  if (is_win) {
    sources += [
      "hid_connection_win.cc",
      "hid_connection_win.h",
      "hid_preparsed_data.cc",
      "hid_preparsed_data.h",
      "hid_service_win.cc",
      "hid_service_win.h",
    ]
    libs = [
      "hid.lib",
      "setupapi.lib",
    ]
  }

  if (is_mac) {
    sources += [
      "hid_connection_mac.cc",
      "hid_connection_mac.h",
      "hid_service_mac.cc",
      "hid_service_mac.h",
    ]
  }

  if (is_fuchsia) {
    sources += [
      "hid_service_fuchsia.cc",
      "hid_service_fuchsia.h",
    ]
  }
}

fuzzer_test("hid_report_descriptor_fuzzer") {
  sources = [ "hid_report_descriptor_fuzzer.cc" ]
  deps = [
    "//services/device/public/cpp/hid",
    "//services/device/public/mojom",
  ]
  seed_corpus = "fuzz_corpus"
  libfuzzer_options = [ "max_len=2048" ]
}