blob: fd68bc343a08f7e5d670a0a1be7f3acf85592b63 [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",
25 "-Wvla",
26 ],
Josh Gao27768452018-01-02 12:01:43 -080027
Josh Gaoc7567fa2018-02-27 15:49:23 -080028 use_version_lib: true,
29
Josh Gao27768452018-01-02 12:01:43 -080030 compile_multilib: "first",
31 product_variables: {
32 debuggable: {
33 cflags: [
34 "-DALLOW_ADBD_ROOT",
35 "-DALLOW_ADBD_DISABLE_VERITY",
36 "-DALLOW_ADBD_NO_AUTH",
37 ],
38 },
39 },
40
41 target: {
42 android: {
Josh Gao560a5472018-10-12 16:37:31 -070043 cflags: [
44 "-DADB_HOST=0",
45 "-Wthread-safety",
46 ],
Josh Gao27768452018-01-02 12:01:43 -080047 },
48
49 host: {
50 cflags: ["-DADB_HOST=1"],
51 },
52
53 darwin: {
54 host_ldlibs: [
55 "-lpthread",
56 "-framework CoreFoundation",
57 "-framework IOKit",
58 "-lobjc",
59 ],
60 },
61
62 windows: {
63 cflags: [
64 // Define windows.h and tchar.h Unicode preprocessor symbols so that
65 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
66 // build if you accidentally pass char*. Fix by calling like:
67 // std::wstring path_wide;
68 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
69 // CreateFileW(path_wide.c_str());
70 "-DUNICODE=1",
71 "-D_UNICODE=1",
72
Elliott Hughes3c59cb82018-12-03 09:02:18 -080073 // Unlike on Linux, -std=gnu++ doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080074 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070075
76 // MinGW hides some things behind _POSIX_SOURCE.
77 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080078 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070079
80 host_ldlibs: [
81 "-lws2_32",
82 "-lgdi32",
83 "-luserenv",
84 ],
Josh Gao27768452018-01-02 12:01:43 -080085 },
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070086
87 not_windows: {
88 cflags: [
89 "-Wthread-safety",
90 ],
91 },
Josh Gao27768452018-01-02 12:01:43 -080092 },
93}
94
95// libadb
96// =========================================================
97// These files are compiled for both the host and the device.
98libadb_srcs = [
99 "adb.cpp",
100 "adb_io.cpp",
101 "adb_listeners.cpp",
102 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700103 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800104 "adb_utils.cpp",
105 "fdevent.cpp",
106 "services.cpp",
107 "sockets.cpp",
108 "socket_spec.cpp",
109 "sysdeps/errno.cpp",
110 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700111 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800112 "transport_local.cpp",
113 "transport_usb.cpp",
114]
115
116libadb_posix_srcs = [
117 "sysdeps_unix.cpp",
118 "sysdeps/posix/network.cpp",
119]
120
121libadb_test_srcs = [
122 "adb_io_test.cpp",
123 "adb_listeners_test.cpp",
124 "adb_utils_test.cpp",
125 "fdevent_test.cpp",
126 "socket_spec_test.cpp",
127 "socket_test.cpp",
128 "sysdeps_test.cpp",
129 "sysdeps/stat_test.cpp",
130 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700131 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800132]
133
134cc_library_host_static {
135 name: "libadb_host",
136 defaults: ["adb_defaults"],
137
138 srcs: libadb_srcs + [
139 "client/auth.cpp",
140 "client/usb_libusb.cpp",
141 "client/usb_dispatch.cpp",
142 "client/transport_mdns.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000143 "client/fastdeploy.cpp",
144 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800145 ],
146
Dan Willemsenab971b52018-08-29 14:58:02 -0700147 generated_headers: ["platform_tools_version"],
148
Josh Gao27768452018-01-02 12:01:43 -0800149 target: {
150 linux: {
151 srcs: ["client/usb_linux.cpp"],
152 },
153 darwin: {
154 srcs: ["client/usb_osx.cpp"],
155 },
156
157 not_windows: {
158 srcs: libadb_posix_srcs,
159 },
160 windows: {
161 enabled: true,
162 srcs: [
163 "client/usb_windows.cpp",
164 "sysdeps_win32.cpp",
165 "sysdeps/win32/errno.cpp",
166 "sysdeps/win32/stat.cpp",
167 ],
168 shared_libs: ["AdbWinApi"],
169 },
170 },
171
172 static_libs: [
173 "libbase",
174 "libcrypto_utils",
175 "libcrypto",
176 "libdiagnose_usb",
177 "libmdnssd",
178 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100179 "libandroidfw",
180 "libziparchive",
181 "libz",
182 "libutils",
183 "liblog",
184 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800185 ],
186}
187
188cc_test_host {
189 name: "adb_test",
190 defaults: ["adb_defaults"],
191 srcs: libadb_test_srcs,
192 static_libs: [
193 "libadb_host",
194 "libbase",
195 "libcutils",
196 "libcrypto_utils",
197 "libcrypto",
198 "libmdnssd",
199 "libdiagnose_usb",
200 "libusb",
201 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700202
203 target: {
204 windows: {
205 enabled: true,
206 shared_libs: ["AdbWinApi"],
207 },
208 },
Josh Gao27768452018-01-02 12:01:43 -0800209}
210
Josh Gao9c596492018-04-04 11:27:24 -0700211cc_benchmark {
212 name: "adb_benchmark",
213 defaults: ["adb_defaults"],
214
215 srcs: ["transport_benchmark.cpp"],
216 target: {
217 android: {
218 static_libs: [
219 "libadbd",
220 ],
221 },
222 host: {
223 static_libs: [
224 "libadb_host",
225 ],
226 },
227 },
228
229 static_libs: [
230 "libbase",
231 "libcutils",
232 "libcrypto_utils",
233 "libcrypto",
234 "libdiagnose_usb",
235 "liblog",
236 "libusb",
237 ],
238}
239
Josh Gao27768452018-01-02 12:01:43 -0800240cc_binary_host {
241 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800242
243 defaults: ["adb_defaults"],
244
245 srcs: [
246 "client/adb_client.cpp",
247 "client/bugreport.cpp",
248 "client/commandline.cpp",
249 "client/file_sync_client.cpp",
250 "client/main.cpp",
251 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000252 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800253 "client/line_printer.cpp",
254 "shell_service_protocol.cpp",
255 ],
256
257 static_libs: [
258 "libadb_host",
259 "libbase",
260 "libcutils",
261 "libcrypto_utils",
262 "libcrypto",
263 "libdiagnose_usb",
264 "liblog",
265 "libmdnssd",
266 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100267 "libandroidfw",
268 "libziparchive",
269 "libz",
270 "libutils",
271 "liblog",
272 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800273 ],
274
275 stl: "libc++_static",
276
277 // Don't add anything here, we don't want additional shared dependencies
278 // on the host adb tool, and shared libraries that link against libc++
279 // will violate ODR
280 shared_libs: [],
281
Idries Hamadi7575cd92018-08-24 11:46:45 +0100282 required: [
283 "deploypatchgenerator",
284 ],
285
Dan Willemsen3f439a72018-11-19 19:11:35 -0800286 // Archive adb, adb.exe.
287 dist: {
288 targets: [
289 "dist_files",
290 "sdk",
291 "win_sdk",
292 ],
293 },
294
Josh Gao27768452018-01-02 12:01:43 -0800295 target: {
296 darwin: {
297 cflags: [
298 "-Wno-sizeof-pointer-memaccess",
299 ],
300 },
301 windows: {
302 enabled: true,
303 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800304 shared_libs: ["AdbWinApi"],
305 required: [
306 "AdbWinUsbApi",
307 ],
308 },
309 },
310}
311
Tao Baoeca59ae2018-07-30 20:45:27 -0700312// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800313cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700314 name: "libadbd_core",
315 defaults: ["adb_defaults"],
316 recovery_available: true,
317
318 // libminadbd wants both, as it's used to build native tests.
319 compile_multilib: "both",
320
321 srcs: libadb_srcs + libadb_posix_srcs + [
322 "daemon/auth.cpp",
323 "daemon/jdwp_service.cpp",
Josh Gaoc51726c2018-10-11 16:33:05 -0700324 "daemon/usb.cpp",
Josh Gao613cbb42018-10-08 14:20:29 -0700325 "daemon/usb_ffs.cpp",
Josh Gao61e9e392018-10-08 14:42:19 -0700326 "daemon/usb_legacy.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700327 ],
328
329 local_include_dirs: [
330 "daemon/include",
331 ],
332
Dan Willemsenab971b52018-08-29 14:58:02 -0700333 generated_headers: ["platform_tools_version"],
334
Tao Baoeca59ae2018-07-30 20:45:27 -0700335 static_libs: [
336 "libdiagnose_usb",
337 "libqemu_pipe",
338 ],
339
340 shared_libs: [
341 "libasyncio",
342 "libbase",
343 "libcrypto",
344 "libcrypto_utils",
345 "libcutils",
346 "liblog",
347 ],
348}
349
350cc_library {
351 name: "libadbd_services",
352 defaults: ["adb_defaults"],
353 recovery_available: true,
354 compile_multilib: "both",
355
356 srcs: [
357 "daemon/file_sync_service.cpp",
358 "daemon/framebuffer_service.cpp",
359 "daemon/mdns.cpp",
360 "daemon/remount_service.cpp",
361 "daemon/services.cpp",
362 "daemon/set_verity_enable_state_service.cpp",
363 "daemon/shell_service.cpp",
364 "shell_service_protocol.cpp",
365 ],
366
367 cflags: [
368 "-D_GNU_SOURCE",
369 "-Wno-deprecated-declarations",
370 ],
371
372 static_libs: [
373 "libadbd_core",
374 "libavb_user",
375 "libdiagnose_usb",
376 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700377 ],
378
379 shared_libs: [
380 "libasyncio",
381 "libbase",
382 "libbootloader_message",
383 "libcrypto",
384 "libcrypto_utils",
385 "libcutils",
386 "libext4_utils",
387 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700388 "libfs_mgr",
389 "liblog",
390 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700391 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700392 ],
393}
394
395cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800396 name: "libadbd",
397 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900398 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800399
Tao Baoeca59ae2018-07-30 20:45:27 -0700400 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
401 use_version_lib: false,
402
403 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800404 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700405
406 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
407 whole_static_libs: [
408 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800409 ],
410
Tao Baoeca59ae2018-07-30 20:45:27 -0700411 shared_libs: [
412 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800413 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800414 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700415 "libcrypto",
416 "libcrypto_utils",
417 "libcutils",
418 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800419 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700420
421 export_include_dirs: [
422 "daemon/include",
423 ],
Josh Gao27768452018-01-02 12:01:43 -0800424}
425
426cc_binary {
427 name: "adbd",
428 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900429 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800430
Josh Gao27768452018-01-02 12:01:43 -0800431 srcs: [
432 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800433 ],
434
435 cflags: [
436 "-D_GNU_SOURCE",
437 "-Wno-deprecated-declarations",
438 ],
439
440 strip: {
441 keep_symbols: true,
442 },
443
Tao Baoeca59ae2018-07-30 20:45:27 -0700444 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800445 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700446 "libadbd_services",
447 "libbase",
448 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800449 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700450 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800451 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800452 "libminijail",
453 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800454 ],
455}
456
457cc_test {
458 name: "adbd_test",
459 defaults: ["adb_defaults"],
460 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700461 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800462 "daemon/shell_service.cpp",
463 "daemon/shell_service_test.cpp",
464 "shell_service_protocol.cpp",
465 "shell_service_protocol_test.cpp",
466 ],
467
468 static_libs: [
469 "libadbd",
470 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700471 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800472 "libcutils",
473 "libcrypto_utils",
474 "libcrypto",
475 "libdiagnose_usb",
476 "liblog",
477 "libusb",
478 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900479 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800480 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700481 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800482}
483
Julien Desprez75fea7e2018-08-08 12:08:50 -0700484python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800485 name: "adb_integration_test_adb",
486 main: "test_adb.py",
487 srcs: [
488 "test_adb.py",
489 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700490 test_config: "adb_integration_test_adb.xml",
491 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800492 version: {
493 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700494 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800495 },
496 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700497 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800498 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700499 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700500}
501
Julien Desprez618f0e12018-10-12 13:48:14 -0700502python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800503 name: "adb_integration_test_device",
504 main: "test_device.py",
505 srcs: [
506 "test_device.py",
507 ],
508 libs: [
509 "adb_py",
510 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700511 test_config: "adb_integration_test_device.xml",
512 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800513 version: {
514 py2: {
515 enabled: true,
516 },
517 py3: {
518 enabled: false,
519 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700520 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700521}