1// 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 15cc_defaults { 16 name: "adb_defaults", 17 18 cflags: [ 19 "-Wall", 20 "-Wextra", 21 "-Werror", 22 "-Wexit-time-destructors", 23 "-Wno-unused-parameter", 24 "-Wno-missing-field-initializers", 25 "-Wthread-safety", 26 "-Wvla", 27 "-DADB_HOST=1", // overridden by adbd_defaults 28 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION=1", 29 ], 30 cpp_std: "experimental", 31 32 use_version_lib: true, 33 compile_multilib: "first", 34 35 target: { 36 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 56 // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows. 57 "-D_GNU_SOURCE", 58 59 // MinGW hides some things behind _POSIX_SOURCE. 60 "-D_POSIX_SOURCE", 61 62 // libusb uses __stdcall on a variadic function, which gets ignored. 63 "-Wno-ignored-attributes", 64 65 // Not supported yet. 66 "-Wno-thread-safety", 67 ], 68 69 host_ldlibs: [ 70 "-lws2_32", 71 "-lgdi32", 72 "-luserenv", 73 ], 74 }, 75 }, 76} 77 78cc_defaults { 79 name: "adbd_defaults", 80 defaults: ["adb_defaults"], 81 82 cflags: ["-UADB_HOST", "-DADB_HOST=0"], 83} 84 85cc_defaults { 86 name: "host_adbd_supported", 87 88 host_supported: true, 89 target: { 90 linux: { 91 enabled: true, 92 host_ldlibs: [ 93 "-lresolv", // b64_pton 94 "-lutil", // forkpty 95 ], 96 }, 97 darwin: { 98 enabled: false, 99 }, 100 windows: { 101 enabled: false, 102 }, 103 }, 104} 105 106cc_defaults { 107 name: "libadbd_binary_dependencies", 108 static_libs: [ 109 "libadb_crypto", 110 "libadb_pairing_connection", 111 "libadb_tls_connection", 112 "libadbd", 113 "libadbd_core", 114 "libadbconnection_server", 115 "libasyncio", 116 "libbrotli", 117 "libcutils_sockets", 118 "libdiagnose_usb", 119 "libmdnssd", 120 "libbase", 121 122 "libadb_protos", 123 ], 124 125 shared_libs: [ 126 "libadbd_auth", 127 "libadbd_fs", 128 "libcrypto", 129 "libcrypto_utils", 130 "liblog", 131 "libselinux", 132 ], 133 134 target: { 135 recovery: { 136 exclude_static_libs: [ 137 "libadb_pairing_auth", 138 "libadb_pairing_connection", 139 ], 140 }, 141 }, 142} 143 144// libadb 145// ========================================================= 146// These files are compiled for both the host and the device. 147libadb_srcs = [ 148 "adb.cpp", 149 "adb_io.cpp", 150 "adb_listeners.cpp", 151 "adb_trace.cpp", 152 "adb_unique_fd.cpp", 153 "adb_utils.cpp", 154 "fdevent/fdevent.cpp", 155 "fdevent/fdevent_poll.cpp", 156 "services.cpp", 157 "sockets.cpp", 158 "socket_spec.cpp", 159 "sysdeps/errno.cpp", 160 "transport.cpp", 161 "transport_fd.cpp", 162 "transport_local.cpp", 163 "types.cpp", 164] 165 166libadb_posix_srcs = [ 167 "sysdeps_unix.cpp", 168 "sysdeps/posix/network.cpp", 169] 170 171libadb_linux_srcs = [ 172 "fdevent/fdevent_epoll.cpp", 173] 174 175libadb_test_srcs = [ 176 "adb_io_test.cpp", 177 "adb_listeners_test.cpp", 178 "adb_utils_test.cpp", 179 "fdevent/fdevent_test.cpp", 180 "socket_spec_test.cpp", 181 "socket_test.cpp", 182 "sysdeps_test.cpp", 183 "sysdeps/stat_test.cpp", 184 "transport_test.cpp", 185 "types_test.cpp", 186] 187 188cc_library_host_static { 189 name: "libadb_host", 190 defaults: ["adb_defaults"], 191 192 srcs: libadb_srcs + [ 193 "client/auth.cpp", 194 "client/adb_wifi.cpp", 195 "client/usb_libusb.cpp", 196 "client/usb_dispatch.cpp", 197 "client/transport_mdns.cpp", 198 "client/transport_usb.cpp", 199 "client/pairing/pairing_client.cpp", 200 ], 201 202 generated_headers: ["platform_tools_version"], 203 204 target: { 205 linux: { 206 srcs: ["client/usb_linux.cpp"] + libadb_linux_srcs, 207 }, 208 darwin: { 209 srcs: ["client/usb_osx.cpp"], 210 }, 211 not_windows: { 212 srcs: libadb_posix_srcs, 213 }, 214 windows: { 215 enabled: true, 216 srcs: [ 217 "client/usb_windows.cpp", 218 "sysdeps_win32.cpp", 219 "sysdeps/win32/errno.cpp", 220 "sysdeps/win32/stat.cpp", 221 ], 222 shared_libs: ["AdbWinApi"], 223 }, 224 }, 225 226 static_libs: [ 227 "libadb_crypto", 228 "libadb_protos", 229 "libadb_pairing_connection", 230 "libadb_tls_connection", 231 "libbase", 232 "libcrypto_utils", 233 "libcrypto", 234 "libdiagnose_usb", 235 "libmdnssd", 236 "libusb", 237 "libutils", 238 "liblog", 239 "libcutils", 240 "libprotobuf-cpp-lite", 241 ], 242} 243 244cc_test_host { 245 name: "adb_test", 246 defaults: ["adb_defaults"], 247 srcs: libadb_test_srcs, 248 static_libs: [ 249 "libadb_crypto_static", 250 "libadb_host", 251 "libadb_pairing_auth_static", 252 "libadb_pairing_connection_static", 253 "libadb_protos_static", 254 "libadb_tls_connection_static", 255 "libbase", 256 "libcutils", 257 "libcrypto_utils", 258 "libcrypto", 259 "liblog", 260 "libmdnssd", 261 "libdiagnose_usb", 262 "libprotobuf-cpp-lite", 263 "libssl", 264 "libusb", 265 ], 266 267 target: { 268 windows: { 269 enabled: true, 270 ldflags: ["-municode"], 271 shared_libs: ["AdbWinApi"], 272 }, 273 }, 274} 275 276cc_binary_host { 277 name: "adb", 278 279 stl: "libc++_static", 280 defaults: ["adb_defaults"], 281 282 srcs: [ 283 "client/adb_client.cpp", 284 "client/bugreport.cpp", 285 "client/commandline.cpp", 286 "client/file_sync_client.cpp", 287 "client/main.cpp", 288 "client/console.cpp", 289 "client/adb_install.cpp", 290 "client/line_printer.cpp", 291 "client/fastdeploy.cpp", 292 "client/fastdeploycallbacks.cpp", 293 "client/incremental.cpp", 294 "client/incremental_server.cpp", 295 "client/incremental_utils.cpp", 296 "shell_service_protocol.cpp", 297 ], 298 299 generated_headers: [ 300 "bin2c_fastdeployagent", 301 "bin2c_fastdeployagentscript" 302 ], 303 304 static_libs: [ 305 "libadb_crypto", 306 "libadb_host", 307 "libadb_pairing_auth", 308 "libadb_pairing_connection", 309 "libadb_protos", 310 "libadb_tls_connection", 311 "libandroidfw", 312 "libbase", 313 "libbrotli", 314 "libcutils", 315 "libcrypto_utils", 316 "libcrypto", 317 "libfastdeploy_host", 318 "libdiagnose_usb", 319 "liblog", 320 "liblz4", 321 "libmdnssd", 322 "libprotobuf-cpp-lite", 323 "libssl", 324 "libusb", 325 "libutils", 326 "liblog", 327 "libziparchive", 328 "libz", 329 ], 330 331 // Don't add anything here, we don't want additional shared dependencies 332 // on the host adb tool, and shared libraries that link against libc++ 333 // will violate ODR 334 shared_libs: [], 335 336 // Archive adb, adb.exe. 337 dist: { 338 targets: [ 339 "dist_files", 340 "sdk", 341 "win_sdk", 342 ], 343 }, 344 345 target: { 346 darwin: { 347 cflags: [ 348 "-Wno-sizeof-pointer-memaccess", 349 ], 350 }, 351 windows: { 352 enabled: true, 353 ldflags: ["-municode"], 354 shared_libs: ["AdbWinApi"], 355 required: [ 356 "AdbWinUsbApi", 357 ], 358 }, 359 }, 360} 361 362// libadbd_core contains the common sources to build libadbd and libadbd_services. 363cc_library_static { 364 name: "libadbd_core", 365 defaults: ["adbd_defaults", "host_adbd_supported"], 366 recovery_available: true, 367 368 // libminadbd wants both, as it's used to build native tests. 369 compile_multilib: "both", 370 371 srcs: libadb_srcs + libadb_linux_srcs + libadb_posix_srcs + [ 372 "daemon/auth.cpp", 373 "daemon/jdwp_service.cpp", 374 "daemon/logging.cpp", 375 "daemon/adb_wifi.cpp", 376 ], 377 378 generated_headers: ["platform_tools_version"], 379 380 static_libs: [ 381 "libadbconnection_server", 382 "libdiagnose_usb", 383 ], 384 385 shared_libs: [ 386 "libadb_crypto", 387 "libadb_pairing_connection", 388 "libadb_protos", 389 "libadb_tls_connection", 390 "libadbd_auth", 391 "libasyncio", 392 "libbase", 393 "libcrypto", 394 "libcrypto_utils", 395 "libcutils_sockets", 396 "liblog", 397 ], 398 399 target: { 400 android: { 401 whole_static_libs: [ 402 "libqemu_pipe", 403 ], 404 srcs: [ 405 "daemon/transport_qemu.cpp", 406 "daemon/usb.cpp", 407 "daemon/usb_ffs.cpp", 408 ] 409 }, 410 recovery: { 411 exclude_shared_libs: [ 412 "libadb_pairing_auth", 413 "libadb_pairing_connection", 414 ], 415 } 416 }, 417 418 apex_available: [ 419 "//apex_available:platform", 420 "com.android.adbd", 421 ], 422 visibility: [ 423 "//bootable/recovery/minadbd", 424 "//system/core/adb", 425 ], 426} 427 428cc_library { 429 name: "libadbd_services", 430 defaults: ["adbd_defaults", "host_adbd_supported"], 431 recovery_available: true, 432 compile_multilib: "both", 433 434 srcs: [ 435 "daemon/file_sync_service.cpp", 436 "daemon/services.cpp", 437 "daemon/shell_service.cpp", 438 "shell_service_protocol.cpp", 439 ], 440 441 cflags: [ 442 "-D_GNU_SOURCE", 443 "-Wno-deprecated-declarations", 444 ], 445 446 static_libs: [ 447 "libadbconnection_server", 448 "libadbd_core", 449 "libbrotli", 450 "libdiagnose_usb", 451 ], 452 453 shared_libs: [ 454 "libadb_crypto", 455 "libadb_pairing_connection", 456 "libadb_protos", 457 "libadb_tls_connection", 458 "libasyncio", 459 "libbase", 460 "libcrypto_utils", 461 "libcutils_sockets", 462 463 // APEX dependencies. 464 "libadbd_auth", 465 "libadbd_fs", 466 "libcrypto", 467 "liblog", 468 ], 469 470 target: { 471 android: { 472 srcs: [ 473 "daemon/abb_service.cpp", 474 "daemon/framebuffer_service.cpp", 475 "daemon/mdns.cpp", 476 "daemon/restart_service.cpp", 477 ], 478 shared_libs: [ 479 "libmdnssd", 480 "libselinux", 481 ], 482 }, 483 recovery: { 484 exclude_srcs: [ 485 "daemon/abb_service.cpp", 486 ], 487 exclude_shared_libs: [ 488 "libadb_pairing_auth", 489 "libadb_pairing_connection", 490 ], 491 }, 492 }, 493 494 apex_available: [ 495 "//apex_available:platform", 496 "com.android.adbd", 497 ], 498 visibility: [ 499 "//system/core/adb", 500 ], 501 502} 503 504cc_library { 505 name: "libadbd", 506 defaults: ["adbd_defaults", "host_adbd_supported"], 507 recovery_available: true, 508 apex_available: ["com.android.adbd"], 509 510 // avoid getting duplicate symbol of android::build::getbuildnumber(). 511 use_version_lib: false, 512 513 // libminadbd wants both, as it's used to build native tests. 514 compile_multilib: "both", 515 516 shared_libs: [ 517 "libadb_crypto", 518 "libadb_pairing_connection", 519 "libadb_tls_connection", 520 "libasyncio", 521 "libbase", 522 "libcrypto", 523 "libcrypto_utils", 524 "liblog", 525 "libselinux", 526 527 // APEX dependencies on the system image. 528 "libadbd_auth", 529 "libadbd_fs", 530 "libadbd_services", 531 ], 532 533 target: { 534 recovery: { 535 exclude_shared_libs: [ 536 "libadb_pairing_auth", 537 "libadb_pairing_connection", 538 ], 539 } 540 }, 541 542 static_libs: [ 543 "libadbd_core", 544 "libbrotli", 545 "libcutils_sockets", 546 "libdiagnose_usb", 547 "libmdnssd", 548 ], 549 550 visibility: [ 551 "//bootable/recovery/minadbd", 552 "//system/core/adb", 553 ], 554} 555 556cc_binary { 557 name: "adbd", 558 defaults: ["adbd_defaults", "host_adbd_supported", "libadbd_binary_dependencies"], 559 recovery_available: true, 560 apex_available: ["com.android.adbd"], 561 562 srcs: [ 563 "daemon/main.cpp", 564 ], 565 566 cflags: [ 567 "-D_GNU_SOURCE", 568 "-Wno-deprecated-declarations", 569 ], 570 571 strip: { 572 keep_symbols: true, 573 }, 574 575 static_libs: [ 576 "libadbd", 577 "libadbd_services", 578 "libasyncio", 579 "libcap", 580 "libminijail", 581 "libssl", 582 ], 583 584 shared_libs: [ 585 "libadb_protos", 586 "libadbd_auth", 587 ], 588 589 target: { 590 recovery: { 591 exclude_shared_libs: [ 592 "libadb_pairing_auth", 593 "libadb_pairing_connection", 594 ], 595 } 596 }, 597} 598 599phony { 600 // Interface between adbd in a module and the system. 601 name: "adbd_system_api", 602 required: [ 603 "libadbd_auth", 604 "libadbd_fs", 605 "abb", 606 "reboot", 607 "set-verity-state", 608 ] 609} 610 611phony { 612 name: "adbd_system_api_recovery", 613 required: [ 614 "libadbd_auth", 615 "libadbd_fs", 616 "reboot.recovery", 617 ], 618} 619 620cc_binary { 621 name: "abb", 622 623 defaults: ["adbd_defaults"], 624 stl: "libc++", 625 recovery_available: false, 626 627 srcs: [ 628 "daemon/abb.cpp", 629 ], 630 631 cflags: [ 632 "-D_GNU_SOURCE", 633 "-Wno-deprecated-declarations", 634 ], 635 636 strip: { 637 keep_symbols: true, 638 }, 639 640 static_libs: [ 641 "libadbd_core", 642 "libadbd_services", 643 "libcmd", 644 ], 645 646 shared_libs: [ 647 "libbase", 648 "libbinder", 649 "liblog", 650 "libutils", 651 "libselinux", 652 ], 653} 654 655cc_test { 656 name: "adbd_test", 657 658 defaults: ["adbd_defaults", "libadbd_binary_dependencies"], 659 660 recovery_available: false, 661 srcs: libadb_test_srcs + [ 662 "daemon/services.cpp", 663 "daemon/shell_service.cpp", 664 "daemon/shell_service_test.cpp", 665 "shell_service_protocol.cpp", 666 "shell_service_protocol_test.cpp", 667 "mdns_test.cpp", 668 ], 669 670 test_config: "adb_test.xml", 671 672 shared_libs: [ 673 "liblog", 674 ], 675 676 static_libs: [ 677 "libadbd", 678 "libadbd_auth", 679 "libbase", 680 "libcrypto_utils", 681 "libusb", 682 ], 683 test_suites: ["device-tests", "mts"], 684 require_root: true, 685} 686 687python_test_host { 688 name: "adb_integration_test_adb", 689 main: "test_adb.py", 690 srcs: [ 691 "test_adb.py", 692 ], 693 test_config: "adb_integration_test_adb.xml", 694 test_suites: ["general-tests"], 695 version: { 696 py2: { 697 enabled: false, 698 }, 699 py3: { 700 enabled: true, 701 }, 702 }, 703} 704 705python_test_host { 706 name: "adb_integration_test_device", 707 main: "test_device.py", 708 srcs: [ 709 "test_device.py", 710 ], 711 libs: [ 712 "adb_py", 713 ], 714 test_config: "adb_integration_test_device.xml", 715 test_suites: ["general-tests"], 716 version: { 717 py2: { 718 enabled: false, 719 }, 720 py3: { 721 enabled: true, 722 }, 723 }, 724} 725 726// Note: using pipe for xxd to control the variable name generated 727// the default name used by xxd is the path to the input file. 728java_genrule { 729 name: "bin2c_fastdeployagent", 730 out: ["deployagent.inc"], 731 srcs: [":deployagent"], 732 cmd: "(echo 'unsigned char kDeployAgent[] = {' && xxd -i <$(in) && echo '};') > $(out)", 733} 734 735genrule { 736 name: "bin2c_fastdeployagentscript", 737 out: ["deployagentscript.inc"], 738 srcs: ["fastdeploy/deployagent/deployagent.sh"], 739 cmd: "(echo 'unsigned char kDeployAgentScript[] = {' && xxd -i <$(in) && echo '};') > $(out)", 740} 741 742cc_library_host_static { 743 name: "libfastdeploy_host", 744 defaults: ["adb_defaults"], 745 srcs: [ 746 "fastdeploy/deploypatchgenerator/apk_archive.cpp", 747 "fastdeploy/deploypatchgenerator/deploy_patch_generator.cpp", 748 "fastdeploy/deploypatchgenerator/patch_utils.cpp", 749 "fastdeploy/proto/ApkEntry.proto", 750 ], 751 static_libs: [ 752 "libadb_host", 753 "libandroidfw", 754 "libbase", 755 "libcutils", 756 "libcrypto_utils", 757 "libcrypto", 758 "libdiagnose_usb", 759 "liblog", 760 "libmdnssd", 761 "libusb", 762 "libutils", 763 "libziparchive", 764 "libz", 765 ], 766 proto: { 767 type: "lite", 768 export_proto_headers: true, 769 }, 770 target: { 771 windows: { 772 enabled: true, 773 shared_libs: ["AdbWinApi"], 774 }, 775 }, 776} 777 778cc_test_host { 779 name: "fastdeploy_test", 780 defaults: ["adb_defaults"], 781 srcs: [ 782 "fastdeploy/deploypatchgenerator/apk_archive_test.cpp", 783 "fastdeploy/deploypatchgenerator/deploy_patch_generator_test.cpp", 784 "fastdeploy/deploypatchgenerator/patch_utils_test.cpp", 785 ], 786 static_libs: [ 787 "libadb_crypto_static", 788 "libadb_host", 789 "libadb_pairing_auth_static", 790 "libadb_pairing_connection_static", 791 "libadb_protos_static", 792 "libadb_tls_connection_static", 793 "libandroidfw", 794 "libbase", 795 "libcutils", 796 "libcrypto_utils", 797 "libcrypto", 798 "libdiagnose_usb", 799 "libfastdeploy_host", 800 "liblog", 801 "libmdnssd", 802 "libprotobuf-cpp-lite", 803 "libssl", 804 "libusb", 805 "libutils", 806 "libziparchive", 807 "libz", 808 ], 809 target: { 810 windows: { 811 enabled: true, 812 shared_libs: ["AdbWinApi"], 813 }, 814 }, 815 data: [ 816 "fastdeploy/testdata/rotating_cube-metadata-release.data", 817 "fastdeploy/testdata/rotating_cube-release.apk", 818 "fastdeploy/testdata/sample.apk", 819 "fastdeploy/testdata/sample.cd", 820 ], 821} 822