blob: b9a15966ec594e3da50fef2139f14c0a82154750 [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",
99 "adb_utils.cpp",
100 "fdevent.cpp",
101 "services.cpp",
102 "sockets.cpp",
103 "socket_spec.cpp",
104 "sysdeps/errno.cpp",
105 "transport.cpp",
106 "transport_local.cpp",
107 "transport_usb.cpp",
108]
109
110libadb_posix_srcs = [
111 "sysdeps_unix.cpp",
112 "sysdeps/posix/network.cpp",
113]
114
115libadb_test_srcs = [
116 "adb_io_test.cpp",
117 "adb_listeners_test.cpp",
118 "adb_utils_test.cpp",
119 "fdevent_test.cpp",
120 "socket_spec_test.cpp",
121 "socket_test.cpp",
122 "sysdeps_test.cpp",
123 "sysdeps/stat_test.cpp",
124 "transport_test.cpp",
125]
126
127cc_library_host_static {
128 name: "libadb_host",
129 defaults: ["adb_defaults"],
130
131 srcs: libadb_srcs + [
132 "client/auth.cpp",
133 "client/usb_libusb.cpp",
134 "client/usb_dispatch.cpp",
135 "client/transport_mdns.cpp",
136 ],
137
138 target: {
139 linux: {
140 srcs: ["client/usb_linux.cpp"],
141 },
142 darwin: {
143 srcs: ["client/usb_osx.cpp"],
144 },
145
146 not_windows: {
147 srcs: libadb_posix_srcs,
148 },
149 windows: {
150 enabled: true,
151 srcs: [
152 "client/usb_windows.cpp",
153 "sysdeps_win32.cpp",
154 "sysdeps/win32/errno.cpp",
155 "sysdeps/win32/stat.cpp",
156 ],
157 shared_libs: ["AdbWinApi"],
158 },
159 },
160
161 static_libs: [
162 "libbase",
163 "libcrypto_utils",
164 "libcrypto",
165 "libdiagnose_usb",
166 "libmdnssd",
167 "libusb",
168 ],
169}
170
171cc_test_host {
172 name: "adb_test",
173 defaults: ["adb_defaults"],
174 srcs: libadb_test_srcs,
175 static_libs: [
176 "libadb_host",
177 "libbase",
178 "libcutils",
179 "libcrypto_utils",
180 "libcrypto",
181 "libmdnssd",
182 "libdiagnose_usb",
183 "libusb",
184 ],
Josh Gaof8a97c12018-03-23 15:37:20 -0700185
186 target: {
187 windows: {
188 enabled: true,
189 shared_libs: ["AdbWinApi"],
190 },
191 },
Josh Gao27768452018-01-02 12:01:43 -0800192}
193
Josh Gao9c596492018-04-04 11:27:24 -0700194cc_benchmark {
195 name: "adb_benchmark",
196 defaults: ["adb_defaults"],
197
198 srcs: ["transport_benchmark.cpp"],
199 target: {
200 android: {
201 static_libs: [
202 "libadbd",
203 ],
204 },
205 host: {
206 static_libs: [
207 "libadb_host",
208 ],
209 },
210 },
211
212 static_libs: [
213 "libbase",
214 "libcutils",
215 "libcrypto_utils",
216 "libcrypto",
217 "libdiagnose_usb",
218 "liblog",
219 "libusb",
220 ],
221}
222
Josh Gao27768452018-01-02 12:01:43 -0800223cc_binary_host {
224 name: "adb",
225 tags: ["debug"],
226
227 defaults: ["adb_defaults"],
228
229 srcs: [
230 "client/adb_client.cpp",
231 "client/bugreport.cpp",
232 "client/commandline.cpp",
233 "client/file_sync_client.cpp",
234 "client/main.cpp",
235 "client/console.cpp",
236 "client/line_printer.cpp",
237 "shell_service_protocol.cpp",
238 ],
239
240 static_libs: [
241 "libadb_host",
242 "libbase",
243 "libcutils",
244 "libcrypto_utils",
245 "libcrypto",
246 "libdiagnose_usb",
247 "liblog",
248 "libmdnssd",
249 "libusb",
250 ],
251
252 stl: "libc++_static",
253
254 // Don't add anything here, we don't want additional shared dependencies
255 // on the host adb tool, and shared libraries that link against libc++
256 // will violate ODR
257 shared_libs: [],
258
259 target: {
260 darwin: {
261 cflags: [
262 "-Wno-sizeof-pointer-memaccess",
263 ],
264 },
265 windows: {
266 enabled: true,
267 ldflags: ["-municode"],
Josh Gao27768452018-01-02 12:01:43 -0800268 shared_libs: ["AdbWinApi"],
269 required: [
270 "AdbWinUsbApi",
271 ],
272 },
273 },
274}
275
276cc_library_static {
277 name: "libadbd",
278 defaults: ["adb_defaults"],
279
280 // libminadbd wants both, for some reason.
281 compile_multilib: "both",
282 srcs: libadb_srcs + libadb_posix_srcs + [
283 "daemon/auth.cpp",
284 "daemon/usb.cpp",
285 "daemon/jdwp_service.cpp",
286 ],
287
288 static_libs: [
289 "libasyncio",
290 "libbootloader_message",
291 "libcrypto_utils",
292 "libcrypto",
293 "libdiagnose_usb",
294 "libqemu_pipe",
295 "libbase",
296 ],
297}
298
299cc_binary {
300 name: "adbd",
301 defaults: ["adb_defaults"],
302
Josh Gao8db99f82018-03-06 12:57:27 -0800303 // adbd must be static, as it is copied into the recovery image.
304 static_executable: true,
305
Josh Gao27768452018-01-02 12:01:43 -0800306 srcs: [
307 "daemon/main.cpp",
308 "daemon/mdns.cpp",
309 "daemon/file_sync_service.cpp",
310 "daemon/framebuffer_service.cpp",
311 "daemon/remount_service.cpp",
312 "daemon/set_verity_enable_state_service.cpp",
313 "daemon/shell_service.cpp",
314 "shell_service_protocol.cpp",
315 ],
316
317 cflags: [
318 "-D_GNU_SOURCE",
319 "-Wno-deprecated-declarations",
320 ],
321
322 strip: {
323 keep_symbols: true,
324 },
325
326 static_libs: [
327 "libadbd",
328 "libasyncio",
329 "libavb_user",
330 "libbootloader_message",
331 "libcrypto_utils",
332 "libcrypto",
333 "libdiagnose_usb",
334 "libfec",
335 "libfec_rs",
336 "libfs_mgr",
337 "liblog",
338 "libext4_utils",
339 "libmdnssd",
340 "libminijail",
341 "libselinux",
342 "libsquashfs_utils",
343 "libqemu_pipe",
344 "libdebuggerd_handler",
345
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",
371 ],
Elliott Hughes40fdf3f2018-04-27 16:12:06 -0700372 test_suites: ["device-tests"],
Josh Gao27768452018-01-02 12:01:43 -0800373}
374
GuangHui Liu41bda342017-05-10 14:37:17 -0700375python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800376 name: "adb_integration_test_adb",
377 main: "test_adb.py",
378 srcs: [
379 "test_adb.py",
380 ],
381 libs: [
382 "adb_py",
383 ],
384 version: {
385 py2: {
386 enabled: true,
387 },
388 py3: {
389 enabled: false,
390 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700391 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700392}
393
394python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800395 name: "adb_integration_test_device",
396 main: "test_device.py",
397 srcs: [
398 "test_device.py",
399 ],
400 libs: [
401 "adb_py",
402 ],
403 version: {
404 py2: {
405 enabled: true,
406 },
407 py3: {
408 enabled: false,
409 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700410 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700411}