blob: 91006b262d7e70c139a341e78187b47ed7ffc4c5 [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",
180 ],
181}
182
183cc_test_host {
184 name: "adb_test",
185 defaults: ["adb_defaults"],
186 srcs: libadb_test_srcs,
187 static_libs: [
188 "libadb_host",
189 "libbase",
190 "libcutils",
191 "libcrypto_utils",
192 "libcrypto",
193 "libmdnssd",
194 "libdiagnose_usb",
195 "libusb",
196 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700197
198 target: {
199 windows: {
200 enabled: true,
201 shared_libs: ["AdbWinApi"],
202 },
203 },
Josh Gao27768452018-01-02 12:01:43 -0800204}
205
Josh Gao9c596492018-04-04 11:27:24 -0700206cc_benchmark {
207 name: "adb_benchmark",
208 defaults: ["adb_defaults"],
209
210 srcs: ["transport_benchmark.cpp"],
211 target: {
212 android: {
213 static_libs: [
214 "libadbd",
215 ],
216 },
217 host: {
218 static_libs: [
219 "libadb_host",
220 ],
221 },
222 },
223
224 static_libs: [
225 "libbase",
226 "libcutils",
227 "libcrypto_utils",
228 "libcrypto",
229 "libdiagnose_usb",
230 "liblog",
231 "libusb",
232 ],
233}
234
Josh Gao27768452018-01-02 12:01:43 -0800235cc_binary_host {
236 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800237
238 defaults: ["adb_defaults"],
239
240 srcs: [
241 "client/adb_client.cpp",
242 "client/bugreport.cpp",
243 "client/commandline.cpp",
244 "client/file_sync_client.cpp",
245 "client/main.cpp",
246 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000247 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800248 "client/line_printer.cpp",
249 "shell_service_protocol.cpp",
250 ],
251
252 static_libs: [
253 "libadb_host",
254 "libbase",
255 "libcutils",
256 "libcrypto_utils",
257 "libcrypto",
258 "libdiagnose_usb",
259 "liblog",
260 "libmdnssd",
261 "libusb",
262 ],
263
264 stl: "libc++_static",
265
266 // Don't add anything here, we don't want additional shared dependencies
267 // on the host adb tool, and shared libraries that link against libc++
268 // will violate ODR
269 shared_libs: [],
270
Idries Hamadi7575cd92018-08-24 11:46:45 +0100271 required: [
272 "deploypatchgenerator",
273 ],
274
Josh Gao27768452018-01-02 12:01:43 -0800275 target: {
276 darwin: {
277 cflags: [
278 "-Wno-sizeof-pointer-memaccess",
279 ],
280 },
281 windows: {
282 enabled: true,
283 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800284 shared_libs: ["AdbWinApi"],
285 required: [
286 "AdbWinUsbApi",
287 ],
288 },
289 },
290}
291
Tao Baoeca59ae2018-07-30 20:45:27 -0700292// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800293cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700294 name: "libadbd_core",
295 defaults: ["adb_defaults"],
296 recovery_available: true,
297
298 // libminadbd wants both, as it's used to build native tests.
299 compile_multilib: "both",
300
301 srcs: libadb_srcs + libadb_posix_srcs + [
302 "daemon/auth.cpp",
303 "daemon/jdwp_service.cpp",
304 "daemon/usb.cpp",
305 ],
306
307 local_include_dirs: [
308 "daemon/include",
309 ],
310
Dan Willemsenab971b52018-08-29 14:58:02 -0700311 generated_headers: ["platform_tools_version"],
312
Tao Baoeca59ae2018-07-30 20:45:27 -0700313 static_libs: [
314 "libdiagnose_usb",
315 "libqemu_pipe",
316 ],
317
318 shared_libs: [
319 "libasyncio",
320 "libbase",
321 "libcrypto",
322 "libcrypto_utils",
323 "libcutils",
324 "liblog",
325 ],
326}
327
328cc_library {
329 name: "libadbd_services",
330 defaults: ["adb_defaults"],
331 recovery_available: true,
332 compile_multilib: "both",
333
334 srcs: [
335 "daemon/file_sync_service.cpp",
336 "daemon/framebuffer_service.cpp",
337 "daemon/mdns.cpp",
338 "daemon/remount_service.cpp",
339 "daemon/services.cpp",
340 "daemon/set_verity_enable_state_service.cpp",
341 "daemon/shell_service.cpp",
342 "shell_service_protocol.cpp",
343 ],
344
345 cflags: [
346 "-D_GNU_SOURCE",
347 "-Wno-deprecated-declarations",
348 ],
349
350 static_libs: [
351 "libadbd_core",
352 "libavb_user",
353 "libdiagnose_usb",
354 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700355 ],
356
357 shared_libs: [
358 "libasyncio",
359 "libbase",
360 "libbootloader_message",
361 "libcrypto",
362 "libcrypto_utils",
363 "libcutils",
364 "libext4_utils",
365 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700366 "libfs_mgr",
367 "liblog",
368 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700369 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700370 ],
371}
372
373cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800374 name: "libadbd",
375 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900376 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800377
Tao Baoeca59ae2018-07-30 20:45:27 -0700378 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
379 use_version_lib: false,
380
381 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800382 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700383
384 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
385 whole_static_libs: [
386 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800387 ],
388
Tao Baoeca59ae2018-07-30 20:45:27 -0700389 shared_libs: [
390 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800391 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800392 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700393 "libcrypto",
394 "libcrypto_utils",
395 "libcutils",
396 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800397 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700398
399 export_include_dirs: [
400 "daemon/include",
401 ],
Josh Gao27768452018-01-02 12:01:43 -0800402}
403
404cc_binary {
405 name: "adbd",
406 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900407 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800408
Josh Gao27768452018-01-02 12:01:43 -0800409 srcs: [
410 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800411 ],
412
413 cflags: [
414 "-D_GNU_SOURCE",
415 "-Wno-deprecated-declarations",
416 ],
417
418 strip: {
419 keep_symbols: true,
420 },
421
Tao Baoeca59ae2018-07-30 20:45:27 -0700422 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800423 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700424 "libadbd_services",
425 "libbase",
426 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800427 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700428 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800429 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800430 "libminijail",
431 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800432 ],
433}
434
435cc_test {
436 name: "adbd_test",
437 defaults: ["adb_defaults"],
438 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700439 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800440 "daemon/shell_service.cpp",
441 "daemon/shell_service_test.cpp",
442 "shell_service_protocol.cpp",
443 "shell_service_protocol_test.cpp",
444 ],
445
446 static_libs: [
447 "libadbd",
448 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700449 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800450 "libcutils",
451 "libcrypto_utils",
452 "libcrypto",
453 "libdiagnose_usb",
454 "liblog",
455 "libusb",
456 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900457 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800458 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700459 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800460}
461
Julien Desprez75fea7e2018-08-08 12:08:50 -0700462python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800463 name: "adb_integration_test_adb",
464 main: "test_adb.py",
465 srcs: [
466 "test_adb.py",
467 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700468 test_config: "adb_integration_test_adb.xml",
469 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800470 version: {
471 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700472 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800473 },
474 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700475 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800476 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700477 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700478}
479
480python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800481 name: "adb_integration_test_device",
482 main: "test_device.py",
483 srcs: [
484 "test_device.py",
485 ],
486 libs: [
487 "adb_py",
488 ],
489 version: {
490 py2: {
491 enabled: true,
492 },
493 py3: {
494 enabled: false,
495 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700496 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700497}