blob: 38135781d07466afcfb298573158b6718dff77e2 [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
405 target: {
Josh Gao776c2ec2019-01-22 19:36:15 -0800406 android: {
407 srcs: [
408 "daemon/abb_service.cpp",
409 "daemon/framebuffer_service.cpp",
410 "daemon/mdns.cpp",
411 "daemon/reboot_service.cpp",
412 "daemon/remount_service.cpp",
413 "daemon/restart_service.cpp",
414 "daemon/set_verity_enable_state_service.cpp",
415 ],
416 static_libs: [
417 "libavb_user",
418 ],
419 shared_libs: [
420 "libbootloader_message",
421 "libmdnssd",
422 "libext4_utils",
423 "libfec",
424 "libfs_mgr",
425 "libselinux",
426 ],
427 },
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800428 recovery: {
429 exclude_srcs: [
430 "daemon/abb_service.cpp",
431 ],
432 },
433 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700434}
435
436cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800437 name: "libadbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800438 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900439 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800440
Tao Baoeca59ae2018-07-30 20:45:27 -0700441 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
442 use_version_lib: false,
443
444 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800445 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700446
447 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
448 whole_static_libs: [
449 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800450 ],
451
Tao Baoeca59ae2018-07-30 20:45:27 -0700452 shared_libs: [
453 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800454 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800455 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700456 "libcrypto",
457 "libcrypto_utils",
458 "libcutils",
459 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800460 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700461
462 export_include_dirs: [
463 "daemon/include",
464 ],
Josh Gao27768452018-01-02 12:01:43 -0800465}
466
467cc_binary {
468 name: "adbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800469 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900470 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800471
Josh Gao27768452018-01-02 12:01:43 -0800472 srcs: [
473 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800474 ],
475
476 cflags: [
477 "-D_GNU_SOURCE",
478 "-Wno-deprecated-declarations",
479 ],
480
481 strip: {
482 keep_symbols: true,
483 },
484
Tao Baoeca59ae2018-07-30 20:45:27 -0700485 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800486 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700487 "libadbd_services",
488 "libbase",
489 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800490 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700491 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800492 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800493 "libminijail",
494 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800495 ],
496}
497
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800498cc_binary {
499 name: "abb",
500
Josh Gao776c2ec2019-01-22 19:36:15 -0800501 defaults: ["adbd_defaults"],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800502 recovery_available: false,
503
504 srcs: [
505 "daemon/abb.cpp",
506 ],
507
508 cflags: [
509 "-D_GNU_SOURCE",
510 "-Wno-deprecated-declarations",
511 ],
512
513 strip: {
514 keep_symbols: true,
515 },
516
517 static_libs: [
518 "libadbd_core",
519 "libadbd_services",
520 "libcmd",
521 ],
522
523 shared_libs: [
524 "libbase",
525 "libbinder",
526 "liblog",
527 "libutils",
528 "libselinux",
529 ],
530}
531
Josh Gao27768452018-01-02 12:01:43 -0800532cc_test {
533 name: "adbd_test",
Josh Gao776c2ec2019-01-22 19:36:15 -0800534 defaults: ["adbd_defaults"],
Josh Gao27768452018-01-02 12:01:43 -0800535 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700536 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800537 "daemon/shell_service.cpp",
538 "daemon/shell_service_test.cpp",
539 "shell_service_protocol.cpp",
540 "shell_service_protocol_test.cpp",
541 ],
542
543 static_libs: [
544 "libadbd",
545 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700546 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800547 "libcutils",
548 "libcrypto_utils",
549 "libcrypto",
550 "libdiagnose_usb",
551 "liblog",
552 "libusb",
553 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900554 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800555 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700556 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800557}
558
Julien Desprez75fea7e2018-08-08 12:08:50 -0700559python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800560 name: "adb_integration_test_adb",
561 main: "test_adb.py",
562 srcs: [
563 "test_adb.py",
564 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700565 test_config: "adb_integration_test_adb.xml",
566 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800567 version: {
568 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700569 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800570 },
571 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700572 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800573 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700574 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700575}
576
Julien Desprez618f0e12018-10-12 13:48:14 -0700577python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800578 name: "adb_integration_test_device",
579 main: "test_device.py",
580 srcs: [
581 "test_device.py",
582 ],
583 libs: [
584 "adb_py",
585 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700586 test_config: "adb_integration_test_device.xml",
587 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800588 version: {
589 py2: {
590 enabled: true,
591 },
592 py3: {
593 enabled: false,
594 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700595 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700596}