blob: 00e98feeb2fa649a83ddd0abe214c69ea46dfc1f [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 ],
27 rtti: true,
Josh Gaoc51726c2018-10-11 16:33:05 -070028 cpp_std: "gnu++17",
Josh Gao27768452018-01-02 12:01:43 -080029
Josh Gaoc7567fa2018-02-27 15:49:23 -080030 use_version_lib: true,
31
Josh Gao27768452018-01-02 12:01:43 -080032 compile_multilib: "first",
33 product_variables: {
34 debuggable: {
35 cflags: [
36 "-DALLOW_ADBD_ROOT",
37 "-DALLOW_ADBD_DISABLE_VERITY",
38 "-DALLOW_ADBD_NO_AUTH",
39 ],
40 },
41 },
42
43 target: {
44 android: {
Josh Gao560a5472018-10-12 16:37:31 -070045 cflags: [
46 "-DADB_HOST=0",
47 "-Wthread-safety",
48 ],
Josh Gao27768452018-01-02 12:01:43 -080049 },
50
51 host: {
52 cflags: ["-DADB_HOST=1"],
53 },
54
55 darwin: {
56 host_ldlibs: [
57 "-lpthread",
58 "-framework CoreFoundation",
59 "-framework IOKit",
60 "-lobjc",
61 ],
62 },
63
64 windows: {
65 cflags: [
66 // Define windows.h and tchar.h Unicode preprocessor symbols so that
67 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
68 // build if you accidentally pass char*. Fix by calling like:
69 // std::wstring path_wide;
70 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
71 // CreateFileW(path_wide.c_str());
72 "-DUNICODE=1",
73 "-D_UNICODE=1",
74
Josh Gao2e1e7892018-03-23 13:03:28 -070075 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080076 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070077
78 // MinGW hides some things behind _POSIX_SOURCE.
79 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080080 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070081
82 host_ldlibs: [
83 "-lws2_32",
84 "-lgdi32",
85 "-luserenv",
86 ],
Josh Gao27768452018-01-02 12:01:43 -080087 },
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070088
89 not_windows: {
90 cflags: [
91 "-Wthread-safety",
92 ],
93 },
Josh Gao27768452018-01-02 12:01:43 -080094 },
95}
96
97// libadb
98// =========================================================
99// These files are compiled for both the host and the device.
100libadb_srcs = [
101 "adb.cpp",
102 "adb_io.cpp",
103 "adb_listeners.cpp",
104 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700105 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800106 "adb_utils.cpp",
107 "fdevent.cpp",
108 "services.cpp",
109 "sockets.cpp",
110 "socket_spec.cpp",
111 "sysdeps/errno.cpp",
112 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700113 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800114 "transport_local.cpp",
115 "transport_usb.cpp",
116]
117
118libadb_posix_srcs = [
119 "sysdeps_unix.cpp",
120 "sysdeps/posix/network.cpp",
121]
122
123libadb_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",
Josh Gao7c738cd2018-04-03 14:37:11 -0700133 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800134]
135
136cc_library_host_static {
137 name: "libadb_host",
138 defaults: ["adb_defaults"],
139
140 srcs: libadb_srcs + [
141 "client/auth.cpp",
142 "client/usb_libusb.cpp",
143 "client/usb_dispatch.cpp",
144 "client/transport_mdns.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000145 "client/fastdeploy.cpp",
146 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800147 ],
148
Dan Willemsenab971b52018-08-29 14:58:02 -0700149 generated_headers: ["platform_tools_version"],
150
Josh Gao27768452018-01-02 12:01:43 -0800151 target: {
152 linux: {
153 srcs: ["client/usb_linux.cpp"],
154 },
155 darwin: {
156 srcs: ["client/usb_osx.cpp"],
157 },
158
159 not_windows: {
160 srcs: libadb_posix_srcs,
161 },
162 windows: {
163 enabled: true,
164 srcs: [
165 "client/usb_windows.cpp",
166 "sysdeps_win32.cpp",
167 "sysdeps/win32/errno.cpp",
168 "sysdeps/win32/stat.cpp",
169 ],
170 shared_libs: ["AdbWinApi"],
171 },
172 },
173
174 static_libs: [
175 "libbase",
176 "libcrypto_utils",
177 "libcrypto",
178 "libdiagnose_usb",
179 "libmdnssd",
180 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100181 "libandroidfw",
182 "libziparchive",
183 "libz",
184 "libutils",
185 "liblog",
186 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800187 ],
188}
189
190cc_test_host {
191 name: "adb_test",
192 defaults: ["adb_defaults"],
193 srcs: libadb_test_srcs,
194 static_libs: [
195 "libadb_host",
196 "libbase",
197 "libcutils",
198 "libcrypto_utils",
199 "libcrypto",
200 "libmdnssd",
201 "libdiagnose_usb",
202 "libusb",
203 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700204
205 target: {
206 windows: {
207 enabled: true,
208 shared_libs: ["AdbWinApi"],
209 },
210 },
Josh Gao27768452018-01-02 12:01:43 -0800211}
212
Josh Gao9c596492018-04-04 11:27:24 -0700213cc_benchmark {
214 name: "adb_benchmark",
215 defaults: ["adb_defaults"],
216
217 srcs: ["transport_benchmark.cpp"],
218 target: {
219 android: {
220 static_libs: [
221 "libadbd",
222 ],
223 },
224 host: {
225 static_libs: [
226 "libadb_host",
227 ],
228 },
229 },
230
231 static_libs: [
232 "libbase",
233 "libcutils",
234 "libcrypto_utils",
235 "libcrypto",
236 "libdiagnose_usb",
237 "liblog",
238 "libusb",
239 ],
240}
241
Josh Gao27768452018-01-02 12:01:43 -0800242cc_binary_host {
243 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800244
245 defaults: ["adb_defaults"],
246
247 srcs: [
248 "client/adb_client.cpp",
249 "client/bugreport.cpp",
250 "client/commandline.cpp",
251 "client/file_sync_client.cpp",
252 "client/main.cpp",
253 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000254 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800255 "client/line_printer.cpp",
256 "shell_service_protocol.cpp",
257 ],
258
259 static_libs: [
260 "libadb_host",
261 "libbase",
262 "libcutils",
263 "libcrypto_utils",
264 "libcrypto",
265 "libdiagnose_usb",
266 "liblog",
267 "libmdnssd",
268 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100269 "libandroidfw",
270 "libziparchive",
271 "libz",
272 "libutils",
273 "liblog",
274 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800275 ],
276
277 stl: "libc++_static",
278
279 // Don't add anything here, we don't want additional shared dependencies
280 // on the host adb tool, and shared libraries that link against libc++
281 // will violate ODR
282 shared_libs: [],
283
Idries Hamadi7575cd92018-08-24 11:46:45 +0100284 required: [
285 "deploypatchgenerator",
286 ],
287
Josh Gao27768452018-01-02 12:01:43 -0800288 target: {
289 darwin: {
290 cflags: [
291 "-Wno-sizeof-pointer-memaccess",
292 ],
293 },
294 windows: {
295 enabled: true,
296 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800297 shared_libs: ["AdbWinApi"],
298 required: [
299 "AdbWinUsbApi",
300 ],
301 },
302 },
303}
304
Tao Baoeca59ae2018-07-30 20:45:27 -0700305// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800306cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700307 name: "libadbd_core",
308 defaults: ["adb_defaults"],
309 recovery_available: true,
310
311 // libminadbd wants both, as it's used to build native tests.
312 compile_multilib: "both",
313
314 srcs: libadb_srcs + libadb_posix_srcs + [
315 "daemon/auth.cpp",
316 "daemon/jdwp_service.cpp",
Josh Gaoc51726c2018-10-11 16:33:05 -0700317 "daemon/usb.cpp",
Josh Gao613cbb42018-10-08 14:20:29 -0700318 "daemon/usb_ffs.cpp",
Josh Gao61e9e392018-10-08 14:42:19 -0700319 "daemon/usb_legacy.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700320 ],
321
322 local_include_dirs: [
323 "daemon/include",
324 ],
325
Dan Willemsenab971b52018-08-29 14:58:02 -0700326 generated_headers: ["platform_tools_version"],
327
Tao Baoeca59ae2018-07-30 20:45:27 -0700328 static_libs: [
329 "libdiagnose_usb",
330 "libqemu_pipe",
331 ],
332
333 shared_libs: [
334 "libasyncio",
335 "libbase",
336 "libcrypto",
337 "libcrypto_utils",
338 "libcutils",
339 "liblog",
340 ],
341}
342
343cc_library {
344 name: "libadbd_services",
345 defaults: ["adb_defaults"],
346 recovery_available: true,
347 compile_multilib: "both",
348
349 srcs: [
350 "daemon/file_sync_service.cpp",
351 "daemon/framebuffer_service.cpp",
352 "daemon/mdns.cpp",
353 "daemon/remount_service.cpp",
354 "daemon/services.cpp",
355 "daemon/set_verity_enable_state_service.cpp",
356 "daemon/shell_service.cpp",
357 "shell_service_protocol.cpp",
358 ],
359
360 cflags: [
361 "-D_GNU_SOURCE",
362 "-Wno-deprecated-declarations",
363 ],
364
365 static_libs: [
366 "libadbd_core",
367 "libavb_user",
368 "libdiagnose_usb",
369 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700370 ],
371
372 shared_libs: [
373 "libasyncio",
374 "libbase",
375 "libbootloader_message",
376 "libcrypto",
377 "libcrypto_utils",
378 "libcutils",
379 "libext4_utils",
380 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700381 "libfs_mgr",
382 "liblog",
383 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700384 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700385 ],
386}
387
388cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800389 name: "libadbd",
390 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900391 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800392
Tao Baoeca59ae2018-07-30 20:45:27 -0700393 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
394 use_version_lib: false,
395
396 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800397 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700398
399 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
400 whole_static_libs: [
401 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800402 ],
403
Tao Baoeca59ae2018-07-30 20:45:27 -0700404 shared_libs: [
405 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800406 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800407 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700408 "libcrypto",
409 "libcrypto_utils",
410 "libcutils",
411 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800412 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700413
414 export_include_dirs: [
415 "daemon/include",
416 ],
Josh Gao27768452018-01-02 12:01:43 -0800417}
418
419cc_binary {
420 name: "adbd",
421 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900422 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800423
Josh Gao27768452018-01-02 12:01:43 -0800424 srcs: [
425 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800426 ],
427
428 cflags: [
429 "-D_GNU_SOURCE",
430 "-Wno-deprecated-declarations",
431 ],
432
433 strip: {
434 keep_symbols: true,
435 },
436
Tao Baoeca59ae2018-07-30 20:45:27 -0700437 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800438 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700439 "libadbd_services",
440 "libbase",
441 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800442 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700443 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800444 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800445 "libminijail",
446 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800447 ],
448}
449
450cc_test {
451 name: "adbd_test",
452 defaults: ["adb_defaults"],
453 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700454 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800455 "daemon/shell_service.cpp",
456 "daemon/shell_service_test.cpp",
457 "shell_service_protocol.cpp",
458 "shell_service_protocol_test.cpp",
459 ],
460
461 static_libs: [
462 "libadbd",
463 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700464 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800465 "libcutils",
466 "libcrypto_utils",
467 "libcrypto",
468 "libdiagnose_usb",
469 "liblog",
470 "libusb",
471 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900472 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800473 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700474 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800475}
476
Julien Desprez75fea7e2018-08-08 12:08:50 -0700477python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800478 name: "adb_integration_test_adb",
479 main: "test_adb.py",
480 srcs: [
481 "test_adb.py",
482 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700483 test_config: "adb_integration_test_adb.xml",
484 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800485 version: {
486 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700487 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800488 },
489 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700490 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800491 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700492 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700493}
494
Julien Desprez618f0e12018-10-12 13:48:14 -0700495python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800496 name: "adb_integration_test_device",
497 main: "test_device.py",
498 srcs: [
499 "test_device.py",
500 ],
501 libs: [
502 "adb_py",
503 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700504 test_config: "adb_integration_test_device.xml",
505 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800506 version: {
507 py2: {
508 enabled: true,
509 },
510 py3: {
511 enabled: false,
512 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700513 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700514}