blob: b87f4cbaa1a2b370430d2cb3897909eea09aced0 [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",
Josh Gao776c2ec2019-01-22 19:36:15 -080025 "-Wthread-safety",
Josh Gao27768452018-01-02 12:01:43 -080026 "-Wvla",
Bowgo Tsai9b30c0a2019-03-12 04:25:33 +080027 "-DADB_HOST=1", // overridden by adbd_defaults
28 "-DALLOW_ADBD_ROOT=0", // overridden by adbd_defaults
Josh Gao93d63c02019-04-18 16:39:30 -070029 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION=1",
Josh Gao27768452018-01-02 12:01:43 -080030 ],
Josh Gao6eb78822018-11-16 15:40:16 -080031 cpp_std: "experimental",
Josh Gao27768452018-01-02 12:01:43 -080032
Josh Gaoc7567fa2018-02-27 15:49:23 -080033 use_version_lib: true,
Josh Gao27768452018-01-02 12:01:43 -080034 compile_multilib: "first",
Josh Gao27768452018-01-02 12:01:43 -080035
36 target: {
Josh Gao27768452018-01-02 12:01:43 -080037 darwin: {
38 host_ldlibs: [
39 "-lpthread",
40 "-framework CoreFoundation",
41 "-framework IOKit",
42 "-lobjc",
43 ],
44 },
45
46 windows: {
47 cflags: [
48 // Define windows.h and tchar.h Unicode preprocessor symbols so that
49 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
50 // build if you accidentally pass char*. Fix by calling like:
51 // std::wstring path_wide;
52 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
53 // CreateFileW(path_wide.c_str());
54 "-DUNICODE=1",
55 "-D_UNICODE=1",
56
Elliott Hughes3c59cb82018-12-03 09:02:18 -080057 // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080058 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070059
60 // MinGW hides some things behind _POSIX_SOURCE.
61 "-D_POSIX_SOURCE",
Josh Gao776c2ec2019-01-22 19:36:15 -080062
63 // Not supported yet.
64 "-Wno-thread-safety",
Josh Gao27768452018-01-02 12:01:43 -080065 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070066
67 host_ldlibs: [
68 "-lws2_32",
69 "-lgdi32",
70 "-luserenv",
71 ],
Josh Gao27768452018-01-02 12:01:43 -080072 },
Josh Gao776c2ec2019-01-22 19:36:15 -080073 },
74}
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070075
Josh Gao776c2ec2019-01-22 19:36:15 -080076cc_defaults {
77 name: "adbd_defaults",
78 defaults: ["adb_defaults"],
79
80 cflags: ["-UADB_HOST", "-DADB_HOST=0"],
81 product_variables: {
82 debuggable: {
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070083 cflags: [
Bowgo Tsai9b30c0a2019-03-12 04:25:33 +080084 "-UALLOW_ADBD_ROOT",
85 "-DALLOW_ADBD_ROOT=1",
Josh Gao776c2ec2019-01-22 19:36:15 -080086 "-DALLOW_ADBD_DISABLE_VERITY",
87 "-DALLOW_ADBD_NO_AUTH",
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070088 ],
89 },
Josh Gao27768452018-01-02 12:01:43 -080090 },
91}
92
Josh Gao776c2ec2019-01-22 19:36:15 -080093cc_defaults {
94 name: "host_adbd_supported",
95
96 host_supported: true,
97 target: {
98 linux: {
99 enabled: true,
100 host_ldlibs: [
101 "-lresolv", // b64_pton
102 "-lutil", // forkpty
103 ],
104 },
105 darwin: {
106 enabled: false,
107 },
108 windows: {
109 enabled: false,
110 },
111 },
112}
113
Josh Gao27768452018-01-02 12:01:43 -0800114// libadb
115// =========================================================
116// These files are compiled for both the host and the device.
117libadb_srcs = [
118 "adb.cpp",
119 "adb_io.cpp",
120 "adb_listeners.cpp",
121 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700122 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800123 "adb_utils.cpp",
124 "fdevent.cpp",
125 "services.cpp",
126 "sockets.cpp",
127 "socket_spec.cpp",
128 "sysdeps/errno.cpp",
129 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700130 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800131 "transport_local.cpp",
132 "transport_usb.cpp",
133]
134
135libadb_posix_srcs = [
136 "sysdeps_unix.cpp",
137 "sysdeps/posix/network.cpp",
138]
139
140libadb_test_srcs = [
141 "adb_io_test.cpp",
142 "adb_listeners_test.cpp",
143 "adb_utils_test.cpp",
144 "fdevent_test.cpp",
145 "socket_spec_test.cpp",
146 "socket_test.cpp",
147 "sysdeps_test.cpp",
148 "sysdeps/stat_test.cpp",
149 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700150 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800151]
152
153cc_library_host_static {
154 name: "libadb_host",
155 defaults: ["adb_defaults"],
156
157 srcs: libadb_srcs + [
158 "client/auth.cpp",
159 "client/usb_libusb.cpp",
160 "client/usb_dispatch.cpp",
161 "client/transport_mdns.cpp",
162 ],
163
Dan Willemsenab971b52018-08-29 14:58:02 -0700164 generated_headers: ["platform_tools_version"],
165
Josh Gao27768452018-01-02 12:01:43 -0800166 target: {
167 linux: {
168 srcs: ["client/usb_linux.cpp"],
169 },
170 darwin: {
171 srcs: ["client/usb_osx.cpp"],
172 },
173
174 not_windows: {
175 srcs: libadb_posix_srcs,
176 },
177 windows: {
178 enabled: true,
179 srcs: [
180 "client/usb_windows.cpp",
181 "sysdeps_win32.cpp",
182 "sysdeps/win32/errno.cpp",
183 "sysdeps/win32/stat.cpp",
184 ],
185 shared_libs: ["AdbWinApi"],
186 },
187 },
188
189 static_libs: [
190 "libbase",
191 "libcrypto_utils",
192 "libcrypto",
193 "libdiagnose_usb",
194 "libmdnssd",
195 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100196 "libutils",
197 "liblog",
198 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800199 ],
200}
201
202cc_test_host {
203 name: "adb_test",
204 defaults: ["adb_defaults"],
205 srcs: libadb_test_srcs,
206 static_libs: [
207 "libadb_host",
208 "libbase",
209 "libcutils",
210 "libcrypto_utils",
211 "libcrypto",
212 "libmdnssd",
213 "libdiagnose_usb",
214 "libusb",
215 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700216
217 target: {
218 windows: {
219 enabled: true,
220 shared_libs: ["AdbWinApi"],
221 },
222 },
Josh Gao27768452018-01-02 12:01:43 -0800223}
224
Josh Gao9c596492018-04-04 11:27:24 -0700225cc_benchmark {
226 name: "adb_benchmark",
227 defaults: ["adb_defaults"],
228
229 srcs: ["transport_benchmark.cpp"],
230 target: {
231 android: {
232 static_libs: [
233 "libadbd",
234 ],
235 },
236 host: {
237 static_libs: [
238 "libadb_host",
239 ],
240 },
241 },
242
243 static_libs: [
244 "libbase",
245 "libcutils",
246 "libcrypto_utils",
247 "libcrypto",
248 "libdiagnose_usb",
249 "liblog",
250 "libusb",
251 ],
252}
253
Josh Gao27768452018-01-02 12:01:43 -0800254cc_binary_host {
255 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800256
257 defaults: ["adb_defaults"],
258
259 srcs: [
260 "client/adb_client.cpp",
261 "client/bugreport.cpp",
262 "client/commandline.cpp",
263 "client/file_sync_client.cpp",
264 "client/main.cpp",
265 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000266 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800267 "client/line_printer.cpp",
268 "shell_service_protocol.cpp",
269 ],
270
271 static_libs: [
272 "libadb_host",
273 "libbase",
274 "libcutils",
275 "libcrypto_utils",
276 "libcrypto",
277 "libdiagnose_usb",
278 "liblog",
279 "libmdnssd",
280 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100281 "libutils",
282 "liblog",
283 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800284 ],
285
286 stl: "libc++_static",
287
288 // Don't add anything here, we don't want additional shared dependencies
289 // on the host adb tool, and shared libraries that link against libc++
290 // will violate ODR
291 shared_libs: [],
292
Idries Hamadi7575cd92018-08-24 11:46:45 +0100293 required: [
294 "deploypatchgenerator",
295 ],
296
Dan Willemsen3f439a72018-11-19 19:11:35 -0800297 // Archive adb, adb.exe.
298 dist: {
299 targets: [
300 "dist_files",
301 "sdk",
302 "win_sdk",
303 ],
304 },
305
Josh Gao27768452018-01-02 12:01:43 -0800306 target: {
307 darwin: {
308 cflags: [
309 "-Wno-sizeof-pointer-memaccess",
310 ],
311 },
312 windows: {
313 enabled: true,
314 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800315 shared_libs: ["AdbWinApi"],
316 required: [
317 "AdbWinUsbApi",
318 ],
319 },
320 },
321}
322
Tao Baoeca59ae2018-07-30 20:45:27 -0700323// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800324cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700325 name: "libadbd_core",
Josh Gao776c2ec2019-01-22 19:36:15 -0800326 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700327 recovery_available: true,
328
329 // libminadbd wants both, as it's used to build native tests.
330 compile_multilib: "both",
331
332 srcs: libadb_srcs + libadb_posix_srcs + [
333 "daemon/auth.cpp",
334 "daemon/jdwp_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700335 ],
336
337 local_include_dirs: [
338 "daemon/include",
339 ],
340
Dan Willemsenab971b52018-08-29 14:58:02 -0700341 generated_headers: ["platform_tools_version"],
342
Tao Baoeca59ae2018-07-30 20:45:27 -0700343 static_libs: [
344 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700345 ],
346
347 shared_libs: [
348 "libasyncio",
349 "libbase",
350 "libcrypto",
351 "libcrypto_utils",
352 "libcutils",
353 "liblog",
354 ],
Josh Gao776c2ec2019-01-22 19:36:15 -0800355
356 target: {
357 android: {
358 whole_static_libs: [
359 "libqemu_pipe",
360 ],
361 srcs: [
362 "daemon/transport_qemu.cpp",
363 "daemon/usb.cpp",
364 "daemon/usb_ffs.cpp",
365 "daemon/usb_legacy.cpp",
366 ]
367 },
368 linux_glibc: {
369 srcs: [
370 "daemon/usb_dummy.cpp",
371 ]
372 }
373 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700374}
375
376cc_library {
377 name: "libadbd_services",
Josh Gao776c2ec2019-01-22 19:36:15 -0800378 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700379 recovery_available: true,
380 compile_multilib: "both",
381
382 srcs: [
383 "daemon/file_sync_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700384 "daemon/services.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700385 "daemon/shell_service.cpp",
386 "shell_service_protocol.cpp",
387 ],
388
389 cflags: [
390 "-D_GNU_SOURCE",
391 "-Wno-deprecated-declarations",
392 ],
393
394 static_libs: [
395 "libadbd_core",
Tao Baoeca59ae2018-07-30 20:45:27 -0700396 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700397 ],
398
399 shared_libs: [
400 "libasyncio",
401 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700402 "libcrypto",
403 "libcrypto_utils",
404 "libcutils",
Tao Baoeca59ae2018-07-30 20:45:27 -0700405 "liblog",
Tao Baoeca59ae2018-07-30 20:45:27 -0700406 ],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800407
Mark Salyzyn2f6c1802019-02-15 07:45:26 -0800408 product_variables: {
409 debuggable: {
410 required: [
411 "remount",
412 ],
413 },
414 },
415
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800416 target: {
Josh Gao776c2ec2019-01-22 19:36:15 -0800417 android: {
418 srcs: [
419 "daemon/abb_service.cpp",
420 "daemon/framebuffer_service.cpp",
421 "daemon/mdns.cpp",
422 "daemon/reboot_service.cpp",
423 "daemon/remount_service.cpp",
424 "daemon/restart_service.cpp",
425 "daemon/set_verity_enable_state_service.cpp",
426 ],
427 static_libs: [
428 "libavb_user",
429 ],
430 shared_libs: [
431 "libbootloader_message",
432 "libmdnssd",
433 "libext4_utils",
434 "libfec",
435 "libfs_mgr",
436 "libselinux",
437 ],
438 },
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800439 recovery: {
440 exclude_srcs: [
441 "daemon/abb_service.cpp",
442 ],
443 },
444 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700445}
446
447cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800448 name: "libadbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800449 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900450 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800451
Tao Baoeca59ae2018-07-30 20:45:27 -0700452 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
453 use_version_lib: false,
454
455 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800456 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700457
458 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
459 whole_static_libs: [
460 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800461 ],
462
Tao Baoeca59ae2018-07-30 20:45:27 -0700463 shared_libs: [
464 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800465 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800466 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700467 "libcrypto",
468 "libcrypto_utils",
469 "libcutils",
470 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800471 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700472
473 export_include_dirs: [
474 "daemon/include",
475 ],
Josh Gao27768452018-01-02 12:01:43 -0800476}
477
478cc_binary {
479 name: "adbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800480 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900481 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800482
Josh Gao27768452018-01-02 12:01:43 -0800483 srcs: [
484 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800485 ],
486
487 cflags: [
488 "-D_GNU_SOURCE",
489 "-Wno-deprecated-declarations",
490 ],
491
492 strip: {
493 keep_symbols: true,
494 },
495
Tao Baoeca59ae2018-07-30 20:45:27 -0700496 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800497 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700498 "libadbd_services",
499 "libbase",
500 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800501 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700502 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800503 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800504 "libminijail",
505 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800506 ],
507}
508
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800509cc_binary {
510 name: "abb",
511
Josh Gao776c2ec2019-01-22 19:36:15 -0800512 defaults: ["adbd_defaults"],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800513 recovery_available: false,
514
515 srcs: [
516 "daemon/abb.cpp",
517 ],
518
519 cflags: [
520 "-D_GNU_SOURCE",
521 "-Wno-deprecated-declarations",
522 ],
523
524 strip: {
525 keep_symbols: true,
526 },
527
528 static_libs: [
529 "libadbd_core",
530 "libadbd_services",
531 "libcmd",
532 ],
533
534 shared_libs: [
535 "libbase",
536 "libbinder",
537 "liblog",
538 "libutils",
539 "libselinux",
540 ],
541}
542
Josh Gao27768452018-01-02 12:01:43 -0800543cc_test {
544 name: "adbd_test",
Josh Gao776c2ec2019-01-22 19:36:15 -0800545 defaults: ["adbd_defaults"],
Josh Gao27768452018-01-02 12:01:43 -0800546 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700547 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800548 "daemon/shell_service.cpp",
549 "daemon/shell_service_test.cpp",
550 "shell_service_protocol.cpp",
551 "shell_service_protocol_test.cpp",
552 ],
553
554 static_libs: [
555 "libadbd",
556 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700557 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800558 "libcutils",
559 "libcrypto_utils",
560 "libcrypto",
561 "libdiagnose_usb",
562 "liblog",
563 "libusb",
564 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900565 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800566 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700567 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800568}
569
Julien Desprez75fea7e2018-08-08 12:08:50 -0700570python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800571 name: "adb_integration_test_adb",
572 main: "test_adb.py",
573 srcs: [
574 "test_adb.py",
575 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700576 test_config: "adb_integration_test_adb.xml",
577 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800578 version: {
579 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700580 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800581 },
582 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700583 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800584 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700585 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700586}
587
Julien Desprez618f0e12018-10-12 13:48:14 -0700588python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800589 name: "adb_integration_test_device",
590 main: "test_device.py",
591 srcs: [
592 "test_device.py",
593 ],
594 libs: [
595 "adb_py",
596 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700597 test_config: "adb_integration_test_device.xml",
598 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800599 version: {
600 py2: {
601 enabled: true,
602 },
603 py3: {
604 enabled: false,
605 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700606 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700607}