blob: ba72d9960b44cd9e741630d65c5985226ecd86d9 [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"],
Josh Gao80dd70d2018-11-12 12:03:04 -0800216 host_supported: true,
Josh Gao9c596492018-04-04 11:27:24 -0700217
218 srcs: ["transport_benchmark.cpp"],
219 target: {
220 android: {
221 static_libs: [
222 "libadbd",
223 ],
224 },
225 host: {
226 static_libs: [
227 "libadb_host",
228 ],
229 },
Josh Gao80dd70d2018-11-12 12:03:04 -0800230 darwin: {
231 enabled: false,
232 }
Josh Gao9c596492018-04-04 11:27:24 -0700233 },
234
235 static_libs: [
236 "libbase",
237 "libcutils",
238 "libcrypto_utils",
239 "libcrypto",
240 "libdiagnose_usb",
241 "liblog",
242 "libusb",
243 ],
244}
245
Josh Gao27768452018-01-02 12:01:43 -0800246cc_binary_host {
247 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800248
249 defaults: ["adb_defaults"],
250
251 srcs: [
252 "client/adb_client.cpp",
253 "client/bugreport.cpp",
254 "client/commandline.cpp",
255 "client/file_sync_client.cpp",
256 "client/main.cpp",
257 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000258 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800259 "client/line_printer.cpp",
260 "shell_service_protocol.cpp",
261 ],
262
263 static_libs: [
264 "libadb_host",
265 "libbase",
266 "libcutils",
267 "libcrypto_utils",
268 "libcrypto",
269 "libdiagnose_usb",
270 "liblog",
271 "libmdnssd",
272 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100273 "libandroidfw",
274 "libziparchive",
275 "libz",
276 "libutils",
277 "liblog",
278 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800279 ],
280
281 stl: "libc++_static",
282
283 // Don't add anything here, we don't want additional shared dependencies
284 // on the host adb tool, and shared libraries that link against libc++
285 // will violate ODR
286 shared_libs: [],
287
Idries Hamadi7575cd92018-08-24 11:46:45 +0100288 required: [
289 "deploypatchgenerator",
290 ],
291
Josh Gao27768452018-01-02 12:01:43 -0800292 target: {
293 darwin: {
294 cflags: [
295 "-Wno-sizeof-pointer-memaccess",
296 ],
297 },
298 windows: {
299 enabled: true,
300 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800301 shared_libs: ["AdbWinApi"],
302 required: [
303 "AdbWinUsbApi",
304 ],
305 },
306 },
307}
308
Tao Baoeca59ae2018-07-30 20:45:27 -0700309// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800310cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700311 name: "libadbd_core",
312 defaults: ["adb_defaults"],
313 recovery_available: true,
314
315 // libminadbd wants both, as it's used to build native tests.
316 compile_multilib: "both",
317
318 srcs: libadb_srcs + libadb_posix_srcs + [
319 "daemon/auth.cpp",
320 "daemon/jdwp_service.cpp",
Josh Gaoc51726c2018-10-11 16:33:05 -0700321 "daemon/usb.cpp",
Josh Gao613cbb42018-10-08 14:20:29 -0700322 "daemon/usb_ffs.cpp",
Josh Gao61e9e392018-10-08 14:42:19 -0700323 "daemon/usb_legacy.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700324 ],
325
326 local_include_dirs: [
327 "daemon/include",
328 ],
329
Dan Willemsenab971b52018-08-29 14:58:02 -0700330 generated_headers: ["platform_tools_version"],
331
Tao Baoeca59ae2018-07-30 20:45:27 -0700332 static_libs: [
333 "libdiagnose_usb",
334 "libqemu_pipe",
335 ],
336
337 shared_libs: [
338 "libasyncio",
339 "libbase",
340 "libcrypto",
341 "libcrypto_utils",
342 "libcutils",
343 "liblog",
344 ],
345}
346
347cc_library {
348 name: "libadbd_services",
349 defaults: ["adb_defaults"],
350 recovery_available: true,
351 compile_multilib: "both",
352
353 srcs: [
354 "daemon/file_sync_service.cpp",
355 "daemon/framebuffer_service.cpp",
356 "daemon/mdns.cpp",
357 "daemon/remount_service.cpp",
358 "daemon/services.cpp",
359 "daemon/set_verity_enable_state_service.cpp",
360 "daemon/shell_service.cpp",
361 "shell_service_protocol.cpp",
362 ],
363
364 cflags: [
365 "-D_GNU_SOURCE",
366 "-Wno-deprecated-declarations",
367 ],
368
369 static_libs: [
370 "libadbd_core",
371 "libavb_user",
372 "libdiagnose_usb",
373 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700374 ],
375
376 shared_libs: [
377 "libasyncio",
378 "libbase",
379 "libbootloader_message",
380 "libcrypto",
381 "libcrypto_utils",
382 "libcutils",
383 "libext4_utils",
384 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700385 "libfs_mgr",
386 "liblog",
387 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700388 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700389 ],
390}
391
392cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800393 name: "libadbd",
394 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900395 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800396
Tao Baoeca59ae2018-07-30 20:45:27 -0700397 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
398 use_version_lib: false,
399
400 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800401 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700402
403 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
404 whole_static_libs: [
405 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800406 ],
407
Tao Baoeca59ae2018-07-30 20:45:27 -0700408 shared_libs: [
409 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800410 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800411 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700412 "libcrypto",
413 "libcrypto_utils",
414 "libcutils",
415 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800416 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700417
418 export_include_dirs: [
419 "daemon/include",
420 ],
Josh Gao27768452018-01-02 12:01:43 -0800421}
422
423cc_binary {
424 name: "adbd",
425 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900426 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800427
Josh Gao27768452018-01-02 12:01:43 -0800428 srcs: [
429 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800430 ],
431
432 cflags: [
433 "-D_GNU_SOURCE",
434 "-Wno-deprecated-declarations",
435 ],
436
437 strip: {
438 keep_symbols: true,
439 },
440
Tao Baoeca59ae2018-07-30 20:45:27 -0700441 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800442 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700443 "libadbd_services",
444 "libbase",
445 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800446 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700447 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800448 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800449 "libminijail",
450 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800451 ],
452}
453
454cc_test {
455 name: "adbd_test",
456 defaults: ["adb_defaults"],
457 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700458 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800459 "daemon/shell_service.cpp",
460 "daemon/shell_service_test.cpp",
461 "shell_service_protocol.cpp",
462 "shell_service_protocol_test.cpp",
463 ],
464
465 static_libs: [
466 "libadbd",
467 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700468 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800469 "libcutils",
470 "libcrypto_utils",
471 "libcrypto",
472 "libdiagnose_usb",
473 "liblog",
474 "libusb",
475 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900476 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800477 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700478 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800479}
480
Julien Desprez75fea7e2018-08-08 12:08:50 -0700481python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800482 name: "adb_integration_test_adb",
483 main: "test_adb.py",
484 srcs: [
485 "test_adb.py",
486 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700487 test_config: "adb_integration_test_adb.xml",
488 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800489 version: {
490 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700491 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800492 },
493 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700494 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800495 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700496 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700497}
498
Julien Desprez618f0e12018-10-12 13:48:14 -0700499python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800500 name: "adb_integration_test_device",
501 main: "test_device.py",
502 srcs: [
503 "test_device.py",
504 ],
505 libs: [
506 "adb_py",
507 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700508 test_config: "adb_integration_test_device.xml",
509 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800510 version: {
511 py2: {
512 enabled: true,
513 },
514 py3: {
515 enabled: false,
516 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700517 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700518}