blob: 8199fff107ed2a0b36fcecb661aebe4d89697a98 [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",
Idries Hamadied409ea2018-01-29 16:30:36 +0000159 "client/fastdeploy.cpp",
160 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800161 ],
162
Dan Willemsenab971b52018-08-29 14:58:02 -0700163 generated_headers: ["platform_tools_version"],
164
Josh Gao27768452018-01-02 12:01:43 -0800165 target: {
166 linux: {
167 srcs: ["client/usb_linux.cpp"],
168 },
169 darwin: {
170 srcs: ["client/usb_osx.cpp"],
171 },
172
173 not_windows: {
174 srcs: libadb_posix_srcs,
175 },
176 windows: {
177 enabled: true,
178 srcs: [
179 "client/usb_windows.cpp",
180 "sysdeps_win32.cpp",
181 "sysdeps/win32/errno.cpp",
182 "sysdeps/win32/stat.cpp",
183 ],
184 shared_libs: ["AdbWinApi"],
185 },
186 },
187
188 static_libs: [
189 "libbase",
190 "libcrypto_utils",
191 "libcrypto",
192 "libdiagnose_usb",
193 "libmdnssd",
194 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100195 "libandroidfw",
196 "libziparchive",
197 "libz",
198 "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 "libandroidfw",
284 "libziparchive",
285 "libz",
286 "libutils",
287 "liblog",
288 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800289 ],
290
291 stl: "libc++_static",
292
293 // Don't add anything here, we don't want additional shared dependencies
294 // on the host adb tool, and shared libraries that link against libc++
295 // will violate ODR
296 shared_libs: [],
297
Idries Hamadi7575cd92018-08-24 11:46:45 +0100298 required: [
299 "deploypatchgenerator",
300 ],
301
Dan Willemsen3f439a72018-11-19 19:11:35 -0800302 // Archive adb, adb.exe.
303 dist: {
304 targets: [
305 "dist_files",
306 "sdk",
307 "win_sdk",
308 ],
309 },
310
Josh Gao27768452018-01-02 12:01:43 -0800311 target: {
312 darwin: {
313 cflags: [
314 "-Wno-sizeof-pointer-memaccess",
315 ],
316 },
317 windows: {
318 enabled: true,
319 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800320 shared_libs: ["AdbWinApi"],
321 required: [
322 "AdbWinUsbApi",
323 ],
324 },
325 },
326}
327
Tao Baoeca59ae2018-07-30 20:45:27 -0700328// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800329cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700330 name: "libadbd_core",
Josh Gao776c2ec2019-01-22 19:36:15 -0800331 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700332 recovery_available: true,
333
334 // libminadbd wants both, as it's used to build native tests.
335 compile_multilib: "both",
336
337 srcs: libadb_srcs + libadb_posix_srcs + [
338 "daemon/auth.cpp",
339 "daemon/jdwp_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700340 ],
341
342 local_include_dirs: [
343 "daemon/include",
344 ],
345
Dan Willemsenab971b52018-08-29 14:58:02 -0700346 generated_headers: ["platform_tools_version"],
347
Tao Baoeca59ae2018-07-30 20:45:27 -0700348 static_libs: [
349 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700350 ],
351
352 shared_libs: [
353 "libasyncio",
354 "libbase",
355 "libcrypto",
356 "libcrypto_utils",
357 "libcutils",
358 "liblog",
359 ],
Josh Gao776c2ec2019-01-22 19:36:15 -0800360
361 target: {
362 android: {
363 whole_static_libs: [
364 "libqemu_pipe",
365 ],
366 srcs: [
367 "daemon/transport_qemu.cpp",
368 "daemon/usb.cpp",
369 "daemon/usb_ffs.cpp",
370 "daemon/usb_legacy.cpp",
371 ]
372 },
373 linux_glibc: {
374 srcs: [
375 "daemon/usb_dummy.cpp",
376 ]
377 }
378 },
Tao Baoeca59ae2018-07-30 20:45:27 -0700379}
380
381cc_library {
382 name: "libadbd_services",
Josh Gao776c2ec2019-01-22 19:36:15 -0800383 defaults: ["adbd_defaults", "host_adbd_supported"],
Tao Baoeca59ae2018-07-30 20:45:27 -0700384 recovery_available: true,
385 compile_multilib: "both",
386
387 srcs: [
388 "daemon/file_sync_service.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700389 "daemon/services.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700390 "daemon/shell_service.cpp",
391 "shell_service_protocol.cpp",
392 ],
393
394 cflags: [
395 "-D_GNU_SOURCE",
396 "-Wno-deprecated-declarations",
397 ],
398
399 static_libs: [
400 "libadbd_core",
Tao Baoeca59ae2018-07-30 20:45:27 -0700401 "libdiagnose_usb",
Tao Baoeca59ae2018-07-30 20:45:27 -0700402 ],
403
404 shared_libs: [
405 "libasyncio",
406 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700407 "libcrypto",
408 "libcrypto_utils",
409 "libcutils",
Tao Baoeca59ae2018-07-30 20:45:27 -0700410 "liblog",
Tao Baoeca59ae2018-07-30 20:45:27 -0700411 ],
Alex Buynytskyy640407d2018-12-12 10:48:50 -0800412
413 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}