blob: a18dc1ab8d91827288a958e6ce99acca0f356e05 [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",
141 ],
142
143 target: {
144 linux: {
145 srcs: ["client/usb_linux.cpp"],
146 },
147 darwin: {
148 srcs: ["client/usb_osx.cpp"],
149 },
150
151 not_windows: {
152 srcs: libadb_posix_srcs,
153 },
154 windows: {
155 enabled: true,
156 srcs: [
157 "client/usb_windows.cpp",
158 "sysdeps_win32.cpp",
159 "sysdeps/win32/errno.cpp",
160 "sysdeps/win32/stat.cpp",
161 ],
162 shared_libs: ["AdbWinApi"],
163 },
164 },
165
166 static_libs: [
167 "libbase",
168 "libcrypto_utils",
169 "libcrypto",
170 "libdiagnose_usb",
171 "libmdnssd",
172 "libusb",
173 ],
174}
175
176cc_test_host {
177 name: "adb_test",
178 defaults: ["adb_defaults"],
179 srcs: libadb_test_srcs,
180 static_libs: [
181 "libadb_host",
182 "libbase",
183 "libcutils",
184 "libcrypto_utils",
185 "libcrypto",
186 "libmdnssd",
187 "libdiagnose_usb",
188 "libusb",
189 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700190
191 target: {
192 windows: {
193 enabled: true,
194 shared_libs: ["AdbWinApi"],
195 },
196 },
Josh Gao27768452018-01-02 12:01:43 -0800197}
198
Josh Gao9c596492018-04-04 11:27:24 -0700199cc_benchmark {
200 name: "adb_benchmark",
201 defaults: ["adb_defaults"],
202
203 srcs: ["transport_benchmark.cpp"],
204 target: {
205 android: {
206 static_libs: [
207 "libadbd",
208 ],
209 },
210 host: {
211 static_libs: [
212 "libadb_host",
213 ],
214 },
215 },
216
217 static_libs: [
218 "libbase",
219 "libcutils",
220 "libcrypto_utils",
221 "libcrypto",
222 "libdiagnose_usb",
223 "liblog",
224 "libusb",
225 ],
226}
227
Josh Gao27768452018-01-02 12:01:43 -0800228cc_binary_host {
229 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800230
231 defaults: ["adb_defaults"],
232
233 srcs: [
234 "client/adb_client.cpp",
235 "client/bugreport.cpp",
236 "client/commandline.cpp",
237 "client/file_sync_client.cpp",
238 "client/main.cpp",
239 "client/console.cpp",
240 "client/line_printer.cpp",
241 "shell_service_protocol.cpp",
242 ],
243
244 static_libs: [
245 "libadb_host",
246 "libbase",
247 "libcutils",
248 "libcrypto_utils",
249 "libcrypto",
250 "libdiagnose_usb",
251 "liblog",
252 "libmdnssd",
253 "libusb",
254 ],
255
256 stl: "libc++_static",
257
258 // Don't add anything here, we don't want additional shared dependencies
259 // on the host adb tool, and shared libraries that link against libc++
260 // will violate ODR
261 shared_libs: [],
262
263 target: {
264 darwin: {
265 cflags: [
266 "-Wno-sizeof-pointer-memaccess",
267 ],
268 },
269 windows: {
270 enabled: true,
271 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800272 shared_libs: ["AdbWinApi"],
273 required: [
274 "AdbWinUsbApi",
275 ],
276 },
277 },
278}
279
Tao Baoeca59ae2018-07-30 20:45:27 -0700280// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800281cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700282 name: "libadbd_core",
283 defaults: ["adb_defaults"],
284 recovery_available: true,
285
286 // libminadbd wants both, as it's used to build native tests.
287 compile_multilib: "both",
288
289 srcs: libadb_srcs + libadb_posix_srcs + [
290 "daemon/auth.cpp",
291 "daemon/jdwp_service.cpp",
292 "daemon/usb.cpp",
293 ],
294
295 local_include_dirs: [
296 "daemon/include",
297 ],
298
299 static_libs: [
300 "libdiagnose_usb",
301 "libqemu_pipe",
302 ],
303
304 shared_libs: [
305 "libasyncio",
306 "libbase",
307 "libcrypto",
308 "libcrypto_utils",
309 "libcutils",
310 "liblog",
311 ],
312}
313
314cc_library {
315 name: "libadbd_services",
316 defaults: ["adb_defaults"],
317 recovery_available: true,
318 compile_multilib: "both",
319
320 srcs: [
321 "daemon/file_sync_service.cpp",
322 "daemon/framebuffer_service.cpp",
323 "daemon/mdns.cpp",
324 "daemon/remount_service.cpp",
325 "daemon/services.cpp",
326 "daemon/set_verity_enable_state_service.cpp",
327 "daemon/shell_service.cpp",
328 "shell_service_protocol.cpp",
329 ],
330
331 cflags: [
332 "-D_GNU_SOURCE",
333 "-Wno-deprecated-declarations",
334 ],
335
336 static_libs: [
337 "libadbd_core",
338 "libavb_user",
339 "libdiagnose_usb",
340 "libqemu_pipe",
341
342 // `daemon/shell_service.cpp` uses selinux_android_setcon(), which is not exposed by
343 // libselinux.
344 "libselinux",
345 ],
346
347 shared_libs: [
348 "libasyncio",
349 "libbase",
350 "libbootloader_message",
351 "libcrypto",
352 "libcrypto_utils",
353 "libcutils",
354 "libext4_utils",
355 "libfec",
356 "libfec_rs",
357 "libfs_mgr",
358 "liblog",
359 "libmdnssd",
360 ],
361}
362
363cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800364 name: "libadbd",
365 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900366 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800367
Tao Baoeca59ae2018-07-30 20:45:27 -0700368 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
369 use_version_lib: false,
370
371 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800372 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700373
374 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
375 whole_static_libs: [
376 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800377 ],
378
Tao Baoeca59ae2018-07-30 20:45:27 -0700379 shared_libs: [
380 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800381 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800382 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700383 "libcrypto",
384 "libcrypto_utils",
385 "libcutils",
386 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800387 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700388
389 export_include_dirs: [
390 "daemon/include",
391 ],
Josh Gao27768452018-01-02 12:01:43 -0800392}
393
394cc_binary {
395 name: "adbd",
396 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900397 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800398
Josh Gao27768452018-01-02 12:01:43 -0800399 srcs: [
400 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800401 ],
402
403 cflags: [
404 "-D_GNU_SOURCE",
405 "-Wno-deprecated-declarations",
406 ],
407
408 strip: {
409 keep_symbols: true,
410 },
411
Tao Baoeca59ae2018-07-30 20:45:27 -0700412 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800413 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700414 "libadbd_services",
415 "libbase",
416 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800417 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700418 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800419 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800420 "libminijail",
421 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800422 ],
423}
424
425cc_test {
426 name: "adbd_test",
427 defaults: ["adb_defaults"],
428 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700429 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800430 "daemon/shell_service.cpp",
431 "daemon/shell_service_test.cpp",
432 "shell_service_protocol.cpp",
433 "shell_service_protocol_test.cpp",
434 ],
435
436 static_libs: [
437 "libadbd",
438 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700439 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800440 "libcutils",
441 "libcrypto_utils",
442 "libcrypto",
443 "libdiagnose_usb",
444 "liblog",
445 "libusb",
446 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900447 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800448 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700449 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800450}
451
Julien Desprez75fea7e2018-08-08 12:08:50 -0700452python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800453 name: "adb_integration_test_adb",
454 main: "test_adb.py",
455 srcs: [
456 "test_adb.py",
457 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700458 test_config: "adb_integration_test_adb.xml",
459 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800460 version: {
461 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700462 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800463 },
464 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700465 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800466 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700467 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700468}
469
470python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800471 name: "adb_integration_test_device",
472 main: "test_device.py",
473 srcs: [
474 "test_device.py",
475 ],
476 libs: [
477 "adb_py",
478 ],
479 version: {
480 py2: {
481 enabled: true,
482 },
483 py3: {
484 enabled: false,
485 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700486 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700487}