blob: 3c2eb0ab1992ed8bb581d7b703dafb51c2b743d1 [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",
22 "-Wno-unused-parameter",
23 "-Wno-missing-field-initializers",
24 "-Wvla",
25 ],
26 rtti: true,
27
28 clang_cflags: [
29 "-Wexit-time-destructors",
30 "-Wthread-safety",
31 ],
32
Josh Gaoc7567fa2018-02-27 15:49:23 -080033 use_version_lib: true,
34
Josh Gao27768452018-01-02 12:01:43 -080035 compile_multilib: "first",
36 product_variables: {
37 debuggable: {
38 cflags: [
39 "-DALLOW_ADBD_ROOT",
40 "-DALLOW_ADBD_DISABLE_VERITY",
41 "-DALLOW_ADBD_NO_AUTH",
42 ],
43 },
44 },
45
46 target: {
47 android: {
48 cflags: ["-DADB_HOST=0"],
49 },
50
51 host: {
52 cflags: ["-DADB_HOST=1"],
53 },
54
55 darwin: {
56 host_ldlibs: [
57 "-lpthread",
58 "-framework CoreFoundation",
59 "-framework IOKit",
60 "-lobjc",
61 ],
62 },
63
64 windows: {
65 cflags: [
66 // Define windows.h and tchar.h Unicode preprocessor symbols so that
67 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
68 // build if you accidentally pass char*. Fix by calling like:
69 // std::wstring path_wide;
70 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
71 // CreateFileW(path_wide.c_str());
72 "-DUNICODE=1",
73 "-D_UNICODE=1",
74
Josh Gao2e1e7892018-03-23 13:03:28 -070075 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao27768452018-01-02 12:01:43 -080076 "-D_GNU_SOURCE",
Josh Gao2e1e7892018-03-23 13:03:28 -070077
78 // MinGW hides some things behind _POSIX_SOURCE.
79 "-D_POSIX_SOURCE",
Josh Gao27768452018-01-02 12:01:43 -080080 ],
Josh Gaof8a97c12018-03-23 15:37:20 -070081
82 host_ldlibs: [
83 "-lws2_32",
84 "-lgdi32",
85 "-luserenv",
86 ],
Josh Gao27768452018-01-02 12:01:43 -080087 },
88 },
89}
90
91// libadb
92// =========================================================
93// These files are compiled for both the host and the device.
94libadb_srcs = [
95 "adb.cpp",
96 "adb_io.cpp",
97 "adb_listeners.cpp",
98 "adb_trace.cpp",
Josh Gao6e1246c2018-05-24 22:54:50 -070099 "adb_unique_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800100 "adb_utils.cpp",
101 "fdevent.cpp",
102 "services.cpp",
103 "sockets.cpp",
104 "socket_spec.cpp",
105 "sysdeps/errno.cpp",
106 "transport.cpp",
Josh Gao6082e7d2018-04-05 16:16:04 -0700107 "transport_fd.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800108 "transport_local.cpp",
109 "transport_usb.cpp",
110]
111
112libadb_posix_srcs = [
113 "sysdeps_unix.cpp",
114 "sysdeps/posix/network.cpp",
115]
116
117libadb_test_srcs = [
118 "adb_io_test.cpp",
119 "adb_listeners_test.cpp",
120 "adb_utils_test.cpp",
121 "fdevent_test.cpp",
122 "socket_spec_test.cpp",
123 "socket_test.cpp",
124 "sysdeps_test.cpp",
125 "sysdeps/stat_test.cpp",
126 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700127 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800128]
129
130cc_library_host_static {
131 name: "libadb_host",
132 defaults: ["adb_defaults"],
133
134 srcs: libadb_srcs + [
135 "client/auth.cpp",
136 "client/usb_libusb.cpp",
137 "client/usb_dispatch.cpp",
138 "client/transport_mdns.cpp",
139 ],
140
141 target: {
142 linux: {
143 srcs: ["client/usb_linux.cpp"],
144 },
145 darwin: {
146 srcs: ["client/usb_osx.cpp"],
147 },
148
149 not_windows: {
150 srcs: libadb_posix_srcs,
151 },
152 windows: {
153 enabled: true,
154 srcs: [
155 "client/usb_windows.cpp",
156 "sysdeps_win32.cpp",
157 "sysdeps/win32/errno.cpp",
158 "sysdeps/win32/stat.cpp",
159 ],
160 shared_libs: ["AdbWinApi"],
161 },
162 },
163
164 static_libs: [
165 "libbase",
166 "libcrypto_utils",
167 "libcrypto",
168 "libdiagnose_usb",
169 "libmdnssd",
170 "libusb",
171 ],
172}
173
174cc_test_host {
175 name: "adb_test",
176 defaults: ["adb_defaults"],
177 srcs: libadb_test_srcs,
178 static_libs: [
179 "libadb_host",
180 "libbase",
181 "libcutils",
182 "libcrypto_utils",
183 "libcrypto",
184 "libmdnssd",
185 "libdiagnose_usb",
186 "libusb",
187 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700188
189 target: {
190 windows: {
191 enabled: true,
192 shared_libs: ["AdbWinApi"],
193 },
194 },
Josh Gao27768452018-01-02 12:01:43 -0800195}
196
Josh Gao9c596492018-04-04 11:27:24 -0700197cc_benchmark {
198 name: "adb_benchmark",
199 defaults: ["adb_defaults"],
200
201 srcs: ["transport_benchmark.cpp"],
202 target: {
203 android: {
204 static_libs: [
205 "libadbd",
206 ],
207 },
208 host: {
209 static_libs: [
210 "libadb_host",
211 ],
212 },
213 },
214
215 static_libs: [
216 "libbase",
217 "libcutils",
218 "libcrypto_utils",
219 "libcrypto",
220 "libdiagnose_usb",
221 "liblog",
222 "libusb",
223 ],
224}
225
Josh Gao27768452018-01-02 12:01:43 -0800226cc_binary_host {
227 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800228
229 defaults: ["adb_defaults"],
230
231 srcs: [
232 "client/adb_client.cpp",
233 "client/bugreport.cpp",
234 "client/commandline.cpp",
235 "client/file_sync_client.cpp",
236 "client/main.cpp",
237 "client/console.cpp",
238 "client/line_printer.cpp",
239 "shell_service_protocol.cpp",
240 ],
241
242 static_libs: [
243 "libadb_host",
244 "libbase",
245 "libcutils",
246 "libcrypto_utils",
247 "libcrypto",
248 "libdiagnose_usb",
249 "liblog",
250 "libmdnssd",
251 "libusb",
252 ],
253
254 stl: "libc++_static",
255
256 // Don't add anything here, we don't want additional shared dependencies
257 // on the host adb tool, and shared libraries that link against libc++
258 // will violate ODR
259 shared_libs: [],
260
261 target: {
262 darwin: {
263 cflags: [
264 "-Wno-sizeof-pointer-memaccess",
265 ],
266 },
267 windows: {
268 enabled: true,
269 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800270 shared_libs: ["AdbWinApi"],
271 required: [
272 "AdbWinUsbApi",
273 ],
274 },
275 },
276}
277
278cc_library_static {
279 name: "libadbd",
280 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900281 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800282
283 // libminadbd wants both, for some reason.
284 compile_multilib: "both",
285 srcs: libadb_srcs + libadb_posix_srcs + [
286 "daemon/auth.cpp",
287 "daemon/usb.cpp",
288 "daemon/jdwp_service.cpp",
289 ],
290
291 static_libs: [
292 "libasyncio",
293 "libbootloader_message",
294 "libcrypto_utils",
295 "libcrypto",
296 "libdiagnose_usb",
297 "libqemu_pipe",
298 "libbase",
299 ],
300}
301
302cc_binary {
303 name: "adbd",
304 defaults: ["adb_defaults"],
305
Josh Gao8db99f82018-03-06 12:57:27 -0800306 // adbd must be static, as it is copied into the recovery image.
307 static_executable: true,
Jiyong Parka0e75042018-05-24 14:11:00 +0900308 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800309
Josh Gao27768452018-01-02 12:01:43 -0800310 srcs: [
311 "daemon/main.cpp",
312 "daemon/mdns.cpp",
313 "daemon/file_sync_service.cpp",
314 "daemon/framebuffer_service.cpp",
315 "daemon/remount_service.cpp",
316 "daemon/set_verity_enable_state_service.cpp",
317 "daemon/shell_service.cpp",
318 "shell_service_protocol.cpp",
319 ],
320
321 cflags: [
322 "-D_GNU_SOURCE",
323 "-Wno-deprecated-declarations",
324 ],
325
326 strip: {
327 keep_symbols: true,
328 },
329
330 static_libs: [
331 "libadbd",
332 "libasyncio",
333 "libavb_user",
334 "libbootloader_message",
335 "libcrypto_utils",
336 "libcrypto",
337 "libdiagnose_usb",
338 "libfec",
339 "libfec_rs",
340 "libfs_mgr",
341 "liblog",
342 "libext4_utils",
343 "libmdnssd",
344 "libminijail",
345 "libselinux",
346 "libsquashfs_utils",
347 "libqemu_pipe",
348 "libdebuggerd_handler",
349
350 "libbase",
351 "libcutils",
352 ],
353}
354
355cc_test {
356 name: "adbd_test",
357 defaults: ["adb_defaults"],
358 srcs: libadb_test_srcs + [
359 "daemon/shell_service.cpp",
360 "daemon/shell_service_test.cpp",
361 "shell_service_protocol.cpp",
362 "shell_service_protocol_test.cpp",
363 ],
364
365 static_libs: [
366 "libadbd",
367 "libbase",
368 "libcutils",
369 "libcrypto_utils",
370 "libcrypto",
371 "libdiagnose_usb",
372 "liblog",
373 "libusb",
374 "libmdnssd",
375 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700376 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800377}
378
GuangHui Liu41bda342017-05-10 14:37:17 -0700379python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800380 name: "adb_integration_test_adb",
381 main: "test_adb.py",
382 srcs: [
383 "test_adb.py",
384 ],
385 libs: [
386 "adb_py",
387 ],
388 version: {
389 py2: {
390 enabled: true,
391 },
392 py3: {
393 enabled: false,
394 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700395 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700396}
397
398python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800399 name: "adb_integration_test_device",
400 main: "test_device.py",
401 srcs: [
402 "test_device.py",
403 ],
404 libs: [
405 "adb_py",
406 ],
407 version: {
408 py2: {
409 enabled: true,
410 },
411 py3: {
412 enabled: false,
413 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700414 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700415}