blob: 36bfad4337f0222afee1b0cdd90b1539ea38f146 [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",
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070022 "-Wexit-time-destructors",
Josh Gao27768452018-01-02 12:01:43 -080023 "-Wno-unused-parameter",
24 "-Wno-missing-field-initializers",
25 "-Wvla",
26 ],
Josh Gao6eb78822018-11-16 15:40:16 -080027 cpp_std: "experimental",
Josh Gao27768452018-01-02 12:01:43 -080028
Josh Gaoc7567fa2018-02-27 15:49:23 -080029 use_version_lib: true,
30
Josh Gao27768452018-01-02 12:01:43 -080031 compile_multilib: "first",
32 product_variables: {
33 debuggable: {
34 cflags: [
35 "-DALLOW_ADBD_ROOT",
36 "-DALLOW_ADBD_DISABLE_VERITY",
37 "-DALLOW_ADBD_NO_AUTH",
38 ],
39 },
40 },
41
42 target: {
43 android: {
Josh Gao560a5472018-10-12 16:37:31 -070044 cflags: [
45 "-DADB_HOST=0",
46 "-Wthread-safety",
47 ],
Josh Gao27768452018-01-02 12:01:43 -080048 },
49
50 host: {
51 cflags: ["-DADB_HOST=1"],
52 },
53
54 darwin: {
55 host_ldlibs: [
56 "-lpthread",
57 "-framework CoreFoundation",
58 "-framework IOKit",
59 "-lobjc",
60 ],
61 },
62
63 windows: {
64 cflags: [
65 // Define windows.h and tchar.h Unicode preprocessor symbols so that
66 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
67 // build if you accidentally pass char*. Fix by calling like:
68 // std::wstring path_wide;
69 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
70 // CreateFileW(path_wide.c_str());
71 "-DUNICODE=1",
72 "-D_UNICODE=1",
73
Elliott Hughes3c59cb82018-12-03 09:02:18 -080074 // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080075 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070076
77 // MinGW hides some things behind _POSIX_SOURCE.
78 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080079 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070080
81 host_ldlibs: [
82 "-lws2_32",
83 "-lgdi32",
84 "-luserenv",
85 ],
Josh Gao27768452018-01-02 12:01:43 -080086 },
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070087
88 not_windows: {
89 cflags: [
90 "-Wthread-safety",
91 ],
92 },
Josh Gao27768452018-01-02 12:01:43 -080093 },
94}
95
96// libadb
97// =========================================================
98// These files are compiled for both the host and the device.
99libadb_srcs = [
100 "adb.cpp",
101 "adb_io.cpp",
102 "adb_listeners.cpp",
103 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700104 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800105 "adb_utils.cpp",
106 "fdevent.cpp",
107 "services.cpp",
108 "sockets.cpp",
109 "socket_spec.cpp",
110 "sysdeps/errno.cpp",
111 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700112 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800113 "transport_local.cpp",
114 "transport_usb.cpp",
115]
116
117libadb_posix_srcs = [
118 "sysdeps_unix.cpp",
119 "sysdeps/posix/network.cpp",
120]
121
122libadb_test_srcs = [
123 "adb_io_test.cpp",
124 "adb_listeners_test.cpp",
125 "adb_utils_test.cpp",
126 "fdevent_test.cpp",
127 "socket_spec_test.cpp",
128 "socket_test.cpp",
129 "sysdeps_test.cpp",
130 "sysdeps/stat_test.cpp",
131 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700132 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800133]
134
135cc_library_host_static {
136 name: "libadb_host",
137 defaults: ["adb_defaults"],
138
139 srcs: libadb_srcs + [
140 "client/auth.cpp",
141 "client/usb_libusb.cpp",
142 "client/usb_dispatch.cpp",
143 "client/transport_mdns.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000144 "client/fastdeploy.cpp",
145 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800146 ],
147
Dan Willemsenab971b52018-08-29 14:58:02 -0700148 generated_headers: ["platform_tools_version"],
149
Josh Gao27768452018-01-02 12:01:43 -0800150 target: {
151 linux: {
152 srcs: ["client/usb_linux.cpp"],
153 },
154 darwin: {
155 srcs: ["client/usb_osx.cpp"],
156 },
157
158 not_windows: {
159 srcs: libadb_posix_srcs,
160 },
161 windows: {
162 enabled: true,
163 srcs: [
164 "client/usb_windows.cpp",
165 "sysdeps_win32.cpp",
166 "sysdeps/win32/errno.cpp",
167 "sysdeps/win32/stat.cpp",
168 ],
169 shared_libs: ["AdbWinApi"],
170 },
171 },
172
173 static_libs: [
174 "libbase",
175 "libcrypto_utils",
176 "libcrypto",
177 "libdiagnose_usb",
178 "libmdnssd",
179 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100180 "libandroidfw",
181 "libziparchive",
182 "libz",
183 "libutils",
184 "liblog",
185 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800186 ],
187}
188
189cc_test_host {
190 name: "adb_test",
191 defaults: ["adb_defaults"],
192 srcs: libadb_test_srcs,
193 static_libs: [
194 "libadb_host",
195 "libbase",
196 "libcutils",
197 "libcrypto_utils",
198 "libcrypto",
199 "libmdnssd",
200 "libdiagnose_usb",
201 "libusb",
202 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700203
204 target: {
205 windows: {
206 enabled: true,
207 shared_libs: ["AdbWinApi"],
208 },
209 },
Josh Gao27768452018-01-02 12:01:43 -0800210}
211
Josh Gao9c596492018-04-04 11:27:24 -0700212cc_benchmark {
213 name: "adb_benchmark",
214 defaults: ["adb_defaults"],
215
216 srcs: ["transport_benchmark.cpp"],
217 target: {
218 android: {
219 static_libs: [
220 "libadbd",
221 ],
222 },
223 host: {
224 static_libs: [
225 "libadb_host",
226 ],
227 },
228 },
229
230 static_libs: [
231 "libbase",
232 "libcutils",
233 "libcrypto_utils",
234 "libcrypto",
235 "libdiagnose_usb",
236 "liblog",
237 "libusb",
238 ],
239}
240
Josh Gao27768452018-01-02 12:01:43 -0800241cc_binary_host {
242 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800243
244 defaults: ["adb_defaults"],
245
246 srcs: [
247 "client/adb_client.cpp",
248 "client/bugreport.cpp",
249 "client/commandline.cpp",
250 "client/file_sync_client.cpp",
251 "client/main.cpp",
252 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000253 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800254 "client/line_printer.cpp",
255 "shell_service_protocol.cpp",
256 ],
257
258 static_libs: [
259 "libadb_host",
260 "libbase",
261 "libcutils",
262 "libcrypto_utils",
263 "libcrypto",
264 "libdiagnose_usb",
265 "liblog",
266 "libmdnssd",
267 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100268 "libandroidfw",
269 "libziparchive",
270 "libz",
271 "libutils",
272 "liblog",
273 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800274 ],
275
276 stl: "libc++_static",
277
278 // Don't add anything here, we don't want additional shared dependencies
279 // on the host adb tool, and shared libraries that link against libc++
280 // will violate ODR
281 shared_libs: [],
282
Idries Hamadi7575cd92018-08-24 11:46:45 +0100283 required: [
284 "deploypatchgenerator",
285 ],
286
Dan Willemsen3f439a72018-11-19 19:11:35 -0800287 // Archive adb, adb.exe.
288 dist: {
289 targets: [
290 "dist_files",
291 "sdk",
292 "win_sdk",
293 ],
294 },
295
Josh Gao27768452018-01-02 12:01:43 -0800296 target: {
297 darwin: {
298 cflags: [
299 "-Wno-sizeof-pointer-memaccess",
300 ],
301 },
302 windows: {
303 enabled: true,
304 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800305 shared_libs: ["AdbWinApi"],
306 required: [
307 "AdbWinUsbApi",
308 ],
309 },
310 },
311}
312
Tao Baoeca59ae2018-07-30 20:45:27 -0700313// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800314cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700315 name: "libadbd_core",
316 defaults: ["adb_defaults"],
317 recovery_available: true,
318
319 // libminadbd wants both, as it's used to build native tests.
320 compile_multilib: "both",
321
322 srcs: libadb_srcs + libadb_posix_srcs + [
323 "daemon/auth.cpp",
324 "daemon/jdwp_service.cpp",
Josh Gaoc51726c2018-10-11 16:33:05 -0700325 "daemon/usb.cpp",
Josh Gao613cbb42018-10-08 14:20:29 -0700326 "daemon/usb_ffs.cpp",
Josh Gao61e9e392018-10-08 14:42:19 -0700327 "daemon/usb_legacy.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700328 ],
329
330 local_include_dirs: [
331 "daemon/include",
332 ],
333
Dan Willemsenab971b52018-08-29 14:58:02 -0700334 generated_headers: ["platform_tools_version"],
335
Tao Baoeca59ae2018-07-30 20:45:27 -0700336 static_libs: [
337 "libdiagnose_usb",
338 "libqemu_pipe",
339 ],
340
341 shared_libs: [
342 "libasyncio",
343 "libbase",
344 "libcrypto",
345 "libcrypto_utils",
346 "libcutils",
347 "liblog",
348 ],
349}
350
351cc_library {
352 name: "libadbd_services",
353 defaults: ["adb_defaults"],
354 recovery_available: true,
355 compile_multilib: "both",
356
357 srcs: [
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800358 "daemon/abb_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700359 "daemon/file_sync_service.cpp",
360 "daemon/framebuffer_service.cpp",
361 "daemon/mdns.cpp",
362 "daemon/remount_service.cpp",
363 "daemon/services.cpp",
364 "daemon/set_verity_enable_state_service.cpp",
365 "daemon/shell_service.cpp",
366 "shell_service_protocol.cpp",
367 ],
368
369 cflags: [
370 "-D_GNU_SOURCE",
371 "-Wno-deprecated-declarations",
372 ],
373
374 static_libs: [
375 "libadbd_core",
376 "libavb_user",
377 "libdiagnose_usb",
378 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700379 ],
380
381 shared_libs: [
382 "libasyncio",
383 "libbase",
384 "libbootloader_message",
385 "libcrypto",
386 "libcrypto_utils",
387 "libcutils",
388 "libext4_utils",
389 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700390 "libfs_mgr",
391 "liblog",
392 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700393 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700394 ],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800395
396 target: {
397 recovery: {
398 exclude_srcs: [
399 "daemon/abb_service.cpp",
400 ],
401 },
402 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700403}
404
405cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800406 name: "libadbd",
407 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900408 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800409
Tao Baoeca59ae2018-07-30 20:45:27 -0700410 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
411 use_version_lib: false,
412
413 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800414 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700415
416 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
417 whole_static_libs: [
418 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800419 ],
420
Tao Baoeca59ae2018-07-30 20:45:27 -0700421 shared_libs: [
422 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800423 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800424 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700425 "libcrypto",
426 "libcrypto_utils",
427 "libcutils",
428 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800429 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700430
431 export_include_dirs: [
432 "daemon/include",
433 ],
Josh Gao27768452018-01-02 12:01:43 -0800434}
435
436cc_binary {
437 name: "adbd",
438 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900439 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800440
Josh Gao27768452018-01-02 12:01:43 -0800441 srcs: [
442 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800443 ],
444
445 cflags: [
446 "-D_GNU_SOURCE",
447 "-Wno-deprecated-declarations",
448 ],
449
450 strip: {
451 keep_symbols: true,
452 },
453
Tao Baoeca59ae2018-07-30 20:45:27 -0700454 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800455 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700456 "libadbd_services",
457 "libbase",
458 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800459 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700460 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800461 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800462 "libminijail",
463 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800464 ],
465}
466
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800467cc_binary {
468 name: "abb",
469
470 defaults: ["adb_defaults"],
471 recovery_available: false,
472
473 srcs: [
474 "daemon/abb.cpp",
475 ],
476
477 cflags: [
478 "-D_GNU_SOURCE",
479 "-Wno-deprecated-declarations",
480 ],
481
482 strip: {
483 keep_symbols: true,
484 },
485
486 static_libs: [
487 "libadbd_core",
488 "libadbd_services",
489 "libcmd",
490 ],
491
492 shared_libs: [
493 "libbase",
494 "libbinder",
495 "liblog",
496 "libutils",
497 "libselinux",
498 ],
499}
500
Josh Gao27768452018-01-02 12:01:43 -0800501cc_test {
502 name: "adbd_test",
503 defaults: ["adb_defaults"],
504 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700505 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800506 "daemon/shell_service.cpp",
507 "daemon/shell_service_test.cpp",
508 "shell_service_protocol.cpp",
509 "shell_service_protocol_test.cpp",
510 ],
511
512 static_libs: [
513 "libadbd",
514 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700515 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800516 "libcutils",
517 "libcrypto_utils",
518 "libcrypto",
519 "libdiagnose_usb",
520 "liblog",
521 "libusb",
522 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900523 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800524 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700525 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800526}
527
Julien Desprez75fea7e2018-08-08 12:08:50 -0700528python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800529 name: "adb_integration_test_adb",
530 main: "test_adb.py",
531 srcs: [
532 "test_adb.py",
533 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700534 test_config: "adb_integration_test_adb.xml",
535 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800536 version: {
537 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700538 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800539 },
540 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700541 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800542 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700543 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700544}
545
Julien Desprez618f0e12018-10-12 13:48:14 -0700546python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800547 name: "adb_integration_test_device",
548 main: "test_device.py",
549 srcs: [
550 "test_device.py",
551 ],
552 libs: [
553 "adb_py",
554 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700555 test_config: "adb_integration_test_device.xml",
556 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800557 version: {
558 py2: {
559 enabled: true,
560 },
561 py3: {
562 enabled: false,
563 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700564 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700565}