blob: 3685687ab70e8915447472cf18054b11cf479af8 [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: {
44 cflags: ["-DADB_HOST=0"],
45 },
46
47 host: {
48 cflags: ["-DADB_HOST=1"],
49 },
50
51 darwin: {
52 host_ldlibs: [
53 "-lpthread",
54 "-framework CoreFoundation",
55 "-framework IOKit",
56 "-lobjc",
57 ],
58 },
59
60 windows: {
61 cflags: [
62 // Define windows.h and tchar.h Unicode preprocessor symbols so that
63 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
64 // build if you accidentally pass char*. Fix by calling like:
65 // std::wstring path_wide;
66 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
67 // CreateFileW(path_wide.c_str());
68 "-DUNICODE=1",
69 "-D_UNICODE=1",
70
Josh Gao2e1e7892018-03-23 13:03:28 -070071 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080072 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070073
74 // MinGW hides some things behind _POSIX_SOURCE.
75 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080076 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070077
78 host_ldlibs: [
79 "-lws2_32",
80 "-lgdi32",
81 "-luserenv",
82 ],
Josh Gao27768452018-01-02 12:01:43 -080083 },
Pirama Arumuga Nainar79821782018-06-01 11:31:38 -070084
85 not_windows: {
86 cflags: [
87 "-Wthread-safety",
88 ],
89 },
Josh Gao27768452018-01-02 12:01:43 -080090 },
91}
92
93// libadb
94// =========================================================
95// These files are compiled for both the host and the device.
96libadb_srcs = [
97 "adb.cpp",
98 "adb_io.cpp",
99 "adb_listeners.cpp",
100 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -0700101 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800102 "adb_utils.cpp",
103 "fdevent.cpp",
104 "services.cpp",
105 "sockets.cpp",
106 "socket_spec.cpp",
107 "sysdeps/errno.cpp",
108 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700109 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800110 "transport_local.cpp",
111 "transport_usb.cpp",
112]
113
114libadb_posix_srcs = [
115 "sysdeps_unix.cpp",
116 "sysdeps/posix/network.cpp",
117]
118
119libadb_test_srcs = [
120 "adb_io_test.cpp",
121 "adb_listeners_test.cpp",
122 "adb_utils_test.cpp",
123 "fdevent_test.cpp",
124 "socket_spec_test.cpp",
125 "socket_test.cpp",
126 "sysdeps_test.cpp",
127 "sysdeps/stat_test.cpp",
128 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700129 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800130]
131
132cc_library_host_static {
133 name: "libadb_host",
134 defaults: ["adb_defaults"],
135
136 srcs: libadb_srcs + [
137 "client/auth.cpp",
138 "client/usb_libusb.cpp",
139 "client/usb_dispatch.cpp",
140 "client/transport_mdns.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000141 "client/fastdeploy.cpp",
142 "client/fastdeploycallbacks.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800143 ],
144
145 target: {
146 linux: {
147 srcs: ["client/usb_linux.cpp"],
148 },
149 darwin: {
150 srcs: ["client/usb_osx.cpp"],
151 },
152
153 not_windows: {
154 srcs: libadb_posix_srcs,
155 },
156 windows: {
157 enabled: true,
158 srcs: [
159 "client/usb_windows.cpp",
160 "sysdeps_win32.cpp",
161 "sysdeps/win32/errno.cpp",
162 "sysdeps/win32/stat.cpp",
163 ],
164 shared_libs: ["AdbWinApi"],
165 },
166 },
167
168 static_libs: [
169 "libbase",
170 "libcrypto_utils",
171 "libcrypto",
172 "libdiagnose_usb",
173 "libmdnssd",
174 "libusb",
Idries Hamadied409ea2018-01-29 16:30:36 +0000175 "libandroidfw",
176 "libziparchive",
177 "libz",
178 "libutils",
179 "liblog",
180 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800181 ],
182}
183
184cc_test_host {
185 name: "adb_test",
186 defaults: ["adb_defaults"],
187 srcs: libadb_test_srcs,
188 static_libs: [
189 "libadb_host",
190 "libbase",
191 "libcutils",
192 "libcrypto_utils",
193 "libcrypto",
194 "libmdnssd",
195 "libdiagnose_usb",
196 "libusb",
197 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700198
199 target: {
200 windows: {
201 enabled: true,
202 shared_libs: ["AdbWinApi"],
203 },
204 },
Josh Gao27768452018-01-02 12:01:43 -0800205}
206
Josh Gao9c596492018-04-04 11:27:24 -0700207cc_benchmark {
208 name: "adb_benchmark",
209 defaults: ["adb_defaults"],
210
211 srcs: ["transport_benchmark.cpp"],
212 target: {
213 android: {
214 static_libs: [
215 "libadbd",
216 ],
217 },
218 host: {
219 static_libs: [
220 "libadb_host",
221 ],
222 },
223 },
224
225 static_libs: [
226 "libbase",
227 "libcutils",
228 "libcrypto_utils",
229 "libcrypto",
230 "libdiagnose_usb",
231 "liblog",
232 "libusb",
233 ],
234}
235
Josh Gao27768452018-01-02 12:01:43 -0800236cc_binary_host {
237 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800238
239 defaults: ["adb_defaults"],
240
241 srcs: [
242 "client/adb_client.cpp",
243 "client/bugreport.cpp",
244 "client/commandline.cpp",
245 "client/file_sync_client.cpp",
246 "client/main.cpp",
247 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000248 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800249 "client/line_printer.cpp",
250 "shell_service_protocol.cpp",
251 ],
252
253 static_libs: [
254 "libadb_host",
255 "libbase",
256 "libcutils",
257 "libcrypto_utils",
258 "libcrypto",
259 "libdiagnose_usb",
260 "liblog",
261 "libmdnssd",
262 "libusb",
Idries Hamadied409ea2018-01-29 16:30:36 +0000263 "libandroidfw",
264 "libziparchive",
265 "libz",
266 "libutils",
267 "liblog",
268 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800269 ],
270
271 stl: "libc++_static",
272
273 // Don't add anything here, we don't want additional shared dependencies
274 // on the host adb tool, and shared libraries that link against libc++
275 // will violate ODR
276 shared_libs: [],
277
278 target: {
279 darwin: {
280 cflags: [
281 "-Wno-sizeof-pointer-memaccess",
282 ],
283 },
284 windows: {
285 enabled: true,
286 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800287 shared_libs: ["AdbWinApi"],
288 required: [
289 "AdbWinUsbApi",
290 ],
291 },
292 },
293}
294
Tao Baoeca59ae2018-07-30 20:45:27 -0700295// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800296cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700297 name: "libadbd_core",
298 defaults: ["adb_defaults"],
299 recovery_available: true,
300
301 // libminadbd wants both, as it's used to build native tests.
302 compile_multilib: "both",
303
304 srcs: libadb_srcs + libadb_posix_srcs + [
305 "daemon/auth.cpp",
306 "daemon/jdwp_service.cpp",
307 "daemon/usb.cpp",
308 ],
309
310 local_include_dirs: [
311 "daemon/include",
312 ],
313
314 static_libs: [
315 "libdiagnose_usb",
316 "libqemu_pipe",
317 ],
318
319 shared_libs: [
320 "libasyncio",
321 "libbase",
322 "libcrypto",
323 "libcrypto_utils",
324 "libcutils",
325 "liblog",
326 ],
327}
328
329cc_library {
330 name: "libadbd_services",
331 defaults: ["adb_defaults"],
332 recovery_available: true,
333 compile_multilib: "both",
334
335 srcs: [
336 "daemon/file_sync_service.cpp",
337 "daemon/framebuffer_service.cpp",
338 "daemon/mdns.cpp",
339 "daemon/remount_service.cpp",
340 "daemon/services.cpp",
341 "daemon/set_verity_enable_state_service.cpp",
342 "daemon/shell_service.cpp",
343 "shell_service_protocol.cpp",
344 ],
345
346 cflags: [
347 "-D_GNU_SOURCE",
348 "-Wno-deprecated-declarations",
349 ],
350
351 static_libs: [
352 "libadbd_core",
353 "libavb_user",
354 "libdiagnose_usb",
355 "libqemu_pipe",
356
357 // `daemon/shell_service.cpp` uses selinux_android_setcon(), which is not exposed by
358 // libselinux.
359 "libselinux",
360 ],
361
362 shared_libs: [
363 "libasyncio",
364 "libbase",
365 "libbootloader_message",
366 "libcrypto",
367 "libcrypto_utils",
368 "libcutils",
369 "libext4_utils",
370 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700371 "libfs_mgr",
372 "liblog",
373 "libmdnssd",
374 ],
375}
376
377cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800378 name: "libadbd",
379 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900380 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800381
Tao Baoeca59ae2018-07-30 20:45:27 -0700382 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
383 use_version_lib: false,
384
385 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800386 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700387
388 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
389 whole_static_libs: [
390 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800391 ],
392
Tao Baoeca59ae2018-07-30 20:45:27 -0700393 shared_libs: [
394 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800395 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800396 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700397 "libcrypto",
398 "libcrypto_utils",
399 "libcutils",
400 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800401 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700402
403 export_include_dirs: [
404 "daemon/include",
405 ],
Josh Gao27768452018-01-02 12:01:43 -0800406}
407
408cc_binary {
409 name: "adbd",
410 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900411 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800412
Josh Gao27768452018-01-02 12:01:43 -0800413 srcs: [
414 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800415 ],
416
417 cflags: [
418 "-D_GNU_SOURCE",
419 "-Wno-deprecated-declarations",
420 ],
421
422 strip: {
423 keep_symbols: true,
424 },
425
Tao Baoeca59ae2018-07-30 20:45:27 -0700426 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800427 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700428 "libadbd_services",
429 "libbase",
430 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800431 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700432 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800433 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800434 "libminijail",
435 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800436 ],
437}
438
439cc_test {
440 name: "adbd_test",
441 defaults: ["adb_defaults"],
442 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700443 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800444 "daemon/shell_service.cpp",
445 "daemon/shell_service_test.cpp",
446 "shell_service_protocol.cpp",
447 "shell_service_protocol_test.cpp",
448 ],
449
450 static_libs: [
451 "libadbd",
452 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700453 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800454 "libcutils",
455 "libcrypto_utils",
456 "libcrypto",
457 "libdiagnose_usb",
458 "liblog",
459 "libusb",
460 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900461 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800462 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700463 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800464}
465
Julien Desprez75fea7e2018-08-08 12:08:50 -0700466python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800467 name: "adb_integration_test_adb",
468 main: "test_adb.py",
469 srcs: [
470 "test_adb.py",
471 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700472 test_config: "adb_integration_test_adb.xml",
473 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800474 version: {
475 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700476 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800477 },
478 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700479 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800480 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700481 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700482}
483
484python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800485 name: "adb_integration_test_device",
486 main: "test_device.py",
487 srcs: [
488 "test_device.py",
489 ],
490 libs: [
491 "adb_py",
492 ],
493 version: {
494 py2: {
495 enabled: true,
496 },
497 py3: {
498 enabled: false,
499 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700500 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700501}