summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/BUILD.gn
blob: b3394b932114968d4c4f9679eb0eacf7064abfae (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# 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")

if (is_android) {
  import("//build/config/android/rules.gni")  # For generate_jni().
}

config("bluetooth_config") {
  if (is_win) {
    ldflags = [
      "/DELAYLOAD:BluetoothApis.dll",

      # Despite MSDN stating that Bthprops.dll contains the
      # symbols declared by bthprops.lib, they actually reside here:
      "/DELAYLOAD:Bthprops.cpl",
      "/DELAYLOAD:setupapi.dll",
    ]
  }
}

component("bluetooth") {
  sources = [
    "android/bluetooth_jni_registrar.cc",
    "android/bluetooth_jni_registrar.h",
    "android/wrappers.cc",
    "android/wrappers.h",
    "bluetooth_adapter.cc",
    "bluetooth_adapter.h",
    "bluetooth_adapter_android.cc",
    "bluetooth_adapter_android.h",
    "bluetooth_adapter_factory.cc",
    "bluetooth_adapter_factory.h",
    "bluetooth_adapter_mac.h",
    "bluetooth_adapter_mac.mm",
    "bluetooth_adapter_win.cc",
    "bluetooth_adapter_win.h",
    "bluetooth_advertisement.cc",
    "bluetooth_advertisement.h",
    "bluetooth_audio_sink.cc",
    "bluetooth_audio_sink.h",
    "bluetooth_channel_mac.h",
    "bluetooth_channel_mac.mm",
    "bluetooth_classic_device_mac.h",
    "bluetooth_classic_device_mac.mm",
    "bluetooth_classic_win.cc",
    "bluetooth_classic_win.h",
    "bluetooth_device.cc",
    "bluetooth_device.h",
    "bluetooth_device_android.cc",
    "bluetooth_device_android.h",
    "bluetooth_device_mac.h",
    "bluetooth_device_mac.mm",
    "bluetooth_device_win.cc",
    "bluetooth_device_win.h",
    "bluetooth_discovery_filter.cc",
    "bluetooth_discovery_filter.h",
    "bluetooth_discovery_manager_mac.h",
    "bluetooth_discovery_manager_mac.mm",
    "bluetooth_discovery_session.cc",
    "bluetooth_discovery_session.h",
    "bluetooth_discovery_session_outcome.h",
    "bluetooth_gatt_characteristic.cc",
    "bluetooth_gatt_characteristic.h",
    "bluetooth_gatt_connection.cc",
    "bluetooth_gatt_connection.h",
    "bluetooth_gatt_descriptor.cc",
    "bluetooth_gatt_descriptor.h",
    "bluetooth_gatt_notify_session.cc",
    "bluetooth_gatt_notify_session.h",
    "bluetooth_gatt_notify_session_android.cc",
    "bluetooth_gatt_notify_session_android.h",
    "bluetooth_gatt_service.cc",
    "bluetooth_gatt_service.h",
    "bluetooth_init_win.cc",
    "bluetooth_init_win.h",
    "bluetooth_l2cap_channel_mac.h",
    "bluetooth_l2cap_channel_mac.mm",
    "bluetooth_low_energy_central_manager_delegate.h",
    "bluetooth_low_energy_central_manager_delegate.mm",
    "bluetooth_low_energy_defs_win.cc",
    "bluetooth_low_energy_defs_win.h",
    "bluetooth_low_energy_device_mac.h",
    "bluetooth_low_energy_device_mac.mm",
    "bluetooth_low_energy_discovery_manager_mac.h",
    "bluetooth_low_energy_discovery_manager_mac.mm",
    "bluetooth_low_energy_win.cc",
    "bluetooth_low_energy_win.h",
    "bluetooth_remote_gatt_characteristic_android.cc",
    "bluetooth_remote_gatt_characteristic_android.h",
    "bluetooth_remote_gatt_characteristic_win.cc",
    "bluetooth_remote_gatt_characteristic_win.h",
    "bluetooth_remote_gatt_descriptor_android.cc",
    "bluetooth_remote_gatt_descriptor_android.h",
    "bluetooth_remote_gatt_descriptor_win.cc",
    "bluetooth_remote_gatt_descriptor_win.h",
    "bluetooth_remote_gatt_service_android.cc",
    "bluetooth_remote_gatt_service_android.h",
    "bluetooth_remote_gatt_service_win.cc",
    "bluetooth_remote_gatt_service_win.h",
    "bluetooth_rfcomm_channel_mac.h",
    "bluetooth_rfcomm_channel_mac.mm",
    "bluetooth_service_record_win.cc",
    "bluetooth_service_record_win.h",
    "bluetooth_socket.cc",
    "bluetooth_socket.h",
    "bluetooth_socket_mac.h",
    "bluetooth_socket_mac.mm",
    "bluetooth_socket_net.cc",
    "bluetooth_socket_net.h",
    "bluetooth_socket_thread.cc",
    "bluetooth_socket_thread.h",
    "bluetooth_socket_win.cc",
    "bluetooth_socket_win.h",
    "bluetooth_task_manager_win.cc",
    "bluetooth_task_manager_win.h",
    "bluetooth_uuid.cc",
    "bluetooth_uuid.h",
  ]

  defines = [ "DEVICE_BLUETOOTH_IMPLEMENTATION" ]

  all_dependent_configs = [ ":bluetooth_config" ]

  deps = [
    "//base",
    "//crypto",
    "//device/bluetooth/strings",
    "//device/bluetooth/uribeacon",
    "//ipc",
    "//net",
    "//ui/base",
  ]

  if (is_android) {
    deps += [ ":jni_headers" ]
  }

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

  if (is_mac) {
    libs = [ "IOBluetooth.framework" ]
  }

  if (is_win) {
    libs = [ "setupapi.lib" ]
  }

  if (is_chromeos || is_linux) {
    if (use_dbus) {
      sources += [
        "bluetooth_adapter_bluez.cc",
        "bluetooth_adapter_bluez.h",
        "bluetooth_adapter_profile_bluez.cc",
        "bluetooth_adapter_profile_bluez.h",
        "bluetooth_advertisement_bluez.cc",
        "bluetooth_advertisement_bluez.h",
        "bluetooth_audio_sink_bluez.cc",
        "bluetooth_audio_sink_bluez.h",
        "bluetooth_device_bluez.cc",
        "bluetooth_device_bluez.h",
        "bluetooth_gatt_connection_bluez.cc",
        "bluetooth_gatt_connection_bluez.h",
        "bluetooth_gatt_notify_session_bluez.cc",
        "bluetooth_gatt_notify_session_bluez.h",
        "bluetooth_pairing_bluez.cc",
        "bluetooth_pairing_bluez.h",
        "bluetooth_remote_gatt_characteristic_bluez.cc",
        "bluetooth_remote_gatt_characteristic_bluez.h",
        "bluetooth_remote_gatt_descriptor_bluez.cc",
        "bluetooth_remote_gatt_descriptor_bluez.h",
        "bluetooth_remote_gatt_service_bluez.cc",
        "bluetooth_remote_gatt_service_bluez.h",
        "bluetooth_socket_bluez.cc",
        "bluetooth_socket_bluez.h",
        "dbus/bluetooth_adapter_client.cc",
        "dbus/bluetooth_adapter_client.h",
        "dbus/bluetooth_agent_manager_client.cc",
        "dbus/bluetooth_agent_manager_client.h",
        "dbus/bluetooth_agent_service_provider.cc",
        "dbus/bluetooth_agent_service_provider.h",
        "dbus/bluetooth_dbus_client_bundle.cc",
        "dbus/bluetooth_dbus_client_bundle.h",
        "dbus/bluetooth_device_client.cc",
        "dbus/bluetooth_device_client.h",
        "dbus/bluetooth_gatt_characteristic_client.cc",
        "dbus/bluetooth_gatt_characteristic_client.h",
        "dbus/bluetooth_gatt_characteristic_service_provider.cc",
        "dbus/bluetooth_gatt_characteristic_service_provider.h",
        "dbus/bluetooth_gatt_descriptor_client.cc",
        "dbus/bluetooth_gatt_descriptor_client.h",
        "dbus/bluetooth_gatt_descriptor_service_provider.cc",
        "dbus/bluetooth_gatt_descriptor_service_provider.h",
        "dbus/bluetooth_gatt_manager_client.cc",
        "dbus/bluetooth_gatt_manager_client.h",
        "dbus/bluetooth_gatt_service_client.cc",
        "dbus/bluetooth_gatt_service_client.h",
        "dbus/bluetooth_gatt_service_service_provider.cc",
        "dbus/bluetooth_gatt_service_service_provider.h",
        "dbus/bluetooth_input_client.cc",
        "dbus/bluetooth_input_client.h",
        "dbus/bluetooth_le_advertisement_service_provider.cc",
        "dbus/bluetooth_le_advertisement_service_provider.h",
        "dbus/bluetooth_le_advertising_manager_client.cc",
        "dbus/bluetooth_le_advertising_manager_client.h",
        "dbus/bluetooth_media_client.cc",
        "dbus/bluetooth_media_client.h",
        "dbus/bluetooth_media_endpoint_service_provider.cc",
        "dbus/bluetooth_media_endpoint_service_provider.h",
        "dbus/bluetooth_media_transport_client.cc",
        "dbus/bluetooth_media_transport_client.h",
        "dbus/bluetooth_profile_manager_client.cc",
        "dbus/bluetooth_profile_manager_client.h",
        "dbus/bluetooth_profile_service_provider.cc",
        "dbus/bluetooth_profile_service_provider.h",
        "dbus/bluez_dbus_client.h",
        "dbus/bluez_dbus_manager.cc",
        "dbus/bluez_dbus_manager.h",
        "dbus/fake_bluetooth_adapter_client.cc",
        "dbus/fake_bluetooth_adapter_client.h",
        "dbus/fake_bluetooth_agent_manager_client.cc",
        "dbus/fake_bluetooth_agent_manager_client.h",
        "dbus/fake_bluetooth_agent_service_provider.cc",
        "dbus/fake_bluetooth_agent_service_provider.h",
        "dbus/fake_bluetooth_device_client.cc",
        "dbus/fake_bluetooth_device_client.h",
        "dbus/fake_bluetooth_gatt_characteristic_client.cc",
        "dbus/fake_bluetooth_gatt_characteristic_client.h",
        "dbus/fake_bluetooth_gatt_characteristic_service_provider.cc",
        "dbus/fake_bluetooth_gatt_characteristic_service_provider.h",
        "dbus/fake_bluetooth_gatt_descriptor_client.cc",
        "dbus/fake_bluetooth_gatt_descriptor_client.h",
        "dbus/fake_bluetooth_gatt_descriptor_service_provider.cc",
        "dbus/fake_bluetooth_gatt_descriptor_service_provider.h",
        "dbus/fake_bluetooth_gatt_manager_client.cc",
        "dbus/fake_bluetooth_gatt_manager_client.h",
        "dbus/fake_bluetooth_gatt_service_client.cc",
        "dbus/fake_bluetooth_gatt_service_client.h",
        "dbus/fake_bluetooth_gatt_service_service_provider.cc",
        "dbus/fake_bluetooth_gatt_service_service_provider.h",
        "dbus/fake_bluetooth_input_client.cc",
        "dbus/fake_bluetooth_input_client.h",
        "dbus/fake_bluetooth_le_advertisement_service_provider.cc",
        "dbus/fake_bluetooth_le_advertisement_service_provider.h",
        "dbus/fake_bluetooth_le_advertising_manager_client.cc",
        "dbus/fake_bluetooth_le_advertising_manager_client.h",
        "dbus/fake_bluetooth_media_client.cc",
        "dbus/fake_bluetooth_media_client.h",
        "dbus/fake_bluetooth_media_endpoint_service_provider.cc",
        "dbus/fake_bluetooth_media_endpoint_service_provider.h",
        "dbus/fake_bluetooth_media_transport_client.cc",
        "dbus/fake_bluetooth_media_transport_client.h",
        "dbus/fake_bluetooth_profile_manager_client.cc",
        "dbus/fake_bluetooth_profile_manager_client.h",
        "dbus/fake_bluetooth_profile_service_provider.cc",
        "dbus/fake_bluetooth_profile_service_provider.h",
      ]
      if (is_linux) {
        sources += [
          "dbus/dbus_bluez_manager_wrapper_linux.cc",
          "dbus/dbus_bluez_manager_wrapper_linux.h",
          "dbus/dbus_thread_manager_linux.cc",
          "dbus/dbus_thread_manager_linux.h",
        ]
      }
      deps += [ "//dbus" ]
    } else {  # !use_dbus
      sources += [ "bluetooth_adapter_stub.cc" ]
      if (is_linux) {
        sources += [
          "dbus/dbus_bluez_manager_wrapper_linux.h",
          "dbus/dbus_bluez_manager_wrapper_stub_linux.cc",
        ]
      }
    }
  }
}

static_library("mocks") {
  testonly = true
  sources = [
    "test/mock_bluetooth_adapter.cc",
    "test/mock_bluetooth_adapter.h",
    "test/mock_bluetooth_advertisement.cc",
    "test/mock_bluetooth_advertisement.h",
    "test/mock_bluetooth_central_manager_mac.h",
    "test/mock_bluetooth_central_manager_mac.mm",
    "test/mock_bluetooth_device.cc",
    "test/mock_bluetooth_device.h",
    "test/mock_bluetooth_discovery_session.cc",
    "test/mock_bluetooth_discovery_session.h",
    "test/mock_bluetooth_gatt_characteristic.cc",
    "test/mock_bluetooth_gatt_characteristic.h",
    "test/mock_bluetooth_gatt_connection.cc",
    "test/mock_bluetooth_gatt_connection.h",
    "test/mock_bluetooth_gatt_descriptor.cc",
    "test/mock_bluetooth_gatt_descriptor.h",
    "test/mock_bluetooth_gatt_notify_session.cc",
    "test/mock_bluetooth_gatt_notify_session.h",
    "test/mock_bluetooth_gatt_service.cc",
    "test/mock_bluetooth_gatt_service.h",
    "test/mock_bluetooth_socket.cc",
    "test/mock_bluetooth_socket.h",
  ]

  public_deps = [
    ":bluetooth",
    "//base",
    "//net",
    "//testing/gmock",
  ]
}

if (is_android) {
  java_sources_needing_jni = [
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothAdapter.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattDescriptor.java",
    "android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattService.java",
    "android/java/src/org/chromium/device/bluetooth/Wrappers.java",
  ]

  generate_jni("jni_headers") {
    sources = java_sources_needing_jni
    jni_package = "bluetooth"
  }

  android_library("java") {
    java_files = java_sources_needing_jni
    deps = [
      "//base:base_java",
    ]
  }
}