summaryrefslogtreecommitdiffstats
path: root/device/usb/BUILD.gn
blob: a139092be7f1d5e16b13e53f17dcf426199fdbb6 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Copyright (c) 2013 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")

assert(!is_ios)

source_ids = "//third_party/usb_ids/usb.ids"
generated_ids = "$target_gen_dir/usb_ids_gen.cc"

source_set("usb") {
  sources = [
    "usb_descriptors.cc",
    "usb_descriptors.h",
    "usb_device.cc",
    "usb_device.h",
    "usb_device_filter.cc",
    "usb_device_filter.h",
    "usb_device_handle.cc",
    "usb_device_handle.h",
    "usb_ids.cc",
    "usb_ids.h",
    "usb_service.cc",
    "usb_service.h",
    "webusb_descriptors.cc",
    "webusb_descriptors.h",
    generated_ids,
  ]

  deps = [
    ":usb_device_ids",
    "//base",
    "//base/third_party/dynamic_annotations",
    "//components/device_event_log",
    "//device/core",
    "//net",
  ]

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

  if (is_android) {
    sources += [
      "usb_service_android.cc",
      "usb_service_android.h",
    ]
  } else {
    sources += [
      "usb_context.cc",
      "usb_context.h",
      "usb_device_handle_impl.cc",
      "usb_device_handle_impl.h",
      "usb_device_impl.cc",
      "usb_device_impl.h",
      "usb_error.cc",
      "usb_error.h",
      "usb_service_impl.cc",
      "usb_service_impl.h",
    ]

    deps += [ "//third_party/libusb" ]
  }

  if (is_chromeos) {
    deps += [
      "//chromeos",
      "//dbus",
    ]
  }
}

source_set("mocks") {
  testonly = true

  sources = [
    "mock_usb_device.cc",
    "mock_usb_device.h",
    "mock_usb_device_handle.cc",
    "mock_usb_device_handle.h",
    "mock_usb_service.cc",
    "mock_usb_service.h",
  ]

  deps = [
    "//base",
    "//testing/gmock",
    ":usb",
  ]
}

action("usb_device_ids") {
  script = "//device/usb/tools/usb_ids.py"
  inputs = [
    source_ids,
  ]
  outputs = [
    generated_ids,
  ]
  args = [
    "-i",
    rebase_path(source_ids, root_build_dir),
    "-o",
    rebase_path(generated_ids, root_build_dir),
  ]

  # Only the device_usb target can depend on us.
  visibility = [ ":usb" ]
}