Android.bp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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. cc_defaults {
  15. name: "adb_defaults",
  16. cflags: [
  17. "-Wall",
  18. "-Wextra",
  19. "-Werror",
  20. "-Wexit-time-destructors",
  21. "-Wno-unused-parameter",
  22. "-Wno-missing-field-initializers",
  23. "-Wthread-safety",
  24. "-Wvla",
  25. "-DADB_HOST=1", // overridden by adbd_defaults
  26. "-DALLOW_ADBD_ROOT=0", // overridden by adbd_defaults
  27. ],
  28. cpp_std: "experimental",
  29. use_version_lib: true,
  30. compile_multilib: "first",
  31. target: {
  32. darwin: {
  33. host_ldlibs: [
  34. "-lpthread",
  35. "-framework CoreFoundation",
  36. "-framework IOKit",
  37. "-lobjc",
  38. ],
  39. },
  40. windows: {
  41. cflags: [
  42. // Define windows.h and tchar.h Unicode preprocessor symbols so that
  43. // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
  44. // build if you accidentally pass char*. Fix by calling like:
  45. // std::wstring path_wide;
  46. // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
  47. // CreateFileW(path_wide.c_str());
  48. "-DUNICODE=1",
  49. "-D_UNICODE=1",
  50. // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows.
  51. "-D_GNU_SOURCE",
  52. // MinGW hides some things behind _POSIX_SOURCE.
  53. "-D_POSIX_SOURCE",
  54. // Not supported yet.
  55. "-Wno-thread-safety",
  56. ],
  57. host_ldlibs: [
  58. "-lws2_32",
  59. "-lgdi32",
  60. "-luserenv",
  61. ],
  62. },
  63. },
  64. }
  65. cc_defaults {
  66. name: "adbd_defaults",
  67. defaults: ["adb_defaults"],
  68. cflags: ["-UADB_HOST", "-DADB_HOST=0"],
  69. product_variables: {
  70. debuggable: {
  71. cflags: [
  72. "-UALLOW_ADBD_ROOT",
  73. "-DALLOW_ADBD_ROOT=1",
  74. "-DALLOW_ADBD_DISABLE_VERITY",
  75. "-DALLOW_ADBD_NO_AUTH",
  76. ],
  77. },
  78. },
  79. }
  80. cc_defaults {
  81. name: "host_adbd_supported",
  82. host_supported: true,
  83. target: {
  84. linux: {
  85. enabled: true,
  86. host_ldlibs: [
  87. "-lresolv", // b64_pton
  88. "-lutil", // forkpty
  89. ],
  90. },
  91. darwin: {
  92. enabled: false,
  93. },
  94. windows: {
  95. enabled: false,
  96. },
  97. },
  98. }
  99. // libadb
  100. // =========================================================
  101. // These files are compiled for both the host and the device.
  102. libadb_srcs = [
  103. "adb.cpp",
  104. "adb_io.cpp",
  105. "adb_listeners.cpp",
  106. "adb_trace.cpp",
  107. "adb_unique_fd.cpp",
  108. "adb_utils.cpp",
  109. "fdevent.cpp",
  110. "services.cpp",
  111. "sockets.cpp",
  112. "socket_spec.cpp",
  113. "sysdeps/errno.cpp",
  114. "transport.cpp",
  115. "transport_fd.cpp",
  116. "transport_local.cpp",
  117. "transport_usb.cpp",
  118. ]
  119. libadb_posix_srcs = [
  120. "sysdeps_unix.cpp",
  121. "sysdeps/posix/network.cpp",
  122. ]
  123. libadb_test_srcs = [
  124. "adb_io_test.cpp",
  125. "adb_listeners_test.cpp",
  126. "adb_utils_test.cpp",
  127. "fdevent_test.cpp",
  128. "socket_spec_test.cpp",
  129. "socket_test.cpp",
  130. "sysdeps_test.cpp",
  131. "sysdeps/stat_test.cpp",
  132. "transport_test.cpp",
  133. "types_test.cpp",
  134. ]
  135. cc_library_host_static {
  136. name: "libadb_host",
  137. defaults: ["adb_defaults"],
  138. srcs: libadb_srcs + [
  139. "client/auth.cpp",
  140. "client/usb_libusb.cpp",
  141. "client/usb_dispatch.cpp",
  142. "client/transport_mdns.cpp",
  143. ],
  144. generated_headers: ["platform_tools_version"],
  145. target: {
  146. linux: {
  147. srcs: ["client/usb_linux.cpp"],
  148. },
  149. darwin: {
  150. srcs: ["client/usb_osx.cpp"],
  151. },
  152. not_windows: {
  153. srcs: libadb_posix_srcs,
  154. },
  155. windows: {
  156. enabled: true,
  157. srcs: [
  158. "client/usb_windows.cpp",
  159. "sysdeps_win32.cpp",
  160. "sysdeps/win32/errno.cpp",
  161. "sysdeps/win32/stat.cpp",
  162. ],
  163. shared_libs: ["AdbWinApi"],
  164. },
  165. },
  166. static_libs: [
  167. "libbase",
  168. "libcrypto_utils",
  169. "libcrypto",
  170. "libdiagnose_usb",
  171. "libmdnssd",
  172. "libusb",
  173. "libutils",
  174. "liblog",
  175. "libcutils",
  176. ],
  177. }
  178. cc_test_host {
  179. name: "adb_test",
  180. defaults: ["adb_defaults"],
  181. srcs: libadb_test_srcs,
  182. static_libs: [
  183. "libadb_host",
  184. "libbase",
  185. "libcutils",
  186. "libcrypto_utils",
  187. "libcrypto",
  188. "libmdnssd",
  189. "libdiagnose_usb",
  190. "libusb",
  191. ],
  192. target: {
  193. windows: {
  194. enabled: true,
  195. shared_libs: ["AdbWinApi"],
  196. },
  197. },
  198. }
  199. cc_benchmark {
  200. name: "adb_benchmark",
  201. defaults: ["adb_defaults"],
  202. srcs: ["transport_benchmark.cpp"],
  203. target: {
  204. android: {
  205. static_libs: [
  206. "libadbd",
  207. ],
  208. },
  209. host: {
  210. static_libs: [
  211. "libadb_host",
  212. ],
  213. },
  214. },
  215. static_libs: [
  216. "libbase",
  217. "libcutils",
  218. "libcrypto_utils",
  219. "libcrypto",
  220. "libdiagnose_usb",
  221. "liblog",
  222. "libusb",
  223. ],
  224. }
  225. cc_binary_host {
  226. name: "adb",
  227. defaults: ["adb_defaults"],
  228. srcs: [
  229. "client/adb_client.cpp",
  230. "client/bugreport.cpp",
  231. "client/commandline.cpp",
  232. "client/file_sync_client.cpp",
  233. "client/main.cpp",
  234. "client/console.cpp",
  235. "client/adb_install.cpp",
  236. "client/line_printer.cpp",
  237. "shell_service_protocol.cpp",
  238. ],
  239. static_libs: [
  240. "libadb_host",
  241. "libbase",
  242. "libcutils",
  243. "libcrypto_utils",
  244. "libcrypto",
  245. "libdiagnose_usb",
  246. "liblog",
  247. "libmdnssd",
  248. "libusb",
  249. "libutils",
  250. "liblog",
  251. "libcutils",
  252. ],
  253. stl: "libc++_static",
  254. // Don't add anything here, we don't want additional shared dependencies
  255. // on the host adb tool, and shared libraries that link against libc++
  256. // will violate ODR
  257. shared_libs: [],
  258. required: [
  259. "deploypatchgenerator",
  260. ],
  261. // Archive adb, adb.exe.
  262. dist: {
  263. targets: [
  264. "dist_files",
  265. "sdk",
  266. "win_sdk",
  267. ],
  268. },
  269. target: {
  270. darwin: {
  271. cflags: [
  272. "-Wno-sizeof-pointer-memaccess",
  273. ],
  274. },
  275. windows: {
  276. enabled: true,
  277. ldflags: ["-municode"],
  278. shared_libs: ["AdbWinApi"],
  279. required: [
  280. "AdbWinUsbApi",
  281. ],
  282. },
  283. },
  284. }
  285. // libadbd_core contains the common sources to build libadbd and libadbd_services.
  286. cc_library_static {
  287. name: "libadbd_core",
  288. defaults: ["adbd_defaults", "host_adbd_supported"],
  289. recovery_available: true,
  290. // libminadbd wants both, as it's used to build native tests.
  291. compile_multilib: "both",
  292. srcs: libadb_srcs + libadb_posix_srcs + [
  293. "daemon/auth.cpp",
  294. "daemon/jdwp_service.cpp",
  295. ],
  296. local_include_dirs: [
  297. "daemon/include",
  298. ],
  299. generated_headers: ["platform_tools_version"],
  300. static_libs: [
  301. "libdiagnose_usb",
  302. ],
  303. shared_libs: [
  304. "libasyncio",
  305. "libbase",
  306. "libcrypto",
  307. "libcrypto_utils",
  308. "libcutils",
  309. "liblog",
  310. ],
  311. target: {
  312. android: {
  313. whole_static_libs: [
  314. "libqemu_pipe",
  315. ],
  316. srcs: [
  317. "daemon/transport_qemu.cpp",
  318. "daemon/usb.cpp",
  319. "daemon/usb_ffs.cpp",
  320. "daemon/usb_legacy.cpp",
  321. ]
  322. },
  323. linux_glibc: {
  324. srcs: [
  325. "daemon/usb_dummy.cpp",
  326. ]
  327. }
  328. },
  329. }
  330. cc_library {
  331. name: "libadbd_services",
  332. defaults: ["adbd_defaults", "host_adbd_supported"],
  333. recovery_available: true,
  334. compile_multilib: "both",
  335. srcs: [
  336. "daemon/file_sync_service.cpp",
  337. "daemon/services.cpp",
  338. "daemon/shell_service.cpp",
  339. "shell_service_protocol.cpp",
  340. ],
  341. cflags: [
  342. "-D_GNU_SOURCE",
  343. "-Wno-deprecated-declarations",
  344. ],
  345. static_libs: [
  346. "libadbd_core",
  347. "libdiagnose_usb",
  348. ],
  349. shared_libs: [
  350. "libasyncio",
  351. "libbase",
  352. "libcrypto",
  353. "libcrypto_utils",
  354. "libcutils",
  355. "liblog",
  356. ],
  357. product_variables: {
  358. debuggable: {
  359. required: [
  360. "remount",
  361. ],
  362. },
  363. },
  364. target: {
  365. android: {
  366. srcs: [
  367. "daemon/abb_service.cpp",
  368. "daemon/framebuffer_service.cpp",
  369. "daemon/mdns.cpp",
  370. "daemon/reboot_service.cpp",
  371. "daemon/remount_service.cpp",
  372. "daemon/restart_service.cpp",
  373. "daemon/set_verity_enable_state_service.cpp",
  374. ],
  375. static_libs: [
  376. "libavb_user",
  377. ],
  378. shared_libs: [
  379. "libbootloader_message",
  380. "libmdnssd",
  381. "libext4_utils",
  382. "libfec",
  383. "libfs_mgr",
  384. "libselinux",
  385. ],
  386. },
  387. recovery: {
  388. exclude_srcs: [
  389. "daemon/abb_service.cpp",
  390. ],
  391. },
  392. },
  393. }
  394. cc_library {
  395. name: "libadbd",
  396. defaults: ["adbd_defaults", "host_adbd_supported"],
  397. recovery_available: true,
  398. // Avoid getting duplicate symbol of android::build::GetBuildNumber().
  399. use_version_lib: false,
  400. // libminadbd wants both, as it's used to build native tests.
  401. compile_multilib: "both",
  402. // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
  403. whole_static_libs: [
  404. "libadbd_core",
  405. ],
  406. shared_libs: [
  407. "libadbd_services",
  408. "libasyncio",
  409. "libbase",
  410. "libcrypto",
  411. "libcrypto_utils",
  412. "libcutils",
  413. "liblog",
  414. ],
  415. export_include_dirs: [
  416. "daemon/include",
  417. ],
  418. }
  419. cc_binary {
  420. name: "adbd",
  421. defaults: ["adbd_defaults", "host_adbd_supported"],
  422. recovery_available: true,
  423. srcs: [
  424. "daemon/main.cpp",
  425. ],
  426. cflags: [
  427. "-D_GNU_SOURCE",
  428. "-Wno-deprecated-declarations",
  429. ],
  430. strip: {
  431. keep_symbols: true,
  432. },
  433. shared_libs: [
  434. "libadbd",
  435. "libadbd_services",
  436. "libbase",
  437. "libcap",
  438. "libcrypto",
  439. "libcutils",
  440. "liblog",
  441. "libminijail",
  442. "libselinux",
  443. ],
  444. }
  445. cc_binary {
  446. name: "abb",
  447. defaults: ["adbd_defaults"],
  448. recovery_available: false,
  449. srcs: [
  450. "daemon/abb.cpp",
  451. ],
  452. cflags: [
  453. "-D_GNU_SOURCE",
  454. "-Wno-deprecated-declarations",
  455. ],
  456. strip: {
  457. keep_symbols: true,
  458. },
  459. static_libs: [
  460. "libadbd_core",
  461. "libadbd_services",
  462. "libcmd",
  463. ],
  464. shared_libs: [
  465. "libbase",
  466. "libbinder",
  467. "liblog",
  468. "libutils",
  469. "libselinux",
  470. ],
  471. }
  472. cc_test {
  473. name: "adbd_test",
  474. defaults: ["adbd_defaults"],
  475. srcs: libadb_test_srcs + [
  476. "daemon/services.cpp",
  477. "daemon/shell_service.cpp",
  478. "daemon/shell_service_test.cpp",
  479. "shell_service_protocol.cpp",
  480. "shell_service_protocol_test.cpp",
  481. ],
  482. static_libs: [
  483. "libadbd",
  484. "libbase",
  485. "libbootloader_message",
  486. "libcutils",
  487. "libcrypto_utils",
  488. "libcrypto",
  489. "libdiagnose_usb",
  490. "liblog",
  491. "libusb",
  492. "libmdnssd",
  493. "libselinux",
  494. ],
  495. test_suites: ["device-tests"],
  496. }
  497. python_test_host {
  498. name: "adb_integration_test_adb",
  499. main: "test_adb.py",
  500. srcs: [
  501. "test_adb.py",
  502. ],
  503. test_config: "adb_integration_test_adb.xml",
  504. test_suites: ["general-tests"],
  505. version: {
  506. py2: {
  507. enabled: false,
  508. },
  509. py3: {
  510. enabled: true,
  511. },
  512. },
  513. }
  514. python_test_host {
  515. name: "adb_integration_test_device",
  516. main: "test_device.py",
  517. srcs: [
  518. "test_device.py",
  519. ],
  520. libs: [
  521. "adb_py",
  522. ],
  523. test_config: "adb_integration_test_device.xml",
  524. test_suites: ["general-tests"],
  525. version: {
  526. py2: {
  527. enabled: true,
  528. },
  529. py3: {
  530. enabled: false,
  531. },
  532. },
  533. }