chromium/services/device/serial/BUILD.gn

# Copyright 2017 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")

if (is_win || ((is_linux || is_chromeos) && use_udev) || is_mac) {
  config("platform_support") {
    visibility = [ ":serial" ]
    if (is_win) {
      libs = [ "setupapi.lib" ]
      ldflags = [ "/DELAYLOAD:setupapi.dll" ]
    }
  }

  source_set("serial") {
    visibility = [
      ":test_support",
      "//services/device:lib",
      "//services/device:tests",
    ]

    sources = [
      "bluetooth_serial_device_enumerator.cc",
      "bluetooth_serial_device_enumerator.h",
      "bluetooth_serial_port_impl.cc",
      "bluetooth_serial_port_impl.h",
      "serial_device_enumerator.cc",
      "serial_device_enumerator.h",
      "serial_io_handler.cc",
      "serial_io_handler.h",
      "serial_port_impl.cc",
      "serial_port_impl.h",
      "serial_port_manager_impl.cc",
      "serial_port_manager_impl.h",
    ]

    public_configs = [ ":platform_support" ]

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

    public_deps = [ "//services/device/public/mojom" ]

    deps = [
      "//base",
      "//build:chromeos_buildflags",
      "//components/device_event_log",
      "//device/bluetooth:bluetooth",
      "//device/bluetooth/public/cpp",
      "//mojo/public/cpp/bindings",
      "//net",
      "//services/device/public/cpp:device_features",
      "//services/device/public/cpp/bluetooth:bluetooth",
    ]

    if (is_linux || is_chromeos) {
      sources += [
        "serial_device_enumerator_linux.cc",
        "serial_device_enumerator_linux.h",
      ]
    }

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

    if (is_win) {
      sources += [
        "serial_device_enumerator_win.cc",
        "serial_device_enumerator_win.h",
        "serial_io_handler_win.cc",
        "serial_io_handler_win.h",
      ]
    }

    if (is_posix) {
      sources += [
        "serial_io_handler_posix.cc",
        "serial_io_handler_posix.h",
      ]
    }

    if (use_udev) {
      deps += [ "//device/udev_linux" ]
    }

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

    if (is_mac) {
      frameworks = [
        "Foundation.framework",
        "IOKit.framework",
      ]
    }

    if (is_win) {
      deps += [
        "//device/base",
        "//third_party/re2",
      ]
    }
  }

  static_library("test_support") {
    testonly = true

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

    deps = [
      ":serial",
      "//base",
    ]
  }
}