blob: 53bf7e34a0e3ac77aeedf2a935793e5aa42b7472 [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",
107 "transport_local.cpp",
108 "transport_usb.cpp",
109]
110
111libadb_posix_srcs = [
112 "sysdeps_unix.cpp",
113 "sysdeps/posix/network.cpp",
114]
115
116libadb_test_srcs = [
117 "adb_io_test.cpp",
118 "adb_listeners_test.cpp",
119 "adb_utils_test.cpp",
120 "fdevent_test.cpp",
121 "socket_spec_test.cpp",
122 "socket_test.cpp",
123 "sysdeps_test.cpp",
124 "sysdeps/stat_test.cpp",
125 "transport_test.cpp",
Josh Gao7c738cd2018-04-03 14:37:11 -0700126 "types_test.cpp",
Josh Gao27768452018-01-02 12:01:43 -0800127]
128
129cc_library_host_static {
130 name: "libadb_host",
131 defaults: ["adb_defaults"],
132
133 srcs: libadb_srcs + [
134 "client/auth.cpp",
135 "client/usb_libusb.cpp",
136 "client/usb_dispatch.cpp",
137 "client/transport_mdns.cpp",
138 ],
139
140 target: {
141 linux: {
142 srcs: ["client/usb_linux.cpp"],
143 },
144 darwin: {
145 srcs: ["client/usb_osx.cpp"],
146 },
147
148 not_windows: {
149 srcs: libadb_posix_srcs,
150 },
151 windows: {
152 enabled: true,
153 srcs: [
154 "client/usb_windows.cpp",
155 "sysdeps_win32.cpp",
156 "sysdeps/win32/errno.cpp",
157 "sysdeps/win32/stat.cpp",
158 ],
159 shared_libs: ["AdbWinApi"],
160 },
161 },
162
163 static_libs: [
164 "libbase",
165 "libcrypto_utils",
166 "libcrypto",
167 "libdiagnose_usb",
168 "libmdnssd",
169 "libusb",
170 ],
171}
172
173cc_test_host {
174 name: "adb_test",
175 defaults: ["adb_defaults"],
176 srcs: libadb_test_srcs,
177 static_libs: [
178 "libadb_host",
179 "libbase",
180 "libcutils",
181 "libcrypto_utils",
182 "libcrypto",
183 "libmdnssd",
184 "libdiagnose_usb",
185 "libusb",
186 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700187
188 target: {
189 windows: {
190 enabled: true,
191 shared_libs: ["AdbWinApi"],
192 },
193 },
Josh Gao27768452018-01-02 12:01:43 -0800194}
195
Josh Gao9c596492018-04-04 11:27:24 -0700196cc_benchmark {
197 name: "adb_benchmark",
198 defaults: ["adb_defaults"],
199
200 srcs: ["transport_benchmark.cpp"],
201 target: {
202 android: {
203 static_libs: [
204 "libadbd",
205 ],
206 },
207 host: {
208 static_libs: [
209 "libadb_host",
210 ],
211 },
212 },
213
214 static_libs: [
215 "libbase",
216 "libcutils",
217 "libcrypto_utils",
218 "libcrypto",
219 "libdiagnose_usb",
220 "liblog",
221 "libusb",
222 ],
223}
224
Josh Gao27768452018-01-02 12:01:43 -0800225cc_binary_host {
226 name: "adb",
Josh Gao27768452018-01-02 12:01:43 -0800227
228 defaults: ["adb_defaults"],
229
230 srcs: [
231 "client/adb_client.cpp",
232 "client/bugreport.cpp",
233 "client/commandline.cpp",
234 "client/file_sync_client.cpp",
235 "client/main.cpp",
236 "client/console.cpp",
237 "client/line_printer.cpp",
238 "shell_service_protocol.cpp",
239 ],
240
241 static_libs: [
242 "libadb_host",
243 "libbase",
244 "libcutils",
245 "libcrypto_utils",
246 "libcrypto",
247 "libdiagnose_usb",
248 "liblog",
249 "libmdnssd",
250 "libusb",
251 ],
252
253 stl: "libc++_static",
254
255 // Don't add anything here, we don't want additional shared dependencies
256 // on the host adb tool, and shared libraries that link against libc++
257 // will violate ODR
258 shared_libs: [],
259
260 target: {
261 darwin: {
262 cflags: [
263 "-Wno-sizeof-pointer-memaccess",
264 ],
265 },
266 windows: {
267 enabled: true,
268 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800269 shared_libs: ["AdbWinApi"],
270 required: [
271 "AdbWinUsbApi",
272 ],
273 },
274 },
275}
276
277cc_library_static {
278 name: "libadbd",
279 defaults: ["adb_defaults"],
Jiyong Parka0e75042018-05-24 14:11:00 +0900280 recovery_available: true,
Josh Gao27768452018-01-02 12:01:43 -0800281
282 // libminadbd wants both, for some reason.
283 compile_multilib: "both",
284 srcs: libadb_srcs + libadb_posix_srcs + [
285 "daemon/auth.cpp",
286 "daemon/usb.cpp",
287 "daemon/jdwp_service.cpp",
288 ],
289
290 static_libs: [
291 "libasyncio",
292 "libbootloader_message",
293 "libcrypto_utils",
294 "libcrypto",
295 "libdiagnose_usb",
296 "libqemu_pipe",
297 "libbase",
298 ],
299}
300
301cc_binary {
302 name: "adbd",
303 defaults: ["adb_defaults"],
304
Jiyong Parka0e75042018-05-24 14:11:00 +0900305 recovery_available: true,
Josh Gao8db99f82018-03-06 12:57:27 -0800306
Josh Gao27768452018-01-02 12:01:43 -0800307 srcs: [
308 "daemon/main.cpp",
309 "daemon/mdns.cpp",
310 "daemon/file_sync_service.cpp",
311 "daemon/framebuffer_service.cpp",
312 "daemon/remount_service.cpp",
313 "daemon/set_verity_enable_state_service.cpp",
314 "daemon/shell_service.cpp",
315 "shell_service_protocol.cpp",
316 ],
317
318 cflags: [
319 "-D_GNU_SOURCE",
320 "-Wno-deprecated-declarations",
321 ],
322
323 strip: {
324 keep_symbols: true,
325 },
326
327 static_libs: [
328 "libadbd",
329 "libasyncio",
330 "libavb_user",
331 "libbootloader_message",
332 "libcrypto_utils",
333 "libcrypto",
334 "libdiagnose_usb",
335 "libfec",
336 "libfec_rs",
337 "libfs_mgr",
338 "liblog",
339 "libext4_utils",
340 "libmdnssd",
341 "libminijail",
342 "libselinux",
343 "libsquashfs_utils",
344 "libqemu_pipe",
Josh Gao27768452018-01-02 12:01:43 -0800345
346 "libbase",
347 "libcutils",
348 ],
349}
350
351cc_test {
352 name: "adbd_test",
353 defaults: ["adb_defaults"],
354 srcs: libadb_test_srcs + [
355 "daemon/shell_service.cpp",
356 "daemon/shell_service_test.cpp",
357 "shell_service_protocol.cpp",
358 "shell_service_protocol_test.cpp",
359 ],
360
361 static_libs: [
362 "libadbd",
363 "libbase",
364 "libcutils",
365 "libcrypto_utils",
366 "libcrypto",
367 "libdiagnose_usb",
368 "liblog",
369 "libusb",
370 "libmdnssd",
Jiyong Park011ee122018-05-29 16:41:30 +0900371 "libselinux",
Josh Gao27768452018-01-02 12:01:43 -0800372 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700373 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800374}
375
GuangHui Liu41bda342017-05-10 14:37:17 -0700376python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800377 name: "adb_integration_test_adb",
378 main: "test_adb.py",
379 srcs: [
380 "test_adb.py",
381 ],
382 libs: [
383 "adb_py",
384 ],
385 version: {
386 py2: {
387 enabled: true,
388 },
389 py3: {
390 enabled: false,
391 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700392 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700393}
394
395python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800396 name: "adb_integration_test_device",
397 main: "test_device.py",
398 srcs: [
399 "test_device.py",
400 ],
401 libs: [
402 "adb_py",
403 ],
404 version: {
405 py2: {
406 enabled: true,
407 },
408 py3: {
409 enabled: false,
410 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700411 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700412}