blob: bccc71a4eabaad23900fbc6df71006146fd5fec3 [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
Dan Willemsenab971b52018-08-29 14:58:02 -0700145 generated_headers: ["platform_tools_version"],
146
Josh Gao27768452018-01-02 12:01:43 -0800147 target: {
148 linux: {
149 srcs: ["client/usb_linux.cpp"],
150 },
151 darwin: {
152 srcs: ["client/usb_osx.cpp"],
153 },
154
155 not_windows: {
156 srcs: libadb_posix_srcs,
157 },
158 windows: {
159 enabled: true,
160 srcs: [
161 "client/usb_windows.cpp",
162 "sysdeps_win32.cpp",
163 "sysdeps/win32/errno.cpp",
164 "sysdeps/win32/stat.cpp",
165 ],
166 shared_libs: ["AdbWinApi"],
167 },
168 },
169
170 static_libs: [
171 "libbase",
172 "libcrypto_utils",
173 "libcrypto",
174 "libdiagnose_usb",
175 "libmdnssd",
176 "libusb",
177 ],
178}
179
180cc_test_host {
181 name: "adb_test",
182 defaults: ["adb_defaults"],
183 srcs: libadb_test_srcs,
184 static_libs: [
185 "libadb_host",
186 "libbase",
187 "libcutils",
188 "libcrypto_utils",
189 "libcrypto",
190 "libmdnssd",
191 "libdiagnose_usb",
192 "libusb",
193 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700194
195 target: {
196 windows: {
197 enabled: true,
198 shared_libs: ["AdbWinApi"],
199 },
200 },
Josh Gao27768452018-01-02 12:01:43 -0800201}
202
Josh Gao9c596492018-04-04 11:27:24 -0700203cc_benchmark {
204 name: "adb_benchmark",
205 defaults: ["adb_defaults"],
206
207 srcs: ["transport_benchmark.cpp"],
208 target: {
209 android: {
210 static_libs: [
211 "libadbd",
212 ],
213 },
214 host: {
215 static_libs: [
216 "libadb_host",
217 ],
218 },
219 },
220
221 static_libs: [
222 "libbase",
223 "libcutils",
224 "libcrypto_utils",
225 "libcrypto",
226 "libdiagnose_usb",
227 "liblog",
228 "libusb",
229 ],
230}
231
Josh Gao27768452018-01-02 12:01:43 -0800232cc_binary_host {
233 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800234
235 defaults: ["adb_defaults"],
236
237 srcs: [
238 "client/adb_client.cpp",
239 "client/bugreport.cpp",
240 "client/commandline.cpp",
241 "client/file_sync_client.cpp",
242 "client/main.cpp",
243 "client/console.cpp",
Idries Hamadied409ea2018-01-29 16:30:36 +0000244 "client/adb_install.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800245 "client/line_printer.cpp",
246 "shell_service_protocol.cpp",
247 ],
248
249 static_libs: [
250 "libadb_host",
251 "libbase",
252 "libcutils",
253 "libcrypto_utils",
254 "libcrypto",
255 "libdiagnose_usb",
256 "liblog",
257 "libmdnssd",
258 "libusb",
259 ],
260
261 stl: "libc++_static",
262
263 // Don't add anything here, we don't want additional shared dependencies
264 // on the host adb tool, and shared libraries that link against libc++
265 // will violate ODR
266 shared_libs: [],
267
Idries Hamadi7575cd92018-08-24 11:46:45 +0100268 required: [
269 "deploypatchgenerator",
270 ],
271
Josh Gao27768452018-01-02 12:01:43 -0800272 target: {
273 darwin: {
274 cflags: [
275 "-Wno-sizeof-pointer-memaccess",
276 ],
277 },
278 windows: {
279 enabled: true,
280 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800281 shared_libs: ["AdbWinApi"],
282 required: [
283 "AdbWinUsbApi",
284 ],
285 },
286 },
287}
288
Tao Baoeca59ae2018-07-30 20:45:27 -0700289// libadbd_core contains the common sources to build libadbd and libadbd_services.
Josh Gao27768452018-01-02 12:01:43 -0800290cc_library_static {
Tao Baoeca59ae2018-07-30 20:45:27 -0700291 name: "libadbd_core",
292 defaults: ["adb_defaults"],
293 recovery_available: true,
294
295 // libminadbd wants both, as it's used to build native tests.
296 compile_multilib: "both",
297
298 srcs: libadb_srcs + libadb_posix_srcs + [
299 "daemon/auth.cpp",
300 "daemon/jdwp_service.cpp",
301 "daemon/usb.cpp",
302 ],
303
304 local_include_dirs: [
305 "daemon/include",
306 ],
307
Dan Willemsenab971b52018-08-29 14:58:02 -0700308 generated_headers: ["platform_tools_version"],
309
Tao Baoeca59ae2018-07-30 20:45:27 -0700310 static_libs: [
311 "libdiagnose_usb",
312 "libqemu_pipe",
313 ],
314
315 shared_libs: [
316 "libasyncio",
317 "libbase",
318 "libcrypto",
319 "libcrypto_utils",
320 "libcutils",
321 "liblog",
322 ],
323}
324
325cc_library {
326 name: "libadbd_services",
327 defaults: ["adb_defaults"],
328 recovery_available: true,
329 compile_multilib: "both",
330
331 srcs: [
332 "daemon/file_sync_service.cpp",
333 "daemon/framebuffer_service.cpp",
334 "daemon/mdns.cpp",
335 "daemon/remount_service.cpp",
336 "daemon/services.cpp",
337 "daemon/set_verity_enable_state_service.cpp",
338 "daemon/shell_service.cpp",
339 "shell_service_protocol.cpp",
340 ],
341
342 cflags: [
343 "-D_GNU_SOURCE",
344 "-Wno-deprecated-declarations",
345 ],
346
347 static_libs: [
348 "libadbd_core",
349 "libavb_user",
350 "libdiagnose_usb",
351 "libqemu_pipe",
Tao Baoeca59ae2018-07-30 20:45:27 -0700352 ],
353
354 shared_libs: [
355 "libasyncio",
356 "libbase",
357 "libbootloader_message",
358 "libcrypto",
359 "libcrypto_utils",
360 "libcutils",
361 "libext4_utils",
362 "libfec",
Tao Baoeca59ae2018-07-30 20:45:27 -0700363 "libfs_mgr",
364 "liblog",
365 "libmdnssd",
Peter Collingbournefc037372018-09-13 14:20:28 -0700366 "libselinux",
Tao Baoeca59ae2018-07-30 20:45:27 -0700367 ],
368}
369
370cc_library {
Josh Gao27768452018-01-02 12:01:43 -0800371 name: "libadbd",
372 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900373 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800374
Tao Baoeca59ae2018-07-30 20:45:27 -0700375 // Avoid getting duplicate symbol of android::build::GetBuildNumber().
376 use_version_lib: false,
377
378 // libminadbd wants both, as it's used to build native tests.
Josh Gao27768452018-01-02 12:01:43 -0800379 compile_multilib: "both",
Tao Baoeca59ae2018-07-30 20:45:27 -0700380
381 // libadbd doesn't build any additional source, but to expose libadbd_core as a shared library.
382 whole_static_libs: [
383 "libadbd_core",
Josh Gao27768452018-01-02 12:01:43 -0800384 ],
385
Tao Baoeca59ae2018-07-30 20:45:27 -0700386 shared_libs: [
387 "libadbd_services",
Josh Gao27768452018-01-02 12:01:43 -0800388 "libasyncio",
Josh Gao27768452018-01-02 12:01:43 -0800389 "libbase",
Tao Baoeca59ae2018-07-30 20:45:27 -0700390 "libcrypto",
391 "libcrypto_utils",
392 "libcutils",
393 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800394 ],
Jerry Zhangb156c602018-05-07 15:14:47 -0700395
396 export_include_dirs: [
397 "daemon/include",
398 ],
Josh Gao27768452018-01-02 12:01:43 -0800399}
400
401cc_binary {
402 name: "adbd",
403 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900404 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800405
Josh Gao27768452018-01-02 12:01:43 -0800406 srcs: [
407 "daemon/main.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800408 ],
409
410 cflags: [
411 "-D_GNU_SOURCE",
412 "-Wno-deprecated-declarations",
413 ],
414
415 strip: {
416 keep_symbols: true,
417 },
418
Tao Baoeca59ae2018-07-30 20:45:27 -0700419 shared_libs: [
Josh Gao27768452018-01-02 12:01:43 -0800420 "libadbd",
Tao Baoeca59ae2018-07-30 20:45:27 -0700421 "libadbd_services",
422 "libbase",
423 "libcap",
Josh Gao27768452018-01-02 12:01:43 -0800424 "libcrypto",
Tao Baoeca59ae2018-07-30 20:45:27 -0700425 "libcutils",
Josh Gao27768452018-01-02 12:01:43 -0800426 "liblog",
Josh Gao27768452018-01-02 12:01:43 -0800427 "libminijail",
428 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800429 ],
430}
431
432cc_test {
433 name: "adbd_test",
434 defaults: ["adb_defaults"],
435 srcs: libadb_test_srcs + [
Josh Gao997cfac2018-07-25 18:15:52 -0700436 "daemon/services.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800437 "daemon/shell_service.cpp",
438 "daemon/shell_service_test.cpp",
439 "shell_service_protocol.cpp",
440 "shell_service_protocol_test.cpp",
441 ],
442
443 static_libs: [
444 "libadbd",
445 "libbase",
Josh Gao997cfac2018-07-25 18:15:52 -0700446 "libbootloader_message",
Josh Gao27768452018-01-02 12:01:43 -0800447 "libcutils",
448 "libcrypto_utils",
449 "libcrypto",
450 "libdiagnose_usb",
451 "liblog",
452 "libusb",
453 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900454 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800455 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700456 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800457}
458
Julien Desprez75fea7e2018-08-08 12:08:50 -0700459python_test_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800460 name: "adb_integration_test_adb",
461 main: "test_adb.py",
462 srcs: [
463 "test_adb.py",
464 ],
Julien Desprez75fea7e2018-08-08 12:08:50 -0700465 test_config: "adb_integration_test_adb.xml",
466 test_suites: ["general-tests"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800467 version: {
468 py2: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700469 enabled: false,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800470 },
471 py3: {
Josh Gao9b6522b2018-08-07 14:31:17 -0700472 enabled: true,
Elliott Hughesdc699a22018-02-16 17:58:14 -0800473 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700474 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700475}
476
477python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800478 name: "adb_integration_test_device",
479 main: "test_device.py",
480 srcs: [
481 "test_device.py",
482 ],
483 libs: [
484 "adb_py",
485 ],
486 version: {
487 py2: {
488 enabled: true,
489 },
490 py3: {
491 enabled: false,
492 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700493 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700494}