summaryrefslogtreecommitdiff
path: root/chromium/device/serial/BUILD.gn
blob: 77132bfc86d3cf0cf5e7faea099f2cec7a816de4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")

# Library works only on desktop platforms.
if (is_win || is_linux || is_mac) {
  config("platform_support") {
    visibility = [ ":serial" ]
    if (is_win) {
      libs = [ "setupapi.lib" ]
      ldflags = [ "/DELAYLOAD:setupapi.dll" ]
    }
  }

  static_library("serial") {
    visibility = [
      ":test_support",
      "//device:device_unittests",
      "//services/device/serial",
      "//tools/battor_agent:battor_agent_lib",
    ]

    output_name = "device_serial"

    sources = [
      "buffer.cc",
      "buffer.h",
      "serial_device_enumerator.cc",
      "serial_device_enumerator.h",
      "serial_device_enumerator_linux.cc",
      "serial_device_enumerator_linux.h",
      "serial_device_enumerator_mac.cc",
      "serial_device_enumerator_mac.h",
      "serial_device_enumerator_win.cc",
      "serial_device_enumerator_win.h",
      "serial_io_handler.cc",
      "serial_io_handler.h",
      "serial_io_handler_win.cc",
      "serial_io_handler_win.h",
    ]

    public_configs = [ ":platform_support" ]

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

    deps = [
      "//mojo/public/cpp/system",
      "//net",
      "//third_party/re2",
    ]

    if (is_posix) {
      sources += [
        "serial_io_handler_posix.cc",
        "serial_io_handler_posix.h",
      ]
    }
    if (use_udev) {
      deps += [ "//device/udev_linux" ]
    }
    if (is_chromeos) {
      deps += [
        "//chromeos",
        "//dbus",
      ]
    }
    if (is_mac) {
      libs = [
        "Foundation.framework",
        "IOKit.framework",
      ]
    }
  }

  static_library("test_support") {
    # TODO(leonhsl): Merge necessary parts of TestSerialIoHandler into
    # battor_connection_impl_unittest.cc to hide serial impl completely.
    visibility = [ "//tools/battor_agent:battor_agent_unittests" ]

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

    public_deps = [
      ":serial",
    ]
  }
}