blob: 1e085a7b3f21273daa632ccbd1aaf3f3ea0c4aa5 [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",
Josh Gao776c2ec2019-01-22 19:36:15 -080027 "-DADB_HOST=1", // overridden by adbd_defaults
Josh Gao27768452018-01-02 12:01:43 -080028 ],
Josh Gao6eb78822018-11-16 15:40:16 -080029 cpp_std: "experimental",
Josh Gao27768452018-01-02 12:01:43 -080030
Josh Gaoc7567fa2018-02-27 15:49:23 -080031 use_version_lib: true,
Josh Gao27768452018-01-02 12:01:43 -080032 compile_multilib: "first",
Josh Gao27768452018-01-02 12:01:43 -080033
34 target: {
Josh Gao27768452018-01-02 12:01:43 -080035 darwin: {
36 host_ldlibs: [
37 "-lpthread",
38 "-framework CoreFoundation",
39 "-framework IOKit",
40 "-lobjc",
41 ],
42 },
43
44 windows: {
45 cflags: [
46 // Define windows.h and tchar.h Unicode preprocessor symbols so that
47 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
48 // build if you accidentally pass char*. Fix by calling like:
49 // std::wstring path_wide;
50 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
51 // CreateFileW(path_wide.c_str());
52 "-DUNICODE=1",
53 "-D_UNICODE=1",
54
Elliott Hughes3c59cb82018-12-03 09:02:18 -080055 // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080056 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070057
58 // MinGW hides some things behind _POSIX_SOURCE.
59 "-D_POSIX_SOURCE",
Josh Gao776c2ec2019-01-22 19:36:15 -080060
61 // Not supported yet.
62 "-Wno-thread-safety",
Josh Gao27768452018-01-02 12:01:43 -080063 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070064
65 host_ldlibs: [
66 "-lws2_32",
67 "-lgdi32",
68 "-luserenv",
69 ],
Josh Gao27768452018-01-02 12:01:43 -080070 },
Josh Gao776c2ec2019-01-22 19:36:15 -080071 },
72}
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070073
Josh Gao776c2ec2019-01-22 19:36:15 -080074cc_defaults {
75 name: "adbd_defaults",
76 defaults: ["adb_defaults"],
77
78 cflags: ["-UADB_HOST", "-DADB_HOST=0"],
79 product_variables: {
80 debuggable: {
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070081 cflags: [
Josh Gao776c2ec2019-01-22 19:36:15 -080082 "-DALLOW_ADBD_ROOT",
83 "-DALLOW_ADBD_DISABLE_VERITY",
84 "-DALLOW_ADBD_NO_AUTH",
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070085 ],
86 },
Josh Gao27768452018-01-02 12:01:43 -080087 },
88}
89
Josh Gao776c2ec2019-01-22 19:36:15 -080090cc_defaults {
91 name: "host_adbd_supported",
92
93 host_supported: true,
94 target: {
95 linux: {
96 enabled: true,
97 host_ldlibs: [
98 "-lresolv", // b64_pton
99 "-lutil", // forkpty
100 ],
101 },
102 darwin: {
103 enabled: false,
104 },
105 windows: {
106 enabled: false,
107 },
108 },
109}
110
Josh Gao27768452018-01-02 12:01:43 -0800111// libadb
112// =========================================================
113// These files are compiled for both the host and the device.
114libadb_srcs = [
115 "adb.cpp",
116 "adb_io.cpp",
117 "adb_listeners.cpp",
118 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700119 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800120 "adb_utils.cpp",
121 "fdevent.cpp",
122 "services.cpp",
123 "sockets.cpp",
124 "socket_spec.cpp",
125 "sysdeps/errno.cpp",
126 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700127 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800128 "transport_local.cpp",
129 "transport_usb.cpp",
130]
131
132libadb_posix_srcs = [
133 "sysdeps_unix.cpp",
134 "sysdeps/posix/network.cpp",
135]
136
137libadb_test_srcs = [
138 "adb_io_test.cpp",
139 "adb_listeners_test.cpp",
140 "adb_utils_test.cpp",
141 "fdevent_test.cpp",
142 "socket_spec_test.cpp",
143 "socket_test.cpp",
144 "sysdeps_test.cpp",
145 "sysdeps/stat_test.cpp",
146 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700147 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800148]
149
150cc_library_host_static {
151 name: "libadb_host",
152 defaults: ["adb_defaults"],
153
154 srcs: libadb_srcs + [
155 "client/auth.cpp",
156 "client/usb_libusb.cpp",
157 "client/usb_dispatch.cpp",
158 "client/transport_mdns.cpp",
159 ],
160
Dan Willemsenab971b52018-08-29 14:58:02 -0700161 generated_headers: ["platform_tools_version"],
162
Josh Gao27768452018-01-02 12:01:43 -0800163 target: {
164 linux: {
165 srcs: ["client/usb_linux.cpp"],
166 },
167 darwin: {
168 srcs: ["client/usb_osx.cpp"],
169 },
170
171 not_windows: {
172 srcs: libadb_posix_srcs,
173 },
174 windows: {
175 enabled: true,
176 srcs: [
177 "client/usb_windows.cpp",
178 "sysdeps_win32.cpp",
179 "sysdeps/win32/errno.cpp",
180 "sysdeps/win32/stat.cpp",
181 ],
182 shared_libs: ["AdbWinApi"],
183 },
184 },
185
186 static_libs: [
187 "libbase",
188 "libcrypto_utils",
189 "libcrypto",
190 "libdiagnose_usb",
191 "libmdnssd",
192 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100193 "libutils",
194 "liblog",
195 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800196 ],
197}
198
199cc_test_host {
200 name: "adb_test",
201 defaults: ["adb_defaults"],
202 srcs: libadb_test_srcs,
203 static_libs: [
204 "libadb_host",
205 "libbase",
206 "libcutils",
207 "libcrypto_utils",
208 "libcrypto",
209 "libmdnssd",
210 "libdiagnose_usb",
211 "libusb",
212 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700213
214 target: {
215 windows: {
216 enabled: true,
217 shared_libs: ["AdbWinApi"],
218 },
219 },
Josh Gao27768452018-01-02 12:01:43 -0800220}
221
Josh Gao9c596492018-04-04 11:27:24 -0700222cc_benchmark {
223 name: "adb_benchmark",
224 defaults: ["adb_defaults"],
225
226 srcs: ["transport_benchmark.cpp"],
227 target: {
228 android: {
229 static_libs: [
230 "libadbd",
231 ],
232 },
233 host: {
234 static_libs: [
235 "libadb_host",
236 ],
237 },
238 },
239
240 static_libs: [
241 "libbase",
242 "libcutils",
243 "libcrypto_utils",
244 "libcrypto",
245 "libdiagnose_usb",
246 "liblog",
247 "libusb",
248 ],
249}
250
Josh Gao27768452018-01-02 12:01:43 -0800251cc_binary_host {
252 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800253
254 defaults: ["adb_defaults"],
255
256 srcs: [
257 "client/adb_client.cpp",
258 "client/bugreport.cpp",
259 "client/commandline.cpp",
260 "client/file_sync_client.cpp",
261 "client/main.cpp",
262 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000263 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800264 "client/line_printer.cpp",
265 "shell_service_protocol.cpp",
266 ],
267
268 static_libs: [
269 "libadb_host",
270 "libbase",
271 "libcutils",
272 "libcrypto_utils",
273 "libcrypto",
274 "libdiagnose_usb",
275 "liblog",
276 "libmdnssd",
277 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100278 "libutils",
279 "liblog",
280 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800281 ],
282
283 stl: "libc++_static",
284
285 // Don't add anything here, we don't want additional shared dependencies
286 // on the host adb tool, and shared libraries that link against libc++
287 // will violate ODR
288 shared_libs: [],
289
Idries Hamadi7575cd92018-08-24 11:46:45 +0100290 required: [
291 "deploypatchgenerator",
292 ],
293
Dan Willemsen3f439a72018-11-19 19:11:35 -0800294 // Archive adb, adb.exe.
295 dist: {
296 targets: [
297 "dist_files",
298 "sdk",
299 "win_sdk",
300 ],
301 },
302
Josh Gao27768452018-01-02 12:01:43 -0800303 target: {
304 darwin: {
305 cflags: [
306 "-Wno-sizeof-pointer-memaccess",
307 ],
308 },
309 windows: {
310 enabled: true,
311 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800312 shared_libs: ["AdbWinApi"],
313 required: [
314 "AdbWinUsbApi",
315 ],
316 },
317 },
318}
319
Tao Baoeca59ae2018-07-30 20:45:27 -0700320// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800321cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700322 name: "libadbd_core",
Josh Gao776c2ec2019-01-22 19:36:15 -0800323 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700324 recovery_available: true,
325
326 // libminadbd wants both, as it's used to build native tests.
327 compile_multilib: "both",
328
329 srcs: libadb_srcs + libadb_posix_srcs + [
330 "daemon/auth.cpp",
331 "daemon/jdwp_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700332 ],
333
334 local_include_dirs: [
335 "daemon/include",
336 ],
337
Dan Willemsenab971b52018-08-29 14:58:02 -0700338 generated_headers: ["platform_tools_version"],
339
Tao Baoeca59ae2018-07-30 20:45:27 -0700340 static_libs: [
341 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700342 ],
343
344 shared_libs: [
345 "libasyncio",
346 "libbase",
347 "libcrypto",
348 "libcrypto_utils",
349 "libcutils",
350 "liblog",
351 ],
Josh Gao776c2ec2019-01-22 19:36:15 -0800352
353 target: {
354 android: {
355 whole_static_libs: [
356 "libqemu_pipe",
357 ],
358 srcs: [
359 "daemon/transport_qemu.cpp",
360 "daemon/usb.cpp",
361 "daemon/usb_ffs.cpp",
362 "daemon/usb_legacy.cpp",
363 ]
364 },
365 linux_glibc: {
366 srcs: [
367 "daemon/usb_dummy.cpp",
368 ]
369 }
370 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700371}
372
373cc_library {
374 name: "libadbd_services",
Josh Gao776c2ec2019-01-22 19:36:15 -0800375 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700376 recovery_available: true,
377 compile_multilib: "both",
378
379 srcs: [
380 "daemon/file_sync_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700381 "daemon/services.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700382 "daemon/shell_service.cpp",
383 "shell_service_protocol.cpp",
384 ],
385
386 cflags: [
387 "-D_GNU_SOURCE",
388 "-Wno-deprecated-declarations",
389 ],
390
391 static_libs: [
392 "libadbd_core",
Tao Baoeca59ae2018-07-30 20:45:27 -0700393 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700394 ],
395
396 shared_libs: [
397 "libasyncio",
398 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700399 "libcrypto",
400 "libcrypto_utils",
401 "libcutils",
Tao Baoeca59ae2018-07-30 20:45:27 -0700402 "liblog",
Tao Baoeca59ae2018-07-30 20:45:27 -0700403 ],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800404
Mark Salyzyn2f6c1802019-02-15 07:45:26 -0800405 product_variables: {
406 debuggable: {
407 required: [
408 "remount",
409 ],
410 },
411 },
412
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800413 target: {
Josh Gao776c2ec2019-01-22 19:36:15 -0800414 android: {
415 srcs: [
416 "daemon/abb_service.cpp",
417 "daemon/framebuffer_service.cpp",
418 "daemon/mdns.cpp",
419 "daemon/reboot_service.cpp",
420 "daemon/remount_service.cpp",
421 "daemon/restart_service.cpp",
422 "daemon/set_verity_enable_state_service.cpp",
423 ],
424 static_libs: [
425 "libavb_user",
426 ],
427 shared_libs: [
428 "libbootloader_message",
429 "libmdnssd",
430 "libext4_utils",
431 "libfec",
432 "libfs_mgr",
433 "libselinux",
434 ],
435 },
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800436 recovery: {
437 exclude_srcs: [
438 "daemon/abb_service.cpp",
439 ],
440 },
441 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700442}
443
444cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800445 name: "libadbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800446 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900447 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800448
Tao Baoeca59ae2018-07-30 20:45:27 -0700449 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
450 use_version_lib: false,
451
452 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800453 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700454
455 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
456 whole_static_libs: [
457 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800458 ],
459
Tao Baoeca59ae2018-07-30 20:45:27 -0700460 shared_libs: [
461 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800462 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800463 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700464 "libcrypto",
465 "libcrypto_utils",
466 "libcutils",
467 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800468 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700469
470 export_include_dirs: [
471 "daemon/include",
472 ],
Josh Gao27768452018-01-02 12:01:43 -0800473}
474
475cc_binary {
476 name: "adbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800477 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900478 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800479
Josh Gao27768452018-01-02 12:01:43 -0800480 srcs: [
481 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800482 ],
483
484 cflags: [
485 "-D_GNU_SOURCE",
486 "-Wno-deprecated-declarations",
487 ],
488
489 strip: {
490 keep_symbols: true,
491 },
492
Tao Baoeca59ae2018-07-30 20:45:27 -0700493 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800494 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700495 "libadbd_services",
496 "libbase",
497 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800498 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700499 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800500 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800501 "libminijail",
502 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800503 ],
504}
505
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800506cc_binary {
507 name: "abb",
508
Josh Gao776c2ec2019-01-22 19:36:15 -0800509 defaults: ["adbd_defaults"],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800510 recovery_available: false,
511
512 srcs: [
513 "daemon/abb.cpp",
514 ],
515
516 cflags: [
517 "-D_GNU_SOURCE",
518 "-Wno-deprecated-declarations",
519 ],
520
521 strip: {
522 keep_symbols: true,
523 },
524
525 static_libs: [
526 "libadbd_core",
527 "libadbd_services",
528 "libcmd",
529 ],
530
531 shared_libs: [
532 "libbase",
533 "libbinder",
534 "liblog",
535 "libutils",
536 "libselinux",
537 ],
538}
539
Josh Gao27768452018-01-02 12:01:43 -0800540cc_test {
541 name: "adbd_test",
Josh Gao776c2ec2019-01-22 19:36:15 -0800542 defaults: ["adbd_defaults"],
Josh Gao27768452018-01-02 12:01:43 -0800543 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700544 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800545 "daemon/shell_service.cpp",
546 "daemon/shell_service_test.cpp",
547 "shell_service_protocol.cpp",
548 "shell_service_protocol_test.cpp",
549 ],
550
551 static_libs: [
552 "libadbd",
553 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700554 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800555 "libcutils",
556 "libcrypto_utils",
557 "libcrypto",
558 "libdiagnose_usb",
559 "liblog",
560 "libusb",
561 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900562 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800563 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700564 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800565}
566
Julien Desprez75fea7e2018-08-08 12:08:50 -0700567python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800568 name: "adb_integration_test_adb",
569 main: "test_adb.py",
570 srcs: [
571 "test_adb.py",
572 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700573 test_config: "adb_integration_test_adb.xml",
574 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800575 version: {
576 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700577 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800578 },
579 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700580 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800581 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700582 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700583}
584
Julien Desprez618f0e12018-10-12 13:48:14 -0700585python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800586 name: "adb_integration_test_device",
587 main: "test_device.py",
588 srcs: [
589 "test_device.py",
590 ],
591 libs: [
592 "adb_py",
593 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700594 test_config: "adb_integration_test_device.xml",
595 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800596 version: {
597 py2: {
598 enabled: true,
599 },
600 py3: {
601 enabled: false,
602 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700603 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700604}