blob: 7f82ca6c22732d4fde18f51c334b37c1f7ba9078 [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 Gaoffc11d32018-09-20 17:38:14 -070027 cpp_std: "gnu++17",
Josh Gao27768452018-01-02 12:01:43 -080028 rtti: true,
29
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: {
45 cflags: ["-DADB_HOST=0"],
46 },
47
48 host: {
49 cflags: ["-DADB_HOST=1"],
50 },
51
52 darwin: {
53 host_ldlibs: [
54 "-lpthread",
55 "-framework CoreFoundation",
56 "-framework IOKit",
57 "-lobjc",
58 ],
59 },
60
61 windows: {
62 cflags: [
63 // Define windows.h and tchar.h Unicode preprocessor symbols so that
64 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
65 // build if you accidentally pass char*. Fix by calling like:
66 // std::wstring path_wide;
67 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
68 // CreateFileW(path_wide.c_str());
69 "-DUNICODE=1",
70 "-D_UNICODE=1",
71
Josh Gao2e1e7892018-03-23 13:03:28 -070072 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080073 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070074
75 // MinGW hides some things behind _POSIX_SOURCE.
76 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080077 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070078
79 host_ldlibs: [
80 "-lws2_32",
81 "-lgdi32",
82 "-luserenv",
83 ],
Josh Gao27768452018-01-02 12:01:43 -080084 },
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070085
86 not_windows: {
87 cflags: [
88 "-Wthread-safety",
89 ],
90 },
Josh Gao27768452018-01-02 12:01:43 -080091 },
92}
93
94// libadb
95// =========================================================
96// These files are compiled for both the host and the device.
97libadb_srcs = [
98 "adb.cpp",
99 "adb_io.cpp",
100 "adb_listeners.cpp",
101 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700102 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800103 "adb_utils.cpp",
104 "fdevent.cpp",
105 "services.cpp",
106 "sockets.cpp",
107 "socket_spec.cpp",
108 "sysdeps/errno.cpp",
109 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700110 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800111 "transport_local.cpp",
112 "transport_usb.cpp",
113]
114
115libadb_posix_srcs = [
116 "sysdeps_unix.cpp",
117 "sysdeps/posix/network.cpp",
118]
119
120libadb_test_srcs = [
121 "adb_io_test.cpp",
122 "adb_listeners_test.cpp",
123 "adb_utils_test.cpp",
124 "fdevent_test.cpp",
125 "socket_spec_test.cpp",
126 "socket_test.cpp",
127 "sysdeps_test.cpp",
128 "sysdeps/stat_test.cpp",
129 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700130 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800131]
132
133cc_library_host_static {
134 name: "libadb_host",
135 defaults: ["adb_defaults"],
136
137 srcs: libadb_srcs + [
138 "client/auth.cpp",
139 "client/usb_libusb.cpp",
140 "client/usb_dispatch.cpp",
141 "client/transport_mdns.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000142 "client/fastdeploy.cpp",
143 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800144 ],
145
Dan Willemsenab971b52018-08-29 14:58:02 -0700146 generated_headers: ["platform_tools_version"],
147
Josh Gao27768452018-01-02 12:01:43 -0800148 target: {
149 linux: {
150 srcs: ["client/usb_linux.cpp"],
151 },
152 darwin: {
153 srcs: ["client/usb_osx.cpp"],
154 },
155
156 not_windows: {
157 srcs: libadb_posix_srcs,
158 },
159 windows: {
160 enabled: true,
161 srcs: [
162 "client/usb_windows.cpp",
163 "sysdeps_win32.cpp",
164 "sysdeps/win32/errno.cpp",
165 "sysdeps/win32/stat.cpp",
166 ],
167 shared_libs: ["AdbWinApi"],
168 },
169 },
170
171 static_libs: [
172 "libbase",
173 "libcrypto_utils",
174 "libcrypto",
175 "libdiagnose_usb",
176 "libmdnssd",
177 "libusb",
178 ],
179}
180
181cc_test_host {
182 name: "adb_test",
183 defaults: ["adb_defaults"],
184 srcs: libadb_test_srcs,
185 static_libs: [
186 "libadb_host",
187 "libbase",
188 "libcutils",
189 "libcrypto_utils",
190 "libcrypto",
191 "libmdnssd",
192 "libdiagnose_usb",
193 "libusb",
194 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700195
196 target: {
197 windows: {
198 enabled: true,
199 shared_libs: ["AdbWinApi"],
200 },
201 },
Josh Gao27768452018-01-02 12:01:43 -0800202}
203
Josh Gao9c596492018-04-04 11:27:24 -0700204cc_benchmark {
205 name: "adb_benchmark",
206 defaults: ["adb_defaults"],
207
208 srcs: ["transport_benchmark.cpp"],
209 target: {
210 android: {
211 static_libs: [
212 "libadbd",
213 ],
214 },
215 host: {
216 static_libs: [
217 "libadb_host",
218 ],
219 },
220 },
221
222 static_libs: [
223 "libbase",
224 "libcutils",
225 "libcrypto_utils",
226 "libcrypto",
227 "libdiagnose_usb",
228 "liblog",
229 "libusb",
230 ],
231}
232
Josh Gao27768452018-01-02 12:01:43 -0800233cc_binary_host {
234 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800235
236 defaults: ["adb_defaults"],
237
238 srcs: [
239 "client/adb_client.cpp",
240 "client/bugreport.cpp",
241 "client/commandline.cpp",
242 "client/file_sync_client.cpp",
243 "client/main.cpp",
244 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000245 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800246 "client/line_printer.cpp",
247 "shell_service_protocol.cpp",
248 ],
249
250 static_libs: [
251 "libadb_host",
252 "libbase",
253 "libcutils",
254 "libcrypto_utils",
255 "libcrypto",
256 "libdiagnose_usb",
257 "liblog",
258 "libmdnssd",
259 "libusb",
260 ],
261
262 stl: "libc++_static",
263
264 // Don't add anything here, we don't want additional shared dependencies
265 // on the host adb tool, and shared libraries that link against libc++
266 // will violate ODR
267 shared_libs: [],
268
Idries Hamadi7575cd92018-08-24 11:46:45 +0100269 required: [
270 "deploypatchgenerator",
271 ],
272
Josh Gao27768452018-01-02 12:01:43 -0800273 target: {
274 darwin: {
275 cflags: [
276 "-Wno-sizeof-pointer-memaccess",
277 ],
278 },
279 windows: {
280 enabled: true,
281 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800282 shared_libs: ["AdbWinApi"],
283 required: [
284 "AdbWinUsbApi",
285 ],
286 },
287 },
288}
289
Tao Baoeca59ae2018-07-30 20:45:27 -0700290// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800291cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700292 name: "libadbd_core",
293 defaults: ["adb_defaults"],
294 recovery_available: true,
295
296 // libminadbd wants both, as it's used to build native tests.
297 compile_multilib: "both",
298
299 srcs: libadb_srcs + libadb_posix_srcs + [
300 "daemon/auth.cpp",
301 "daemon/jdwp_service.cpp",
302 "daemon/usb.cpp",
303 ],
304
305 local_include_dirs: [
306 "daemon/include",
307 ],
308
Dan Willemsenab971b52018-08-29 14:58:02 -0700309 generated_headers: ["platform_tools_version"],
310
Tao Baoeca59ae2018-07-30 20:45:27 -0700311 static_libs: [
312 "libdiagnose_usb",
313 "libqemu_pipe",
314 ],
315
316 shared_libs: [
317 "libasyncio",
318 "libbase",
319 "libcrypto",
320 "libcrypto_utils",
321 "libcutils",
322 "liblog",
323 ],
324}
325
326cc_library {
327 name: "libadbd_services",
328 defaults: ["adb_defaults"],
329 recovery_available: true,
330 compile_multilib: "both",
331
332 srcs: [
333 "daemon/file_sync_service.cpp",
334 "daemon/framebuffer_service.cpp",
335 "daemon/mdns.cpp",
336 "daemon/remount_service.cpp",
337 "daemon/services.cpp",
338 "daemon/set_verity_enable_state_service.cpp",
339 "daemon/shell_service.cpp",
340 "shell_service_protocol.cpp",
341 ],
342
343 cflags: [
344 "-D_GNU_SOURCE",
345 "-Wno-deprecated-declarations",
346 ],
347
348 static_libs: [
349 "libadbd_core",
350 "libavb_user",
351 "libdiagnose_usb",
352 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700353 ],
354
355 shared_libs: [
356 "libasyncio",
357 "libbase",
358 "libbootloader_message",
359 "libcrypto",
360 "libcrypto_utils",
361 "libcutils",
362 "libext4_utils",
363 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700364 "libfs_mgr",
365 "liblog",
366 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700367 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700368 ],
369}
370
371cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800372 name: "libadbd",
373 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900374 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800375
Tao Baoeca59ae2018-07-30 20:45:27 -0700376 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
377 use_version_lib: false,
378
379 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800380 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700381
382 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
383 whole_static_libs: [
384 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800385 ],
386
Tao Baoeca59ae2018-07-30 20:45:27 -0700387 shared_libs: [
388 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800389 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800390 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700391 "libcrypto",
392 "libcrypto_utils",
393 "libcutils",
394 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800395 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700396
397 export_include_dirs: [
398 "daemon/include",
399 ],
Josh Gao27768452018-01-02 12:01:43 -0800400}
401
402cc_binary {
403 name: "adbd",
404 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900405 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800406
Josh Gao27768452018-01-02 12:01:43 -0800407 srcs: [
408 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800409 ],
410
411 cflags: [
412 "-D_GNU_SOURCE",
413 "-Wno-deprecated-declarations",
414 ],
415
416 strip: {
417 keep_symbols: true,
418 },
419
Tao Baoeca59ae2018-07-30 20:45:27 -0700420 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800421 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700422 "libadbd_services",
423 "libbase",
424 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800425 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700426 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800427 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800428 "libminijail",
429 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800430 ],
431}
432
433cc_test {
434 name: "adbd_test",
435 defaults: ["adb_defaults"],
436 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700437 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800438 "daemon/shell_service.cpp",
439 "daemon/shell_service_test.cpp",
440 "shell_service_protocol.cpp",
441 "shell_service_protocol_test.cpp",
442 ],
443
444 static_libs: [
445 "libadbd",
446 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700447 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800448 "libcutils",
449 "libcrypto_utils",
450 "libcrypto",
451 "libdiagnose_usb",
452 "liblog",
453 "libusb",
454 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900455 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800456 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700457 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800458}
459
Julien Desprez75fea7e2018-08-08 12:08:50 -0700460python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800461 name: "adb_integration_test_adb",
462 main: "test_adb.py",
463 srcs: [
464 "test_adb.py",
465 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700466 test_config: "adb_integration_test_adb.xml",
467 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800468 version: {
469 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700470 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800471 },
472 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700473 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800474 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700475 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700476}
477
478python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800479 name: "adb_integration_test_device",
480 main: "test_device.py",
481 srcs: [
482 "test_device.py",
483 ],
484 libs: [
485 "adb_py",
486 ],
487 version: {
488 py2: {
489 enabled: true,
490 },
491 py3: {
492 enabled: false,
493 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700494 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700495}