summaryrefslogtreecommitdiff
path: root/chromium/services/device/BUILD.gn
blob: 42661eeb373f686c859a976b427b57f26ca88ef3 (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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# Copyright 2016 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("//testing/test.gni")

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

# This file depends on the legacy global sources assignment filter. It should
# be converted to check target platform before assigning source files to the
# sources variable. Remove this import and set_sources_assignment_filter call
# when the file has been converted. See https://crbug.com/1018739 for details.
import("//build/config/deprecated_default_sources_assignment_filter.gni")
set_sources_assignment_filter(deprecated_default_sources_assignment_filter)

is_serial_enabled_platform =
    is_win || ((is_linux || is_chromeos) && use_udev) || is_mac

source_set("lib") {
  # This should be visible only to embedders of the Device Service, and the
  # dependence should only be for the purpose of embedding the Device Service.
  visibility = [
    ":test_support",
    ":tests",
    "//content/browser",
    "//services/device/public/cpp:test_support",
  ]
  sources = [
    "device_service.cc",
    "device_service.h",
  ]

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

  deps = [
    ":binder_overrides",
    "//build:chromeos_buildflags",
    "//services/device/fingerprint",
    "//services/device/generic_sensor",
    "//services/device/geolocation",
    "//services/device/power_monitor",
    "//services/device/public/cpp:device_features",
    "//services/device/public/mojom:usb",
    "//services/device/public/mojom:usb_test",
    "//services/device/screen_orientation",
    "//services/device/time_zone_monitor",
    "//services/device/usb/mojo",
    "//services/device/wake_lock",
    "//services/service_manager/public/cpp",
    "//ui/gfx",
  ]

  public_deps = [
    "//base",
    "//mojo/public/cpp/bindings",
    "//services/device/public/mojom",
    "//services/device/public/mojom:device_service",
  ]

  if (is_android) {
    deps += [ ":device_service_jni_headers" ]
  } else {
    deps += [
      "//services/device/battery",
      "//services/device/hid",
      "//services/device/vibration",
    ]
  }

  if (is_chromeos && use_dbus) {
    deps += [
      "//services/device/bluetooth:bluetooth_system",
      "//services/device/media_transfer_protocol",
    ]
  }

  if (is_serial_enabled_platform) {
    deps += [ "//services/device/serial" ]
  }

  if (chromeos_is_browser_only) {
    deps += [
      "//chromeos/crosapi/mojom",
      "//chromeos/lacros",
    ]
  }
}

# NOTE: We use a separate component target to support global binder overrides,
# since the service implementation itself may be linked into multiple
# simultaneously loaded binary targets in a component build. The ":lib" target
# cannot be a component target itself because it depends on generated JNI
# headers that do not currently support component exports.
component("binder_overrides") {
  visibility = [ ":lib" ]
  output_name = "device_service_binder_overrides"
  sources = [
    "binder_overrides.cc",
    "binder_overrides.h",
  ]
  public_deps = [
    "//base",
    "//mojo/public/cpp/bindings",
    "//services/device/public/mojom",
  ]
  defines = [ "IS_DEVICE_SERVICE_BINDER_OVERRIDES_IMPL" ]
}

is_linux_without_udev = (is_linux || is_chromeos) && !use_udev

source_set("perftests") {
  testonly = true

  sources = [ "geolocation/position_cache_impl_perftest.cc" ]

  deps = [
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//services/device/geolocation",
    "//services/device/geolocation:test_support",
    "//testing/gtest",
    "//testing/perf",
  ]
}

source_set("tests") {
  testonly = true

  sources = [
    "battery/battery_status_manager_win_unittest.cc",
    "battery/battery_status_service_unittest.cc",
    "generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer_unittest.cc",
    "generic_sensor/fake_platform_sensor_and_provider.cc",
    "generic_sensor/fake_platform_sensor_and_provider.h",
    "generic_sensor/fake_platform_sensor_fusion.cc",
    "generic_sensor/fake_platform_sensor_fusion.h",
    "generic_sensor/generic_sensor_service_unittest.cc",
    "generic_sensor/linear_acceleration_fusion_algorithm_using_accelerometer_unittest.cc",
    "generic_sensor/orientation_euler_angles_fusion_algorithm_using_quaternion_unittest.cc",
    "generic_sensor/orientation_quaternion_fusion_algorithm_using_euler_angles_unittest.cc",
    "generic_sensor/orientation_test_data.h",
    "generic_sensor/platform_sensor_and_provider_unittest.cc",
    "generic_sensor/platform_sensor_and_provider_unittest_win.cc",
    "generic_sensor/platform_sensor_fusion_unittest.cc",
    "generic_sensor/platform_sensor_provider_unittest_android.cc",
    "generic_sensor/platform_sensor_util_unittest.cc",
    "generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope_unittest.cc",
    "generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_unittest.cc",
    "geolocation/core_location_provider_unittest.mm",
    "geolocation/geolocation_provider_impl_unittest.cc",
    "geolocation/geolocation_service_unittest.cc",
    "geolocation/location_arbitrator_unittest.cc",
    "geolocation/network_location_provider_unittest.cc",
    "geolocation/position_cache_impl_unittest.cc",
    "geolocation/public_ip_address_geolocator_unittest.cc",
    "geolocation/public_ip_address_location_notifier_unittest.cc",
    "geolocation/wifi_data_provider_chromeos_unittest.cc",
    "geolocation/wifi_data_provider_common_unittest.cc",
    "geolocation/wifi_data_provider_win_unittest.cc",
    "geolocation/wifi_polling_policy_unittest.cc",
    "power_monitor/power_monitor_message_broadcaster_unittest.cc",
    "public/cpp/power_monitor/power_monitor_broadcast_source_unittest.cc",
    "vibration/vibration_manager_impl_unittest.cc",
    "wake_lock/wake_lock_unittest.cc",
  ]

  deps = [
    ":lib",
    ":test_support",
    "//base",
    "//base/test:test_support",
    "//base/third_party/dynamic_annotations",
    "//device/base/synchronization",
    "//mojo/public/cpp/bindings",
    "//net",
    "//net:test_support",
    "//services/device/generic_sensor",
    "//services/device/geolocation",
    "//services/device/geolocation:test_support",
    "//services/device/power_monitor",
    "//services/device/public/cpp:device_features",
    "//services/device/public/cpp/bluetooth:bluetooth_tests",
    "//services/device/public/cpp/power_monitor",
    "//services/device/public/mojom",
    "//services/device/wake_lock",
    "//services/network:test_support",
    "//testing/gmock",
    "//testing/gtest",
  ]

  if (!is_linux_without_udev) {
    sources +=
        [ "generic_sensor/platform_sensor_and_provider_unittest_linux.cc" ]
  }

  if (is_linux && !is_chromeos && use_dbus) {
    sources += [
      "battery/battery_status_manager_linux_unittest.cc",
      "geolocation/wifi_data_provider_linux_unittest.cc",
    ]
    deps += [ "//dbus:test_support" ]
  }

  if (is_chromeos) {
    sources += [ "fingerprint/fingerprint_chromeos_unittest.cc" ]
    deps += [
      "//chromeos/dbus:test_support",
      "//chromeos/dbus/biod:test_support",
      "//chromeos/network:test_support",
      "//services/device/bluetooth:bluetooth_system_tests",
      "//services/device/fingerprint",
      "//third_party/protobuf:protobuf_lite",
    ]
  }

  if (is_android) {
    sources -= [
      "battery/battery_status_service_unittest.cc",
      "geolocation/network_location_provider_unittest.cc",
      "geolocation/wifi_data_provider_common_unittest.cc",
    ]
    deps += [
      ":device_service_jni_headers",
      "//services/device/public/java:geolocation_java_test_support",
      "//services/device/usb:java",
      "//services/device/vibration/android:vibration_jni_headers",
    ]
  } else {
    sources += [
      "battery/battery_monitor_impl_unittest.cc",
      "hid/hid_manager_unittest.cc",
    ]
    deps += [
      "//services/device/battery",
      "//services/device/hid:mocks",
      "//services/device/public/cpp/hid",
      "//services/device/vibration",
    ]

    if (!is_linux_without_udev) {
      sources += [
        "hid/hid_connection_impl_unittest.cc",
        "hid/input_service_linux_unittest.cc",
        "hid/test_report_descriptors.cc",
        "hid/test_report_descriptors.h",
        "public/cpp/hid/hid_device_filter_unittest.cc",
        "public/cpp/hid/hid_report_descriptor_unittest.cc",
      ]
      if (!is_fuchsia) {
        # Fuchsia does not currently implement HidService.
        sources += [ "hid/hid_service_unittest.cc" ]
      }
      if (!is_ios) {
        sources += [ "hid/hid_connection_unittest.cc" ]
        deps += [
          ":usb_test_gadget",
          "//net:test_support",
          "//services/device/usb",
        ]
      }
    }
  }

  if (is_serial_enabled_platform) {
    sources += [
      "serial/bluetooth_serial_port_impl_unittest.cc",
      "serial/serial_device_enumerator_linux_unittest.cc",
      "serial/serial_device_enumerator_unittest.cc",
      "serial/serial_port_impl_unittest.cc",
      "serial/serial_port_manager_impl_unittest.cc",
    ]

    if (is_posix) {
      sources += [ "serial/serial_io_handler_posix_unittest.cc" ]
    }

    if (is_linux || is_chromeos) {
      deps += [ "//device/udev_linux:test_support" ]
    }

    deps += [
      "//device/bluetooth:mocks",
      "//services/device/public/cpp/bluetooth:bluetooth",
      "//services/device/public/cpp/serial:switches",
      "//services/device/serial",
      "//services/device/serial:test_support",
    ]
  }

  # USB does not compile on iOS.
  if (!is_ios) {
    sources += [
      "public/cpp/usb/usb_utils_unittest.cc",
      "usb/mojo/device_impl_unittest.cc",
      "usb/mojo/device_manager_impl_unittest.cc",
      "usb/usb_descriptors_unittest.cc",
      "usb/usb_device_handle_unittest.cc",
      "usb/usb_service_unittest.cc",
      "usb/webusb_descriptors_unittest.cc",
    ]
    deps += [
      ":usb_test_gadget",
      "//device/base",
      "//net:test_support",
      "//services/device/public/cpp:test_support",
      "//services/device/public/cpp/usb",
      "//services/device/public/mojom",
      "//services/device/usb",
      "//services/device/usb:test_support",
      "//services/device/usb/mojo",
    ]

    if (!is_android) {
      sources += [ "public/cpp/usb/usb_ids_unittest.cc" ]
    }
  }

  # UsbContext is a libusb-specific object.
  if (is_mac || is_win) {
    sources += [ "usb/usb_context_unittest.cc" ]
    deps += [ "//third_party/libusb" ]
  }

  if (is_win) {
    sources += [
      "generic_sensor/platform_sensor_provider_winrt_unittest.cc",
      "generic_sensor/platform_sensor_reader_winrt_unittests.cc",
      "geolocation/win/fake_geocoordinate_winrt.cc",
      "geolocation/win/fake_geocoordinate_winrt.h",
      "geolocation/win/fake_geolocator_winrt.cc",
      "geolocation/win/fake_geolocator_winrt.h",
      "geolocation/win/fake_geoposition_winrt.cc",
      "geolocation/win/fake_geoposition_winrt.h",
      "geolocation/win/fake_position_changed_event_args_winrt.cc",
      "geolocation/win/fake_position_changed_event_args_winrt.h",
      "geolocation/win/fake_status_changed_event_args_winrt.cc",
      "geolocation/win/fake_status_changed_event_args_winrt.h",
      "geolocation/win/location_provider_winrt_unittest.cc",
    ]

    # Needed for "generic_sensor/platform_sensor_and_provider_unittest_win.cc"
    libs = [
      "propsys.lib",
      "sensorsapi.lib",
    ]
  }
}

source_set("test_support") {
  testonly = true

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

  deps = [
    ":lib",
    "//base",
    "//base/test:test_support",
    "//mojo/public/cpp/bindings",
    "//net",
    "//net:test_support",
    "//services/device/public/cpp/geolocation",
    "//services/device/public/mojom:device_service",
    "//services/network:test_support",
    "//services/service_manager/public/cpp",
    "//services/service_manager/public/cpp/test:test_support",
    "//testing/gtest",
  ]
}

if (is_android) {
  generate_jni("device_service_jni_headers") {
    sources = [
      "android/java/src/org/chromium/services/device/InterfaceRegistrar.java",
      "public/java/src/org/chromium/device/DeviceFeatureList.java",
    ]
  }

  android_library("java") {
    # This should be visible only to embedders of the Device Service, and the
    # dependence should only be for the purpose of embedding the Device Service.
    # //content/public/android:* here actually wants to identify the
    # //content/public/android:content_java target and all of its generated
    # targets which also need to see this target as well.
    # //services:* identifies //services:service_unittests and all of its
    # generated targets.
    visibility = [
      "//content/public/android:*",
      "//services:*",
    ]
    sources = [
      "android/java/src/org/chromium/services/device/InterfaceRegistrar.java",
    ]
    deps = [
      "//base:base_java",
      "//mojo/public/java:bindings_java",
      "//mojo/public/java:system_java",
      "//mojo/public/java/system:system_impl_java",
      "//services/device/battery/android:battery_monitor_java",
      "//services/device/generic_sensor:java",
      "//services/device/geolocation:geolocation_java",
      "//services/device/nfc/android:java",
      "//services/device/public/java:nfc_java",
      "//services/device/public/mojom:mojom_java",
      "//services/device/screen_orientation:java",
      "//services/device/time_zone_monitor:java",
      "//services/device/usb:java",
      "//services/device/vibration/android:vibration_manager_java",
      "//services/device/wake_lock/power_save_blocker:java",
      "//services/service_manager/public/java:service_manager_java",
      "//services/service_manager/public/mojom:mojom_java",
    ]
  }
}

source_set("usb_test_gadget") {
  testonly = true

  sources = [
    "test/usb_test_gadget.h",
    "test/usb_test_gadget_impl.cc",
  ]

  deps = [
    "//device/base",
    "//net:test_support",
    "//services/device/usb",
    "//tools/usb_gadget",
  ]
}