blob: d7eb870e9966d37ffe2342b1d281c936ba5bc564 [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,
28
Josh Gaoc7567fa2018-02-27 15:49:23 -080029 use_version_lib: true,
30
Josh Gao27768452018-01-02 12:01:43 -080031 compile_multilib: "first",
32 product_variables: {
33 debuggable: {
34 cflags: [
35 "-DALLOW_ADBD_ROOT",
36 "-DALLOW_ADBD_DISABLE_VERITY",
37 "-DALLOW_ADBD_NO_AUTH",
38 ],
39 },
40 },
41
42 target: {
43 android: {
Josh Gao560a5472018-10-12 16:37:31 -070044 cflags: [
45 "-DADB_HOST=0",
46 "-Wthread-safety",
47 ],
Josh Gao27768452018-01-02 12:01:43 -080048 },
49
50 host: {
51 cflags: ["-DADB_HOST=1"],
52 },
53
54 darwin: {
55 host_ldlibs: [
56 "-lpthread",
57 "-framework CoreFoundation",
58 "-framework IOKit",
59 "-lobjc",
60 ],
61 },
62
63 windows: {
64 cflags: [
65 // Define windows.h and tchar.h Unicode preprocessor symbols so that
66 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
67 // build if you accidentally pass char*. Fix by calling like:
68 // std::wstring path_wide;
69 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
70 // CreateFileW(path_wide.c_str());
71 "-DUNICODE=1",
72 "-D_UNICODE=1",
73
Josh Gao2e1e7892018-03-23 13:03:28 -070074 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080075 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070076
77 // MinGW hides some things behind _POSIX_SOURCE.
78 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080079 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070080
81 host_ldlibs: [
82 "-lws2_32",
83 "-lgdi32",
84 "-luserenv",
85 ],
Josh Gao27768452018-01-02 12:01:43 -080086 },
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070087
88 not_windows: {
89 cflags: [
90 "-Wthread-safety",
91 ],
92 },
Josh Gao27768452018-01-02 12:01:43 -080093 },
94}
95
96// libadb
97// =========================================================
98// These files are compiled for both the host and the device.
99libadb_srcs = [
100 "adb.cpp",
101 "adb_io.cpp",
102 "adb_listeners.cpp",
103 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700104 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800105 "adb_utils.cpp",
106 "fdevent.cpp",
107 "services.cpp",
108 "sockets.cpp",
109 "socket_spec.cpp",
110 "sysdeps/errno.cpp",
111 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700112 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800113 "transport_local.cpp",
114 "transport_usb.cpp",
115]
116
117libadb_posix_srcs = [
118 "sysdeps_unix.cpp",
119 "sysdeps/posix/network.cpp",
120]
121
122libadb_test_srcs = [
123 "adb_io_test.cpp",
124 "adb_listeners_test.cpp",
125 "adb_utils_test.cpp",
126 "fdevent_test.cpp",
127 "socket_spec_test.cpp",
128 "socket_test.cpp",
129 "sysdeps_test.cpp",
130 "sysdeps/stat_test.cpp",
131 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700132 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800133]
134
135cc_library_host_static {
136 name: "libadb_host",
137 defaults: ["adb_defaults"],
138
139 srcs: libadb_srcs + [
140 "client/auth.cpp",
141 "client/usb_libusb.cpp",
142 "client/usb_dispatch.cpp",
143 "client/transport_mdns.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000144 "client/fastdeploy.cpp",
145 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800146 ],
147
Dan Willemsenab971b52018-08-29 14:58:02 -0700148 generated_headers: ["platform_tools_version"],
149
Josh Gao27768452018-01-02 12:01:43 -0800150 target: {
151 linux: {
152 srcs: ["client/usb_linux.cpp"],
153 },
154 darwin: {
155 srcs: ["client/usb_osx.cpp"],
156 },
157
158 not_windows: {
159 srcs: libadb_posix_srcs,
160 },
161 windows: {
162 enabled: true,
163 srcs: [
164 "client/usb_windows.cpp",
165 "sysdeps_win32.cpp",
166 "sysdeps/win32/errno.cpp",
167 "sysdeps/win32/stat.cpp",
168 ],
169 shared_libs: ["AdbWinApi"],
170 },
171 },
172
173 static_libs: [
174 "libbase",
175 "libcrypto_utils",
176 "libcrypto",
177 "libdiagnose_usb",
178 "libmdnssd",
179 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100180 "libandroidfw",
181 "libziparchive",
182 "libz",
183 "libutils",
184 "liblog",
185 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800186 ],
187}
188
189cc_test_host {
190 name: "adb_test",
191 defaults: ["adb_defaults"],
192 srcs: libadb_test_srcs,
193 static_libs: [
194 "libadb_host",
195 "libbase",
196 "libcutils",
197 "libcrypto_utils",
198 "libcrypto",
199 "libmdnssd",
200 "libdiagnose_usb",
201 "libusb",
202 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700203
204 target: {
205 windows: {
206 enabled: true,
207 shared_libs: ["AdbWinApi"],
208 },
209 },
Josh Gao27768452018-01-02 12:01:43 -0800210}
211
Josh Gao9c596492018-04-04 11:27:24 -0700212cc_benchmark {
213 name: "adb_benchmark",
214 defaults: ["adb_defaults"],
215
216 srcs: ["transport_benchmark.cpp"],
217 target: {
218 android: {
219 static_libs: [
220 "libadbd",
221 ],
222 },
223 host: {
224 static_libs: [
225 "libadb_host",
226 ],
227 },
228 },
229
230 static_libs: [
231 "libbase",
232 "libcutils",
233 "libcrypto_utils",
234 "libcrypto",
235 "libdiagnose_usb",
236 "liblog",
237 "libusb",
238 ],
239}
240
Josh Gao27768452018-01-02 12:01:43 -0800241cc_binary_host {
242 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800243
244 defaults: ["adb_defaults"],
245
246 srcs: [
247 "client/adb_client.cpp",
248 "client/bugreport.cpp",
249 "client/commandline.cpp",
250 "client/file_sync_client.cpp",
251 "client/main.cpp",
252 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000253 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800254 "client/line_printer.cpp",
255 "shell_service_protocol.cpp",
256 ],
257
258 static_libs: [
259 "libadb_host",
260 "libbase",
261 "libcutils",
262 "libcrypto_utils",
263 "libcrypto",
264 "libdiagnose_usb",
265 "liblog",
266 "libmdnssd",
267 "libusb",
Idries Hamadi269a4b42018-09-13 18:00:25 +0100268 "libandroidfw",
269 "libziparchive",
270 "libz",
271 "libutils",
272 "liblog",
273 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800274 ],
275
276 stl: "libc++_static",
277
278 // Don't add anything here, we don't want additional shared dependencies
279 // on the host adb tool, and shared libraries that link against libc++
280 // will violate ODR
281 shared_libs: [],
282
Idries Hamadi7575cd92018-08-24 11:46:45 +0100283 required: [
284 "deploypatchgenerator",
285 ],
286
Josh Gao27768452018-01-02 12:01:43 -0800287 target: {
288 darwin: {
289 cflags: [
290 "-Wno-sizeof-pointer-memaccess",
291 ],
292 },
293 windows: {
294 enabled: true,
295 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800296 shared_libs: ["AdbWinApi"],
297 required: [
298 "AdbWinUsbApi",
299 ],
300 },
301 },
302}
303
Tao Baoeca59ae2018-07-30 20:45:27 -0700304// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800305cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700306 name: "libadbd_core",
307 defaults: ["adb_defaults"],
308 recovery_available: true,
309
310 // libminadbd wants both, as it's used to build native tests.
311 compile_multilib: "both",
312
313 srcs: libadb_srcs + libadb_posix_srcs + [
314 "daemon/auth.cpp",
315 "daemon/jdwp_service.cpp",
Josh Gao613cbb42018-10-08 14:20:29 -0700316 "daemon/usb_ffs.cpp",
Josh Gao61e9e392018-10-08 14:42:19 -0700317 "daemon/usb_legacy.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700318 ],
319
320 local_include_dirs: [
321 "daemon/include",
322 ],
323
Dan Willemsenab971b52018-08-29 14:58:02 -0700324 generated_headers: ["platform_tools_version"],
325
Tao Baoeca59ae2018-07-30 20:45:27 -0700326 static_libs: [
327 "libdiagnose_usb",
328 "libqemu_pipe",
329 ],
330
331 shared_libs: [
332 "libasyncio",
333 "libbase",
334 "libcrypto",
335 "libcrypto_utils",
336 "libcutils",
337 "liblog",
338 ],
339}
340
341cc_library {
342 name: "libadbd_services",
343 defaults: ["adb_defaults"],
344 recovery_available: true,
345 compile_multilib: "both",
346
347 srcs: [
348 "daemon/file_sync_service.cpp",
349 "daemon/framebuffer_service.cpp",
350 "daemon/mdns.cpp",
351 "daemon/remount_service.cpp",
352 "daemon/services.cpp",
353 "daemon/set_verity_enable_state_service.cpp",
354 "daemon/shell_service.cpp",
355 "shell_service_protocol.cpp",
356 ],
357
358 cflags: [
359 "-D_GNU_SOURCE",
360 "-Wno-deprecated-declarations",
361 ],
362
363 static_libs: [
364 "libadbd_core",
365 "libavb_user",
366 "libdiagnose_usb",
367 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700368 ],
369
370 shared_libs: [
371 "libasyncio",
372 "libbase",
373 "libbootloader_message",
374 "libcrypto",
375 "libcrypto_utils",
376 "libcutils",
377 "libext4_utils",
378 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700379 "libfs_mgr",
380 "liblog",
381 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700382 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700383 ],
384}
385
386cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800387 name: "libadbd",
388 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900389 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800390
Tao Baoeca59ae2018-07-30 20:45:27 -0700391 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
392 use_version_lib: false,
393
394 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800395 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700396
397 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
398 whole_static_libs: [
399 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800400 ],
401
Tao Baoeca59ae2018-07-30 20:45:27 -0700402 shared_libs: [
403 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800404 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800405 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700406 "libcrypto",
407 "libcrypto_utils",
408 "libcutils",
409 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800410 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700411
412 export_include_dirs: [
413 "daemon/include",
414 ],
Josh Gao27768452018-01-02 12:01:43 -0800415}
416
417cc_binary {
418 name: "adbd",
419 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900420 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800421
Josh Gao27768452018-01-02 12:01:43 -0800422 srcs: [
423 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800424 ],
425
426 cflags: [
427 "-D_GNU_SOURCE",
428 "-Wno-deprecated-declarations",
429 ],
430
431 strip: {
432 keep_symbols: true,
433 },
434
Tao Baoeca59ae2018-07-30 20:45:27 -0700435 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800436 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700437 "libadbd_services",
438 "libbase",
439 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800440 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700441 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800442 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800443 "libminijail",
444 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800445 ],
446}
447
448cc_test {
449 name: "adbd_test",
450 defaults: ["adb_defaults"],
451 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700452 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800453 "daemon/shell_service.cpp",
454 "daemon/shell_service_test.cpp",
455 "shell_service_protocol.cpp",
456 "shell_service_protocol_test.cpp",
457 ],
458
459 static_libs: [
460 "libadbd",
461 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700462 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800463 "libcutils",
464 "libcrypto_utils",
465 "libcrypto",
466 "libdiagnose_usb",
467 "liblog",
468 "libusb",
469 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900470 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800471 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700472 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800473}
474
Julien Desprez75fea7e2018-08-08 12:08:50 -0700475python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800476 name: "adb_integration_test_adb",
477 main: "test_adb.py",
478 srcs: [
479 "test_adb.py",
480 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700481 test_config: "adb_integration_test_adb.xml",
482 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800483 version: {
484 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700485 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800486 },
487 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700488 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800489 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700490 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700491}
492
Julien Desprez618f0e12018-10-12 13:48:14 -0700493python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800494 name: "adb_integration_test_device",
495 main: "test_device.py",
496 srcs: [
497 "test_device.py",
498 ],
499 libs: [
500 "adb_py",
501 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700502 test_config: "adb_integration_test_device.xml",
503 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800504 version: {
505 py2: {
506 enabled: true,
507 },
508 py3: {
509 enabled: false,
510 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700511 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700512}