blob: 553473f19f6113d0876a20e444add3f4e546b325 [file] [log] [blame]
GuangHui Liu41bda342017-05-10 14:37:17 -07001// Copyright (C) 2017 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Josh Gao27768452018-01-02 12:01:43 -080015cc_defaults {
16 name: "adb_defaults",
17
18 cflags: [
19 "-Wall",
20 "-Wextra",
21 "-Werror",
22 "-Wno-unused-parameter",
23 "-Wno-missing-field-initializers",
24 "-Wvla",
25 ],
26 rtti: true,
27
28 clang_cflags: [
29 "-Wexit-time-destructors",
30 "-Wthread-safety",
31 ],
32
Josh Gaoc7567fa2018-02-27 15:49:23 -080033 use_version_lib: true,
34
Josh Gao27768452018-01-02 12:01:43 -080035 compile_multilib: "first",
36 product_variables: {
37 debuggable: {
38 cflags: [
39 "-DALLOW_ADBD_ROOT",
40 "-DALLOW_ADBD_DISABLE_VERITY",
41 "-DALLOW_ADBD_NO_AUTH",
42 ],
43 },
44 },
45
46 target: {
47 android: {
48 cflags: ["-DADB_HOST=0"],
49 },
50
51 host: {
52 cflags: ["-DADB_HOST=1"],
53 },
54
55 darwin: {
56 host_ldlibs: [
57 "-lpthread",
58 "-framework CoreFoundation",
59 "-framework IOKit",
60 "-lobjc",
61 ],
62 },
63
64 windows: {
65 cflags: [
66 // Define windows.h and tchar.h Unicode preprocessor symbols so that
67 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
68 // build if you accidentally pass char*. Fix by calling like:
69 // std::wstring path_wide;
70 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
71 // CreateFileW(path_wide.c_str());
72 "-DUNICODE=1",
73 "-D_UNICODE=1",
74
Josh Gao2e1e7892018-03-23 13:03:28 -070075 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080076 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070077
78 // MinGW hides some things behind _POSIX_SOURCE.
79 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080080 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070081
82 host_ldlibs: [
83 "-lws2_32",
84 "-lgdi32",
85 "-luserenv",
86 ],
Josh Gao27768452018-01-02 12:01:43 -080087 },
88 },
89}
90
91// libadb
92// =========================================================
93// These files are compiled for both the host and the device.
94libadb_srcs = [
95 "adb.cpp",
96 "adb_io.cpp",
97 "adb_listeners.cpp",
98 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -070099 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800100 "adb_utils.cpp",
101 "fdevent.cpp",
102 "services.cpp",
103 "sockets.cpp",
104 "socket_spec.cpp",
105 "sysdeps/errno.cpp",
106 "transport.cpp",
107 "transport_local.cpp",
108 "transport_usb.cpp",
109]
110
111libadb_posix_srcs = [
112 "sysdeps_unix.cpp",
113 "sysdeps/posix/network.cpp",
114]
115
116libadb_test_srcs = [
117 "adb_io_test.cpp",
118 "adb_listeners_test.cpp",
119 "adb_utils_test.cpp",
120 "fdevent_test.cpp",
121 "socket_spec_test.cpp",
122 "socket_test.cpp",
123 "sysdeps_test.cpp",
124 "sysdeps/stat_test.cpp",
125 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700126 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800127]
128
129cc_library_host_static {
130 name: "libadb_host",
131 defaults: ["adb_defaults"],
132
133 srcs: libadb_srcs + [
134 "client/auth.cpp",
135 "client/usb_libusb.cpp",
136 "client/usb_dispatch.cpp",
137 "client/transport_mdns.cpp",
138 ],
139
140 target: {
141 linux: {
142 srcs: ["client/usb_linux.cpp"],
143 },
144 darwin: {
145 srcs: ["client/usb_osx.cpp"],
146 },
147
148 not_windows: {
149 srcs: libadb_posix_srcs,
150 },
151 windows: {
152 enabled: true,
153 srcs: [
154 "client/usb_windows.cpp",
155 "sysdeps_win32.cpp",
156 "sysdeps/win32/errno.cpp",
157 "sysdeps/win32/stat.cpp",
158 ],
159 shared_libs: ["AdbWinApi"],
160 },
161 },
162
163 static_libs: [
164 "libbase",
165 "libcrypto_utils",
166 "libcrypto",
167 "libdiagnose_usb",
168 "libmdnssd",
169 "libusb",
170 ],
171}
172
173cc_test_host {
174 name: "adb_test",
175 defaults: ["adb_defaults"],
176 srcs: libadb_test_srcs,
177 static_libs: [
178 "libadb_host",
179 "libbase",
180 "libcutils",
181 "libcrypto_utils",
182 "libcrypto",
183 "libmdnssd",
184 "libdiagnose_usb",
185 "libusb",
186 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700187
188 target: {
189 windows: {
190 enabled: true,
191 shared_libs: ["AdbWinApi"],
192 },
193 },
Josh Gao27768452018-01-02 12:01:43 -0800194}
195
Josh Gao9c596492018-04-04 11:27:24 -0700196cc_benchmark {
197 name: "adb_benchmark",
198 defaults: ["adb_defaults"],
199
200 srcs: ["transport_benchmark.cpp"],
201 target: {
202 android: {
203 static_libs: [
204 "libadbd",
205 ],
206 },
207 host: {
208 static_libs: [
209 "libadb_host",
210 ],
211 },
212 },
213
214 static_libs: [
215 "libbase",
216 "libcutils",
217 "libcrypto_utils",
218 "libcrypto",
219 "libdiagnose_usb",
220 "liblog",
221 "libusb",
222 ],
223}
224
Josh Gao27768452018-01-02 12:01:43 -0800225cc_binary_host {
226 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800227
228 defaults: ["adb_defaults"],
229
230 srcs: [
231 "client/adb_client.cpp",
232 "client/bugreport.cpp",
233 "client/commandline.cpp",
234 "client/file_sync_client.cpp",
235 "client/main.cpp",
236 "client/console.cpp",
237 "client/line_printer.cpp",
238 "shell_service_protocol.cpp",
239 ],
240
241 static_libs: [
242 "libadb_host",
243 "libbase",
244 "libcutils",
245 "libcrypto_utils",
246 "libcrypto",
247 "libdiagnose_usb",
248 "liblog",
249 "libmdnssd",
250 "libusb",
251 ],
252
253 stl: "libc++_static",
254
255 // Don't add anything here, we don't want additional shared dependencies
256 // on the host adb tool, and shared libraries that link against libc++
257 // will violate ODR
258 shared_libs: [],
259
260 target: {
261 darwin: {
262 cflags: [
263 "-Wno-sizeof-pointer-memaccess",
264 ],
265 },
266 windows: {
267 enabled: true,
268 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800269 shared_libs: ["AdbWinApi"],
270 required: [
271 "AdbWinUsbApi",
272 ],
273 },
274 },
275}
276
277cc_library_static {
278 name: "libadbd",
279 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900280 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800281
282 // libminadbd wants both, for some reason.
283 compile_multilib: "both",
284 srcs: libadb_srcs + libadb_posix_srcs + [
285 "daemon/auth.cpp",
286 "daemon/usb.cpp",
287 "daemon/jdwp_service.cpp",
288 ],
289
290 static_libs: [
291 "libasyncio",
292 "libbootloader_message",
293 "libcrypto_utils",
294 "libcrypto",
295 "libdiagnose_usb",
296 "libqemu_pipe",
297 "libbase",
298 ],
299}
300
301cc_binary {
302 name: "adbd",
303 defaults: ["adb_defaults"],
304
Josh Gao8db99f82018-03-06 12:57:27 -0800305 // adbd must be static, as it is copied into the recovery image.
306 static_executable: true,
Jiyong Parka0e75042018-05-24 14:11:00 +0900307 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800308
Josh Gao27768452018-01-02 12:01:43 -0800309 srcs: [
310 "daemon/main.cpp",
311 "daemon/mdns.cpp",
312 "daemon/file_sync_service.cpp",
313 "daemon/framebuffer_service.cpp",
314 "daemon/remount_service.cpp",
315 "daemon/set_verity_enable_state_service.cpp",
316 "daemon/shell_service.cpp",
317 "shell_service_protocol.cpp",
318 ],
319
320 cflags: [
321 "-D_GNU_SOURCE",
322 "-Wno-deprecated-declarations",
323 ],
324
325 strip: {
326 keep_symbols: true,
327 },
328
329 static_libs: [
330 "libadbd",
331 "libasyncio",
332 "libavb_user",
333 "libbootloader_message",
334 "libcrypto_utils",
335 "libcrypto",
336 "libdiagnose_usb",
337 "libfec",
338 "libfec_rs",
339 "libfs_mgr",
340 "liblog",
341 "libext4_utils",
342 "libmdnssd",
343 "libminijail",
344 "libselinux",
345 "libsquashfs_utils",
346 "libqemu_pipe",
347 "libdebuggerd_handler",
348
349 "libbase",
350 "libcutils",
351 ],
352}
353
354cc_test {
355 name: "adbd_test",
356 defaults: ["adb_defaults"],
357 srcs: libadb_test_srcs + [
358 "daemon/shell_service.cpp",
359 "daemon/shell_service_test.cpp",
360 "shell_service_protocol.cpp",
361 "shell_service_protocol_test.cpp",
362 ],
363
364 static_libs: [
365 "libadbd",
366 "libbase",
367 "libcutils",
368 "libcrypto_utils",
369 "libcrypto",
370 "libdiagnose_usb",
371 "liblog",
372 "libusb",
373 "libmdnssd",
374 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700375 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800376}
377
GuangHui Liu41bda342017-05-10 14:37:17 -0700378python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800379 name: "adb_integration_test_adb",
380 main: "test_adb.py",
381 srcs: [
382 "test_adb.py",
383 ],
384 libs: [
385 "adb_py",
386 ],
387 version: {
388 py2: {
389 enabled: true,
390 },
391 py3: {
392 enabled: false,
393 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700394 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700395}
396
397python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800398 name: "adb_integration_test_device",
399 main: "test_device.py",
400 srcs: [
401 "test_device.py",
402 ],
403 libs: [
404 "adb_py",
405 ],
406 version: {
407 py2: {
408 enabled: true,
409 },
410 py3: {
411 enabled: false,
412 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700413 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700414}