blob: eec133584a687fb1a04271cb2537e4d6f4a1cba0 [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
Josh Gao4710e532019-04-17 16:57:43 -070062 // libusb uses __stdcall on a variadic function, which gets ignored.
63 "-Wno-ignored-attributes",
64
Josh Gao776c2ec2019-01-22 19:36:15 -080065 // Not supported yet.
66 "-Wno-thread-safety",
Josh Gao27768452018-01-02 12:01:43 -080067 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070068
69 host_ldlibs: [
70 "-lws2_32",
71 "-lgdi32",
72 "-luserenv",
73 ],
Josh Gao27768452018-01-02 12:01:43 -080074 },
Josh Gao776c2ec2019-01-22 19:36:15 -080075 },
76}
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070077
Josh Gao776c2ec2019-01-22 19:36:15 -080078cc_defaults {
79 name: "adbd_defaults",
80 defaults: ["adb_defaults"],
81
82 cflags: ["-UADB_HOST", "-DADB_HOST=0"],
83 product_variables: {
84 debuggable: {
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070085 cflags: [
Bowgo Tsai9b30c0a2019-03-12 04:25:33 +080086 "-UALLOW_ADBD_ROOT",
87 "-DALLOW_ADBD_ROOT=1",
Josh Gao776c2ec2019-01-22 19:36:15 -080088 "-DALLOW_ADBD_DISABLE_VERITY",
89 "-DALLOW_ADBD_NO_AUTH",
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070090 ],
91 },
Josh Gao27768452018-01-02 12:01:43 -080092 },
93}
94
Josh Gao776c2ec2019-01-22 19:36:15 -080095cc_defaults {
96 name: "host_adbd_supported",
97
98 host_supported: true,
99 target: {
100 linux: {
101 enabled: true,
102 host_ldlibs: [
103 "-lresolv", // b64_pton
104 "-lutil", // forkpty
105 ],
106 },
107 darwin: {
108 enabled: false,
109 },
110 windows: {
111 enabled: false,
112 },
113 },
114}
115
Josh Gao27768452018-01-02 12:01:43 -0800116// libadb
117// =========================================================
118// These files are compiled for both the host and the device.
119libadb_srcs = [
120 "adb.cpp",
121 "adb_io.cpp",
122 "adb_listeners.cpp",
123 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700124 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800125 "adb_utils.cpp",
126 "fdevent.cpp",
127 "services.cpp",
128 "sockets.cpp",
129 "socket_spec.cpp",
130 "sysdeps/errno.cpp",
131 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700132 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800133 "transport_local.cpp",
134 "transport_usb.cpp",
135]
136
137libadb_posix_srcs = [
138 "sysdeps_unix.cpp",
139 "sysdeps/posix/network.cpp",
140]
141
142libadb_test_srcs = [
143 "adb_io_test.cpp",
144 "adb_listeners_test.cpp",
145 "adb_utils_test.cpp",
146 "fdevent_test.cpp",
147 "socket_spec_test.cpp",
148 "socket_test.cpp",
149 "sysdeps_test.cpp",
150 "sysdeps/stat_test.cpp",
151 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700152 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800153]
154
155cc_library_host_static {
156 name: "libadb_host",
157 defaults: ["adb_defaults"],
158
159 srcs: libadb_srcs + [
160 "client/auth.cpp",
161 "client/usb_libusb.cpp",
162 "client/usb_dispatch.cpp",
163 "client/transport_mdns.cpp",
164 ],
165
Dan Willemsenab971b52018-08-29 14:58:02 -0700166 generated_headers: ["platform_tools_version"],
167
Josh Gao27768452018-01-02 12:01:43 -0800168 target: {
169 linux: {
170 srcs: ["client/usb_linux.cpp"],
171 },
172 darwin: {
173 srcs: ["client/usb_osx.cpp"],
174 },
175
176 not_windows: {
177 srcs: libadb_posix_srcs,
178 },
179 windows: {
180 enabled: true,
181 srcs: [
182 "client/usb_windows.cpp",
183 "sysdeps_win32.cpp",
184 "sysdeps/win32/errno.cpp",
185 "sysdeps/win32/stat.cpp",
186 ],
187 shared_libs: ["AdbWinApi"],
188 },
189 },
190
191 static_libs: [
192 "libbase",
193 "libcrypto_utils",
194 "libcrypto",
195 "libdiagnose_usb",
196 "libmdnssd",
197 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100198 "libutils",
199 "liblog",
200 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800201 ],
202}
203
204cc_test_host {
205 name: "adb_test",
206 defaults: ["adb_defaults"],
207 srcs: libadb_test_srcs,
208 static_libs: [
209 "libadb_host",
210 "libbase",
211 "libcutils",
212 "libcrypto_utils",
213 "libcrypto",
214 "libmdnssd",
215 "libdiagnose_usb",
216 "libusb",
217 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700218
219 target: {
220 windows: {
221 enabled: true,
222 shared_libs: ["AdbWinApi"],
223 },
224 },
Josh Gao27768452018-01-02 12:01:43 -0800225}
226
Josh Gao9c596492018-04-04 11:27:24 -0700227cc_benchmark {
228 name: "adb_benchmark",
229 defaults: ["adb_defaults"],
230
231 srcs: ["transport_benchmark.cpp"],
232 target: {
233 android: {
234 static_libs: [
235 "libadbd",
236 ],
237 },
238 host: {
239 static_libs: [
240 "libadb_host",
241 ],
242 },
243 },
244
245 static_libs: [
246 "libbase",
247 "libcutils",
248 "libcrypto_utils",
249 "libcrypto",
250 "libdiagnose_usb",
251 "liblog",
252 "libusb",
253 ],
254}
255
Josh Gao27768452018-01-02 12:01:43 -0800256cc_binary_host {
257 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800258
259 defaults: ["adb_defaults"],
260
261 srcs: [
262 "client/adb_client.cpp",
263 "client/bugreport.cpp",
264 "client/commandline.cpp",
265 "client/file_sync_client.cpp",
266 "client/main.cpp",
267 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000268 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800269 "client/line_printer.cpp",
270 "shell_service_protocol.cpp",
271 ],
272
273 static_libs: [
274 "libadb_host",
275 "libbase",
276 "libcutils",
277 "libcrypto_utils",
278 "libcrypto",
279 "libdiagnose_usb",
280 "liblog",
281 "libmdnssd",
282 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100283 "libutils",
284 "liblog",
285 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800286 ],
287
288 stl: "libc++_static",
289
290 // Don't add anything here, we don't want additional shared dependencies
291 // on the host adb tool, and shared libraries that link against libc++
292 // will violate ODR
293 shared_libs: [],
294
Idries Hamadi7575cd92018-08-24 11:46:45 +0100295 required: [
296 "deploypatchgenerator",
297 ],
298
Dan Willemsen3f439a72018-11-19 19:11:35 -0800299 // Archive adb, adb.exe.
300 dist: {
301 targets: [
302 "dist_files",
303 "sdk",
304 "win_sdk",
305 ],
306 },
307
Josh Gao27768452018-01-02 12:01:43 -0800308 target: {
309 darwin: {
310 cflags: [
311 "-Wno-sizeof-pointer-memaccess",
312 ],
313 },
314 windows: {
315 enabled: true,
316 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800317 shared_libs: ["AdbWinApi"],
318 required: [
319 "AdbWinUsbApi",
320 ],
321 },
322 },
323}
324
Tao Baoeca59ae2018-07-30 20:45:27 -0700325// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800326cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700327 name: "libadbd_core",
Josh Gao776c2ec2019-01-22 19:36:15 -0800328 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700329 recovery_available: true,
330
331 // libminadbd wants both, as it's used to build native tests.
332 compile_multilib: "both",
333
334 srcs: libadb_srcs + libadb_posix_srcs + [
335 "daemon/auth.cpp",
336 "daemon/jdwp_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700337 ],
338
339 local_include_dirs: [
340 "daemon/include",
341 ],
342
Dan Willemsenab971b52018-08-29 14:58:02 -0700343 generated_headers: ["platform_tools_version"],
344
Tao Baoeca59ae2018-07-30 20:45:27 -0700345 static_libs: [
346 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700347 ],
348
349 shared_libs: [
350 "libasyncio",
351 "libbase",
352 "libcrypto",
353 "libcrypto_utils",
354 "libcutils",
355 "liblog",
356 ],
Josh Gao776c2ec2019-01-22 19:36:15 -0800357
358 target: {
359 android: {
360 whole_static_libs: [
361 "libqemu_pipe",
362 ],
363 srcs: [
364 "daemon/transport_qemu.cpp",
365 "daemon/usb.cpp",
366 "daemon/usb_ffs.cpp",
367 "daemon/usb_legacy.cpp",
368 ]
369 },
370 linux_glibc: {
371 srcs: [
372 "daemon/usb_dummy.cpp",
373 ]
374 }
375 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700376}
377
378cc_library {
379 name: "libadbd_services",
Josh Gao776c2ec2019-01-22 19:36:15 -0800380 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700381 recovery_available: true,
382 compile_multilib: "both",
383
384 srcs: [
385 "daemon/file_sync_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700386 "daemon/services.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700387 "daemon/shell_service.cpp",
388 "shell_service_protocol.cpp",
389 ],
390
391 cflags: [
392 "-D_GNU_SOURCE",
393 "-Wno-deprecated-declarations",
394 ],
395
396 static_libs: [
397 "libadbd_core",
Tao Baoeca59ae2018-07-30 20:45:27 -0700398 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700399 ],
400
401 shared_libs: [
402 "libasyncio",
403 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700404 "libcrypto",
405 "libcrypto_utils",
406 "libcutils",
Tao Baoeca59ae2018-07-30 20:45:27 -0700407 "liblog",
Tao Baoeca59ae2018-07-30 20:45:27 -0700408 ],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800409
Mark Salyzyn2f6c1802019-02-15 07:45:26 -0800410 product_variables: {
411 debuggable: {
412 required: [
413 "remount",
414 ],
415 },
416 },
417
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800418 target: {
Josh Gao776c2ec2019-01-22 19:36:15 -0800419 android: {
420 srcs: [
421 "daemon/abb_service.cpp",
422 "daemon/framebuffer_service.cpp",
423 "daemon/mdns.cpp",
424 "daemon/reboot_service.cpp",
425 "daemon/remount_service.cpp",
426 "daemon/restart_service.cpp",
427 "daemon/set_verity_enable_state_service.cpp",
428 ],
429 static_libs: [
430 "libavb_user",
431 ],
432 shared_libs: [
433 "libbootloader_message",
434 "libmdnssd",
435 "libext4_utils",
436 "libfec",
437 "libfs_mgr",
438 "libselinux",
439 ],
440 },
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800441 recovery: {
442 exclude_srcs: [
443 "daemon/abb_service.cpp",
444 ],
445 },
446 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700447}
448
449cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800450 name: "libadbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800451 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900452 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800453
Tao Baoeca59ae2018-07-30 20:45:27 -0700454 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
455 use_version_lib: false,
456
457 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800458 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700459
460 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
461 whole_static_libs: [
462 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800463 ],
464
Tao Baoeca59ae2018-07-30 20:45:27 -0700465 shared_libs: [
466 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800467 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800468 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700469 "libcrypto",
470 "libcrypto_utils",
471 "libcutils",
472 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800473 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700474
475 export_include_dirs: [
476 "daemon/include",
477 ],
Josh Gao27768452018-01-02 12:01:43 -0800478}
479
480cc_binary {
481 name: "adbd",
Josh Gao776c2ec2019-01-22 19:36:15 -0800482 defaults: ["adbd_defaults", "host_adbd_supported"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900483 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800484
Josh Gao27768452018-01-02 12:01:43 -0800485 srcs: [
486 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800487 ],
488
489 cflags: [
490 "-D_GNU_SOURCE",
491 "-Wno-deprecated-declarations",
492 ],
493
494 strip: {
495 keep_symbols: true,
496 },
497
Tao Baoeca59ae2018-07-30 20:45:27 -0700498 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800499 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700500 "libadbd_services",
501 "libbase",
502 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800503 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700504 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800505 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800506 "libminijail",
507 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800508 ],
509}
510
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800511cc_binary {
512 name: "abb",
513
Josh Gao776c2ec2019-01-22 19:36:15 -0800514 defaults: ["adbd_defaults"],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800515 recovery_available: false,
516
517 srcs: [
518 "daemon/abb.cpp",
519 ],
520
521 cflags: [
522 "-D_GNU_SOURCE",
523 "-Wno-deprecated-declarations",
524 ],
525
526 strip: {
527 keep_symbols: true,
528 },
529
530 static_libs: [
531 "libadbd_core",
532 "libadbd_services",
533 "libcmd",
534 ],
535
536 shared_libs: [
537 "libbase",
538 "libbinder",
539 "liblog",
540 "libutils",
541 "libselinux",
542 ],
543}
544
Josh Gao27768452018-01-02 12:01:43 -0800545cc_test {
546 name: "adbd_test",
Josh Gao776c2ec2019-01-22 19:36:15 -0800547 defaults: ["adbd_defaults"],
Josh Gao27768452018-01-02 12:01:43 -0800548 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700549 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800550 "daemon/shell_service.cpp",
551 "daemon/shell_service_test.cpp",
552 "shell_service_protocol.cpp",
553 "shell_service_protocol_test.cpp",
554 ],
555
556 static_libs: [
557 "libadbd",
558 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700559 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800560 "libcutils",
561 "libcrypto_utils",
562 "libcrypto",
563 "libdiagnose_usb",
564 "liblog",
565 "libusb",
566 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900567 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800568 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700569 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800570}
571
Julien Desprez75fea7e2018-08-08 12:08:50 -0700572python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800573 name: "adb_integration_test_adb",
574 main: "test_adb.py",
575 srcs: [
576 "test_adb.py",
577 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700578 test_config: "adb_integration_test_adb.xml",
579 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800580 version: {
581 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700582 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800583 },
584 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700585 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800586 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700587 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700588}
589
Julien Desprez618f0e12018-10-12 13:48:14 -0700590python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800591 name: "adb_integration_test_device",
592 main: "test_device.py",
593 srcs: [
594 "test_device.py",
595 ],
596 libs: [
597 "adb_py",
598 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700599 test_config: "adb_integration_test_device.xml",
600 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800601 version: {
602 py2: {
603 enabled: true,
604 },
605 py3: {
606 enabled: false,
607 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700608 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700609}