blob: e994075d90e825482142c7a8863b550dcc7a9006 [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
Dan Willemsen3f439a72018-11-19 19:11:35 -0800288 // Archive adb, adb.exe.
289 dist: {
290 targets: [
291 "dist_files",
292 "sdk",
293 "win_sdk",
294 ],
295 },
296
Josh Gao27768452018-01-02 12:01:43 -0800297 target: {
298 darwin: {
299 cflags: [
300 "-Wno-sizeof-pointer-memaccess",
301 ],
302 },
303 windows: {
304 enabled: true,
305 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800306 shared_libs: ["AdbWinApi"],
307 required: [
308 "AdbWinUsbApi",
309 ],
310 },
311 },
312}
313
Tao Baoeca59ae2018-07-30 20:45:27 -0700314// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800315cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700316 name: "libadbd_core",
317 defaults: ["adb_defaults"],
318 recovery_available: true,
319
320 // libminadbd wants both, as it's used to build native tests.
321 compile_multilib: "both",
322
323 srcs: libadb_srcs + libadb_posix_srcs + [
324 "daemon/auth.cpp",
325 "daemon/jdwp_service.cpp",
Josh Gaoc51726c2018-10-11 16:33:05 -0700326 "daemon/usb.cpp",
Josh Gao613cbb42018-10-08 14:20:29 -0700327 "daemon/usb_ffs.cpp",
Josh Gao61e9e392018-10-08 14:42:19 -0700328 "daemon/usb_legacy.cpp",
Tao Baoeca59ae2018-07-30 20:45:27 -0700329 ],
330
331 local_include_dirs: [
332 "daemon/include",
333 ],
334
Dan Willemsenab971b52018-08-29 14:58:02 -0700335 generated_headers: ["platform_tools_version"],
336
Tao Baoeca59ae2018-07-30 20:45:27 -0700337 static_libs: [
338 "libdiagnose_usb",
339 "libqemu_pipe",
340 ],
341
342 shared_libs: [
343 "libasyncio",
344 "libbase",
345 "libcrypto",
346 "libcrypto_utils",
347 "libcutils",
348 "liblog",
349 ],
350}
351
352cc_library {
353 name: "libadbd_services",
354 defaults: ["adb_defaults"],
355 recovery_available: true,
356 compile_multilib: "both",
357
358 srcs: [
359 "daemon/file_sync_service.cpp",
360 "daemon/framebuffer_service.cpp",
361 "daemon/mdns.cpp",
362 "daemon/remount_service.cpp",
363 "daemon/services.cpp",
364 "daemon/set_verity_enable_state_service.cpp",
365 "daemon/shell_service.cpp",
366 "shell_service_protocol.cpp",
367 ],
368
369 cflags: [
370 "-D_GNU_SOURCE",
371 "-Wno-deprecated-declarations",
372 ],
373
374 static_libs: [
375 "libadbd_core",
376 "libavb_user",
377 "libdiagnose_usb",
378 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700379 ],
380
381 shared_libs: [
382 "libasyncio",
383 "libbase",
384 "libbootloader_message",
385 "libcrypto",
386 "libcrypto_utils",
387 "libcutils",
388 "libext4_utils",
389 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700390 "libfs_mgr",
391 "liblog",
392 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700393 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700394 ],
395}
396
397cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800398 name: "libadbd",
399 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900400 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800401
Tao Baoeca59ae2018-07-30 20:45:27 -0700402 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
403 use_version_lib: false,
404
405 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800406 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700407
408 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
409 whole_static_libs: [
410 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800411 ],
412
Tao Baoeca59ae2018-07-30 20:45:27 -0700413 shared_libs: [
414 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800415 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800416 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700417 "libcrypto",
418 "libcrypto_utils",
419 "libcutils",
420 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800421 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700422
423 export_include_dirs: [
424 "daemon/include",
425 ],
Josh Gao27768452018-01-02 12:01:43 -0800426}
427
428cc_binary {
429 name: "adbd",
430 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900431 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800432
Josh Gao27768452018-01-02 12:01:43 -0800433 srcs: [
434 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800435 ],
436
437 cflags: [
438 "-D_GNU_SOURCE",
439 "-Wno-deprecated-declarations",
440 ],
441
442 strip: {
443 keep_symbols: true,
444 },
445
Tao Baoeca59ae2018-07-30 20:45:27 -0700446 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800447 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700448 "libadbd_services",
449 "libbase",
450 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800451 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700452 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800453 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800454 "libminijail",
455 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800456 ],
457}
458
459cc_test {
460 name: "adbd_test",
461 defaults: ["adb_defaults"],
462 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700463 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800464 "daemon/shell_service.cpp",
465 "daemon/shell_service_test.cpp",
466 "shell_service_protocol.cpp",
467 "shell_service_protocol_test.cpp",
468 ],
469
470 static_libs: [
471 "libadbd",
472 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700473 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800474 "libcutils",
475 "libcrypto_utils",
476 "libcrypto",
477 "libdiagnose_usb",
478 "liblog",
479 "libusb",
480 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900481 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800482 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700483 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800484}
485
Julien Desprez75fea7e2018-08-08 12:08:50 -0700486python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800487 name: "adb_integration_test_adb",
488 main: "test_adb.py",
489 srcs: [
490 "test_adb.py",
491 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700492 test_config: "adb_integration_test_adb.xml",
493 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800494 version: {
495 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700496 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800497 },
498 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700499 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800500 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700501 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700502}
503
Julien Desprez618f0e12018-10-12 13:48:14 -0700504python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800505 name: "adb_integration_test_device",
506 main: "test_device.py",
507 srcs: [
508 "test_device.py",
509 ],
510 libs: [
511 "adb_py",
512 ],
Julien Desprez618f0e12018-10-12 13:48:14 -0700513 test_config: "adb_integration_test_device.xml",
514 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800515 version: {
516 py2: {
517 enabled: true,
518 },
519 py3: {
520 enabled: false,
521 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700522 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700523}