Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / device / BUILD.gn
blob8c5bf66f6b3af2472b36e853c74e2e8dadcc49e1
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/config/features.gni")
6 import("//testing/test.gni")
8 if (is_android) {
9   import("//build/config/android/rules.gni")  # For generate_jni().
12 if (is_mac) {
13   import("//build/config/mac/mac_sdk.gni")
16 is_linux_without_udev = is_linux && !use_udev
17 is_linux_without_dbus = is_linux && !use_dbus
19 # TODO(GYP): Delete this after we've converted everything to GN.
20 # The _run targets exist only for compatibility w/ GYP.
21 group("device_unittests_run") {
22   testonly = true
23   deps = [
24     ":device_unittests",
25   ]
28 test("device_unittests") {
29   sources = [
30     "battery/battery_status_manager_win_unittest.cc",
31     "battery/battery_status_service_unittest.cc",
32     "bluetooth/bluetooth_adapter_mac_unittest.mm",
33     "bluetooth/bluetooth_adapter_profile_chromeos_unittest.cc",
34     "bluetooth/bluetooth_adapter_unittest.cc",
35     "bluetooth/bluetooth_adapter_win_unittest.cc",
36     "bluetooth/bluetooth_advertisement_chromeos_unittest.cc",
37     "bluetooth/bluetooth_advertisement_unittest.cc",
38     "bluetooth/bluetooth_audio_sink_chromeos_unittest.cc",
39     "bluetooth/bluetooth_chromeos_unittest.cc",
40     "bluetooth/bluetooth_device_unittest.cc",
41     "bluetooth/bluetooth_device_win_unittest.cc",
42     "bluetooth/bluetooth_discovery_filter_unittest.cc",
43     "bluetooth/bluetooth_gatt_chromeos_unittest.cc",
44     "bluetooth/bluetooth_low_energy_win_unittest.cc",
45     "bluetooth/bluetooth_service_record_win_unittest.cc",
46     "bluetooth/bluetooth_socket_chromeos_unittest.cc",
47     "bluetooth/bluetooth_task_manager_win_unittest.cc",
48     "bluetooth/bluetooth_uuid_unittest.cc",
49     "bluetooth/test/bluetooth_test.cc",
50     "bluetooth/test/bluetooth_test.h",
51     "bluetooth/test/bluetooth_test_android.cc",
52     "bluetooth/test/bluetooth_test_android.h",
53     "bluetooth/test/bluetooth_test_mac.h",
54     "bluetooth/test/bluetooth_test_mac.mm",
55     "bluetooth/test/test_bluetooth_adapter_observer.cc",
56     "bluetooth/test/test_bluetooth_adapter_observer.h",
57     "nfc/nfc_chromeos_unittest.cc",
58     "nfc/nfc_ndef_record_unittest.cc",
59     "test/run_all_unittests.cc",
60   ]
62   deps = [
63     "//base/test:test_support",
64     "//device/battery",
65     "//device/battery:mojo_bindings",
66     "//device/bluetooth",
67     "//device/nfc",
68     "//mojo/environment:chromium",
69     "//net",
70     "//testing/gmock",
71     "//testing/gtest",
72     "//third_party/mojo/src/mojo/edk/system",
73     "//third_party/mojo/src/mojo/public/cpp/bindings",
74     "//url",
75   ]
77   if (!is_linux_without_dbus && !is_chromeos) {
78     sources += [ "battery/battery_status_manager_linux_unittest.cc" ]
79   }
81   # HID and Serial:
82   # Android doesn't compile.
83   # Linux, requires udev.
84   if (!is_linux_without_udev && !is_android) {
85     sources += [
86       "hid/hid_connection_unittest.cc",
87       "hid/hid_device_filter_unittest.cc",
88       "hid/hid_report_descriptor_unittest.cc",
89       "hid/input_service_linux_unittest.cc",
90       "hid/test_report_descriptors.cc",
91       "hid/test_report_descriptors.h",
92       "serial/data_sink_unittest.cc",
93       "serial/data_source_unittest.cc",
94       "serial/serial_connection_unittest.cc",
95       "serial/serial_io_handler_posix_unittest.cc",
96       "serial/serial_service_unittest.cc",
97     ]
98     deps += [
99       "//device/hid",
100       "//device/serial",
101       "//device/serial:test_support",
102     ]
103   }
105   if (use_udev) {
106     sources += [ "udev_linux/udev_unittest.cc" ]
107     deps += [ "//device/udev_linux" ]
108   }
110   # USB does not compile on mobile platforms.
111   if (!is_android && !is_ios) {
112     sources += [
113       "devices_app/usb/device_impl_unittest.cc",
114       "devices_app/usb/device_manager_impl_unittest.cc",
115       "test/test_device_client.cc",
116       "test/test_device_client.h",
117       "test/usb_test_gadget_impl.cc",
118       "usb/usb_context_unittest.cc",
119       "usb/usb_descriptors_unittest.cc",
120       "usb/usb_device_filter_unittest.cc",
121       "usb/usb_device_handle_unittest.cc",
122       "usb/usb_ids_unittest.cc",
123       "usb/usb_service_unittest.cc",
124       "usb/webusb_descriptors_unittest.cc",
125     ]
126     deps += [
127       "//device/core",
128       "//device/devices_app:lib",
129       "//device/devices_app/usb/public/cpp",
130       "//device/devices_app/usb/public/interfaces",
131       "//device/usb",
132       "//device/usb:mocks",
133       "//third_party/libusb",
134     ]
135   }
137   if (is_android) {
138     sources -= [ "battery/battery_status_service_unittest.cc" ]
139     deps -= [ "//device/battery" ]
140     deps += [ ":bluetooth_test_jni_headers" ]
141     apk_deps = [ ":bluetooth_test_java" ]
142   }
144   if (is_chromeos) {
145     configs += [ "//build/config/linux:dbus" ]
147     deps += [
148       "//chromeos",
149       "//chromeos:test_support",
150       "//chromeos:test_support_without_gmock",
151       "//dbus",
152     ]
153   }
155   if (is_posix && !is_android && !is_mac) {
156     libs = [ "rt" ]
157   }
159   if (is_mac) {
160     deps += [ "//third_party/ocmock" ]
161     ldflags = [ "-ObjC" ]
162     libs = [ "IOBluetooth.framework" ]
164     # In the OSX 10.10 SDK, CoreBluetooth became a top level framework.
165     # Previously, it was nested in IOBluetooth. In order for Chrome to run on
166     # OSes older than OSX 10.10, the top level CoreBluetooth framework must be
167     # weakly linked.
168     if (mac_sdk_version == "10.10") {
169       ldflags += [ "-weak_framework CoreBluetooth" ]
170     }
171   }
174 if (is_android) {
175   bluetooth_java_sources_needing_jni = [ "bluetooth/test/android/java/src/org/chromium/device/bluetooth/Fakes.java" ]
177   generate_jni("bluetooth_test_jni_headers") {
178     sources = bluetooth_java_sources_needing_jni
179     jni_package = "bluetooth"
180   }
182   android_library("bluetooth_test_java") {
183     java_files = bluetooth_java_sources_needing_jni
184     deps = [
185       "//base:base_java",
186       "//device/bluetooth:java",
187     ]
188   }