blob: 01e00dd1cdb7adcd260fef1f201792511ba336e6 [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 Gao27768452018-01-02 12:01:43 -080029 ],
Josh Gao6eb78822018-11-16 15:40:16 -080030 cpp_std: "experimental",
Josh Gao27768452018-01-02 12:01:43 -080031
Josh Gaoc7567fa2018-02-27 15:49:23 -080032 use_version_lib: true,
Josh Gao27768452018-01-02 12:01:43 -080033 compile_multilib: "first",
Josh Gao27768452018-01-02 12:01:43 -080034
35 target: {
Josh Gao27768452018-01-02 12:01:43 -080036 darwin: {
37 host_ldlibs: [
38 "-lpthread",
39 "-framework CoreFoundation",
40 "-framework IOKit",
41 "-lobjc",
42 ],
43 },
44
45 windows: {
46 cflags: [
47 // Define windows.h and tchar.h Unicode preprocessor symbols so that
48 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
49 // build if you accidentally pass char*. Fix by calling like:
50 // std::wstring path_wide;
51 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
52 // CreateFileW(path_wide.c_str());
53 "-DUNICODE=1",
54 "-D_UNICODE=1",
55
Elliott Hughes3c59cb82018-12-03 09:02:18 -080056 // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080057 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070058
59 // MinGW hides some things behind _POSIX_SOURCE.
60 "-D_POSIX_SOURCE",
Josh Gao776c2ec2019-01-22 19:36:15 -080061
62 // Not supported yet.
63 "-Wno-thread-safety",
Josh Gao27768452018-01-02 12:01:43 -080064 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070065
66 host_ldlibs: [
67 "-lws2_32",
68 "-lgdi32",
69 "-luserenv",
70 ],
Josh Gao27768452018-01-02 12:01:43 -080071 },
Josh Gao776c2ec2019-01-22 19:36:15 -080072 },
73}
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070074
Josh Gao776c2ec2019-01-22 19:36:15 -080075cc_defaults {
76 name: "adbd_defaults",
77 defaults: ["adb_defaults"],
78
79 cflags: ["-UADB_HOST", "-DADB_HOST=0"],
80 product_variables: {
81 debuggable: {
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070082 cflags: [
Bowgo Tsai9b30c0a2019-03-12 04:25:33 +080083 "-UALLOW_ADBD_ROOT",
84 "-DALLOW_ADBD_ROOT=1",
Josh Gao776c2ec2019-01-22 19:36:15 -080085 "-DALLOW_ADBD_DISABLE_VERITY",
86 "-DALLOW_ADBD_NO_AUTH",
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070087 ],
88 },
Josh Gao27768452018-01-02 12:01:43 -080089 },
90}
91
Josh Gao776c2ec2019-01-22 19:36:15 -080092cc_defaults {
93 name: "host_adbd_supported",
94
95 host_supported: true,
96 target: {
97 linux: {
98 enabled: true,
99 host_ldlibs: [
100 "-lresolv", // b64_pton
101 "-lutil", // forkpty
102 ],
103 },
104 darwin: {
105 enabled: false,
106 },
107 windows: {
108 enabled: false,
109 },
110 },
111}
112
Josh Gao27768452018-01-02 12:01:43 -0800113// libadb
114// =========================================================
115// These files are compiled for both the host and the device.
116libadb_srcs = [
117 "adb.cpp",
118 "adb_io.cpp",
119 "adb_listeners.cpp",
120 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700121 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800122 "adb_utils.cpp",
123 "fdevent.cpp",
124 "services.cpp",
125 "sockets.cpp",
126 "socket_spec.cpp",
127 "sysdeps/errno.cpp",
128 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700129 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800130 "transport_local.cpp",
131 "transport_usb.cpp",
132]
133
134libadb_posix_srcs = [
135 "sysdeps_unix.cpp",
136 "sysdeps/posix/network.cpp",
137]
138
139libadb_test_srcs = [
140 "adb_io_test.cpp",
141 "adb_listeners_test.cpp",
142 "adb_utils_test.cpp",
143 "fdevent_test.cpp",
144 "socket_spec_test.cpp",
145 "socket_test.cpp",
146 "sysdeps_test.cpp",
147 "sysdeps/stat_test.cpp",
148 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700149 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800150]
151
152cc_library_host_static {
153 name: "libadb_host",
154 defaults: ["adb_defaults"],
155
156 srcs: libadb_srcs + [
157 "client/auth.cpp",
158 "client/usb_libusb.cpp",
159 "client/usb_dispatch.cpp",
160 "client/transport_mdns.cpp",
161 ],
162
Dan Willemsenab971b52018-08-29 14:58:02 -0700163 generated_headers: ["platform_tools_version"],
164
Josh Gao27768452018-01-02 12:01:43 -0800165 target: {
166 linux: {
167 srcs: ["client/usb_linux.cpp"],
168 },
169 darwin: {
170 srcs: ["client/usb_osx.cpp"],
171 },
172
173 not_windows: {
174 srcs: libadb_posix_srcs,
175 },
176 windows: {
177 enabled: true,
178 srcs: [
179 "client/usb_windows.cpp",
180 "sysdeps_win32.cpp",
181 "sysdeps/win32/errno.cpp",
182 "sysdeps/win32/stat.cpp",
183 ],
184 shared_libs: ["AdbWinApi"],
185 },
186 },
187
188 static_libs: [
189 "libbase",
190 "libcrypto_utils",
191 "libcrypto",
192 "libdiagnose_usb",
193 "libmdnssd",
194 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100195 "libutils",
196 "liblog",
197 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800198 ],
199}
200
201cc_test_host {
202 name: "adb_test",
203 defaults: ["adb_defaults"],
204 srcs: libadb_test_srcs,
205 static_libs: [
206 "libadb_host",
207 "libbase",
208 "libcutils",
209 "libcrypto_utils",
210 "libcrypto",
211 "libmdnssd",
212 "libdiagnose_usb",
213 "libusb",
214 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700215
216 target: {
217 windows: {
218 enabled: true,
219 shared_libs: ["AdbWinApi"],
220 },
221 },
Josh Gao27768452018-01-02 12:01:43 -0800222}
223
Josh Gao9c596492018-04-04 11:27:24 -0700224cc_benchmark {
225 name: "adb_benchmark",
226 defaults: ["adb_defaults"],
227
228 srcs: ["transport_benchmark.cpp"],
229 target: {
230 android: {
231 static_libs: [
232 "libadbd",
233 ],
234 },
235 host: {
236 static_libs: [
237 "libadb_host",
238 ],
239 },
240 },
241
242 static_libs: [
243 "libbase",
244 "libcutils",
245 "libcrypto_utils",
246 "libcrypto",
247 "libdiagnose_usb",
248 "liblog",
249 "libusb",
250 ],
251}
252
Josh Gao27768452018-01-02 12:01:43 -0800253cc_binary_host {
254 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800255
256 defaults: ["adb_defaults"],
257
258 srcs: [
259 "client/adb_client.cpp",
260 "client/bugreport.cpp",
261 "client/commandline.cpp",
262 "client/file_sync_client.cpp",
263 "client/main.cpp",
264 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000265 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800266 "client/line_printer.cpp",
267 "shell_service_protocol.cpp",
268 ],
269
270 static_libs: [
271 "libadb_host",
272 "libbase",
273 "libcutils",
274 "libcrypto_utils",
275 "libcrypto",
276 "libdiagnose_usb",
277 "liblog",
278 "libmdnssd",
279 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100280 "libutils",
281 "liblog",
282 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800283 ],
284
285 stl: "libc++_static",
286
287 // Don't add anything here, we don't want additional shared dependencies
288 // on the host adb tool, and shared libraries that link against libc++
289 // will violate ODR
290 shared_libs: [],
291
Idries Hamadi7575cd92018-08-24 11:46:45 +0100292 required: [
293 "deploypatchgenerator",
294 ],
295
Dan Willemsen3f439a72018-11-19 19:11:35 -0800296 // Archive adb, adb.exe.
297 dist: {
298 targets: [
299 "dist_files",
300 "sdk",
301 "win_sdk",
302 ],
303 },
304
Josh Gao27768452018-01-02 12:01:43 -0800305 target: {
306 darwin: {
307 cflags: [
308 "-Wno-sizeof-pointer-memaccess",
309 ],
310 },
311 windows: {
312 enabled: true,
313 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800314 shared_libs: ["AdbWinApi"],
315 required: [
316 "AdbWinUsbApi",
317 ],
318 },
319 },
320}
321
Tao Baoeca59ae2018-07-30 20:45:27 -0700322// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800323cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700324 name: "libadbd_core",
Josh Gao776c2ec2019-01-22 19:36:15 -0800325 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700326 recovery_available: true,
327
328 // libminadbd wants both, as it's used to build native tests.
329 compile_multilib: "both",
330
331 srcs: libadb_srcs + libadb_posix_srcs + [
332 "daemon/auth.cpp",
333 "daemon/jdwp_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700334 ],
335
336 local_include_dirs: [
337 "daemon/include",
338 ],
339
Dan Willemsenab971b52018-08-29 14:58:02 -0700340 generated_headers: ["platform_tools_version"],
341
Tao Baoeca59ae2018-07-30 20:45:27 -0700342 static_libs: [
343 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700344 ],
345
346 shared_libs: [
347 "libasyncio",
348 "libbase",
349 "libcrypto",
350 "libcrypto_utils",
351 "libcutils",
352 "liblog",
353 ],
Josh Gao776c2ec2019-01-22 19:36:15 -0800354
355 target: {
356 android: {
357 whole_static_libs: [
358 "libqemu_pipe",
359 ],
360 srcs: [
361 "daemon/transport_qemu.cpp",
362 "daemon/usb.cpp",
363 "daemon/usb_ffs.cpp",
364 "daemon/usb_legacy.cpp",
365 ]
366 },
367 linux_glibc: {
368 srcs: [
369 "daemon/usb_dummy.cpp",
370 ]
371 }
372 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700373}
374
375cc_library {
376 name: "libadbd_services",
Josh Gao776c2ec2019-01-22 19:36:15 -0800377 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700378 recovery_available: true,
379 compile_multilib: "both",
380
381 srcs: [
382 "daemon/file_sync_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700383 "daemon/services.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700384 "daemon/shell_service.cpp",
385 "shell_service_protocol.cpp",
386 ],
387
388 cflags: [
389 "-D_GNU_SOURCE",
390 "-Wno-deprecated-declarations",
391 ],
392
393 static_libs: [
394 "libadbd_core",
Tao Baoeca59ae2018-07-30 20:45:27 -0700395 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700396 ],
397
398 shared_libs: [
399 "libasyncio",
400 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700401 "libcrypto",
402 "libcrypto_utils",
403 "libcutils",
Tao Baoeca59ae2018-07-30 20:45:27 -0700404 "liblog",
Tao Baoeca59ae2018-07-30 20:45:27 -0700405 ],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800406
Mark Salyzyn2f6c1802019-02-15 07:45:26 -0800407 product_variables: {
408 debuggable: {
409 required: [
410 "remount",
411 ],
412 },
413 },
414
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800415 target: {
Josh Gao776c2ec2019-01-22 19:36:15 -0800416 android: {
417 srcs: [
418 "daemon/abb_service.cpp",
419 "daemon/framebuffer_service.cpp",
420 "daemon/mdns.cpp",
421 "daemon/reboot_service.cpp",
422 "daemon/remount_service.cpp",
423 "daemon/restart_service.cpp",
424 "daemon/set_verity_enable_state_service.cpp",
425 ],
426 static_libs: [
427 "libavb_user",
428 ],
429 shared_libs: [
430 "libbootloader_message",
431 "libmdnssd",
432 "libext4_utils",
433 "libfec",
434 "libfs_mgr",
435 "libselinux",
436 ],
437 },
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800438 recovery: {
439 exclude_srcs: [
440 "daemon/abb_service.cpp",
441 ],
442 },
443 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700444}
445
446cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800447 name: "libadbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800448 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900449 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800450
Tao Baoeca59ae2018-07-30 20:45:27 -0700451 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
452 use_version_lib: false,
453
454 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800455 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700456
457 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
458 whole_static_libs: [
459 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800460 ],
461
Tao Baoeca59ae2018-07-30 20:45:27 -0700462 shared_libs: [
463 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800464 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800465 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700466 "libcrypto",
467 "libcrypto_utils",
468 "libcutils",
469 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800470 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700471
472 export_include_dirs: [
473 "daemon/include",
474 ],
Josh Gao27768452018-01-02 12:01:43 -0800475}
476
477cc_binary {
478 name: "adbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800479 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900480 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800481
Josh Gao27768452018-01-02 12:01:43 -0800482 srcs: [
483 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800484 ],
485
486 cflags: [
487 "-D_GNU_SOURCE",
488 "-Wno-deprecated-declarations",
489 ],
490
491 strip: {
492 keep_symbols: true,
493 },
494
Tao Baoeca59ae2018-07-30 20:45:27 -0700495 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800496 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700497 "libadbd_services",
498 "libbase",
499 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800500 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700501 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800502 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800503 "libminijail",
504 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800505 ],
506}
507
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800508cc_binary {
509 name: "abb",
510
Josh Gao776c2ec2019-01-22 19:36:15 -0800511 defaults: ["adbd_defaults"],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800512 recovery_available: false,
513
514 srcs: [
515 "daemon/abb.cpp",
516 ],
517
518 cflags: [
519 "-D_GNU_SOURCE",
520 "-Wno-deprecated-declarations",
521 ],
522
523 strip: {
524 keep_symbols: true,
525 },
526
527 static_libs: [
528 "libadbd_core",
529 "libadbd_services",
530 "libcmd",
531 ],
532
533 shared_libs: [
534 "libbase",
535 "libbinder",
536 "liblog",
537 "libutils",
538 "libselinux",
539 ],
540}
541
Josh Gao27768452018-01-02 12:01:43 -0800542cc_test {
543 name: "adbd_test",
Josh Gao776c2ec2019-01-22 19:36:15 -0800544 defaults: ["adbd_defaults"],
Josh Gao27768452018-01-02 12:01:43 -0800545 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700546 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800547 "daemon/shell_service.cpp",
548 "daemon/shell_service_test.cpp",
549 "shell_service_protocol.cpp",
550 "shell_service_protocol_test.cpp",
551 ],
552
553 static_libs: [
554 "libadbd",
555 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700556 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800557 "libcutils",
558 "libcrypto_utils",
559 "libcrypto",
560 "libdiagnose_usb",
561 "liblog",
562 "libusb",
563 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900564 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800565 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700566 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800567}
568
Julien Desprez75fea7e2018-08-08 12:08:50 -0700569python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800570 name: "adb_integration_test_adb",
571 main: "test_adb.py",
572 srcs: [
573 "test_adb.py",
574 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700575 test_config: "adb_integration_test_adb.xml",
576 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800577 version: {
578 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700579 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800580 },
581 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700582 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800583 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700584 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700585}
586
Julien Desprez618f0e12018-10-12 13:48:14 -0700587python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800588 name: "adb_integration_test_device",
589 main: "test_device.py",
590 srcs: [
591 "test_device.py",
592 ],
593 libs: [
594 "adb_py",
595 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700596 test_config: "adb_integration_test_device.xml",
597 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800598 version: {
599 py2: {
600 enabled: true,
601 },
602 py3: {
603 enabled: false,
604 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700605 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700606}