blob: d81bb4b2692f726223e446eb3ee22c5a7203d7cc [file] [log] [blame]
GuangHui Liu35994392017-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 Gao361148b2018-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 Gao66766f82018-02-27 15:49:23 -080033 use_version_lib: true,
34
Josh Gao361148b2018-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 Gao96049b92018-03-23 13:03:28 -070075 // -std=gnu++11 doesn't set _GNU_SOURCE on Windows.
Josh Gao361148b2018-01-02 12:01:43 -080076 "-D_GNU_SOURCE",
Josh Gao96049b92018-03-23 13:03:28 -070077
78 // MinGW hides some things behind _POSIX_SOURCE.
79 "-D_POSIX_SOURCE",
Josh Gao361148b2018-01-02 12:01:43 -080080 ],
Josh Gaoea7b95a2018-03-23 15:37:20 -070081
82 host_ldlibs: [
83 "-lws2_32",
84 "-lgdi32",
85 "-luserenv",
86 ],
Josh Gao361148b2018-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 Gaoea7b95a2018-03-23 15:37:20 -0700185
186 target: {
187 windows: {
188 enabled: true,
189 shared_libs: ["AdbWinApi"],
190 },
191 },
Josh Gao361148b2018-01-02 12:01:43 -0800192}
193
194cc_binary_host {
195 name: "adb",
196 tags: ["debug"],
197
198 defaults: ["adb_defaults"],
199
200 srcs: [
201 "client/adb_client.cpp",
202 "client/bugreport.cpp",
203 "client/commandline.cpp",
204 "client/file_sync_client.cpp",
205 "client/main.cpp",
206 "client/console.cpp",
207 "client/line_printer.cpp",
208 "shell_service_protocol.cpp",
209 ],
210
211 static_libs: [
212 "libadb_host",
213 "libbase",
214 "libcutils",
215 "libcrypto_utils",
216 "libcrypto",
217 "libdiagnose_usb",
218 "liblog",
219 "libmdnssd",
220 "libusb",
221 ],
222
223 stl: "libc++_static",
224
225 // Don't add anything here, we don't want additional shared dependencies
226 // on the host adb tool, and shared libraries that link against libc++
227 // will violate ODR
228 shared_libs: [],
229
230 target: {
231 darwin: {
232 cflags: [
233 "-Wno-sizeof-pointer-memaccess",
234 ],
235 },
236 windows: {
237 enabled: true,
238 ldflags: ["-municode"],
Josh Gao361148b2018-01-02 12:01:43 -0800239 shared_libs: ["AdbWinApi"],
240 required: [
241 "AdbWinUsbApi",
242 ],
243 },
244 },
245}
246
247cc_library_static {
248 name: "libadbd",
249 defaults: ["adb_defaults"],
250
251 // libminadbd wants both, for some reason.
252 compile_multilib: "both",
253 srcs: libadb_srcs + libadb_posix_srcs + [
254 "daemon/auth.cpp",
255 "daemon/usb.cpp",
256 "daemon/jdwp_service.cpp",
257 ],
258
259 static_libs: [
260 "libasyncio",
261 "libbootloader_message",
262 "libcrypto_utils",
263 "libcrypto",
264 "libdiagnose_usb",
265 "libqemu_pipe",
266 "libbase",
267 ],
268}
269
270cc_binary {
271 name: "adbd",
272 defaults: ["adb_defaults"],
273
Josh Gao3e0540a2018-03-06 12:57:27 -0800274 // adbd must be static, as it is copied into the recovery image.
275 static_executable: true,
276
Josh Gao361148b2018-01-02 12:01:43 -0800277 srcs: [
278 "daemon/main.cpp",
279 "daemon/mdns.cpp",
280 "daemon/file_sync_service.cpp",
281 "daemon/framebuffer_service.cpp",
282 "daemon/remount_service.cpp",
283 "daemon/set_verity_enable_state_service.cpp",
284 "daemon/shell_service.cpp",
285 "shell_service_protocol.cpp",
286 ],
287
288 cflags: [
289 "-D_GNU_SOURCE",
290 "-Wno-deprecated-declarations",
291 ],
292
293 strip: {
294 keep_symbols: true,
295 },
296
297 static_libs: [
298 "libadbd",
299 "libasyncio",
300 "libavb_user",
301 "libbootloader_message",
302 "libcrypto_utils",
303 "libcrypto",
304 "libdiagnose_usb",
305 "libfec",
306 "libfec_rs",
307 "libfs_mgr",
308 "liblog",
309 "libext4_utils",
310 "libmdnssd",
311 "libminijail",
312 "libselinux",
313 "libsquashfs_utils",
314 "libqemu_pipe",
315 "libdebuggerd_handler",
316
317 "libbase",
318 "libcutils",
319 ],
320}
321
322cc_test {
323 name: "adbd_test",
324 defaults: ["adb_defaults"],
325 srcs: libadb_test_srcs + [
326 "daemon/shell_service.cpp",
327 "daemon/shell_service_test.cpp",
328 "shell_service_protocol.cpp",
329 "shell_service_protocol_test.cpp",
330 ],
331
332 static_libs: [
333 "libadbd",
334 "libbase",
335 "libcutils",
336 "libcrypto_utils",
337 "libcrypto",
338 "libdiagnose_usb",
339 "liblog",
340 "libusb",
341 "libmdnssd",
342 ],
343}
344
GuangHui Liu35994392017-05-10 14:37:17 -0700345python_binary_host {
Elliott Hughes307e7672018-02-16 17:58:14 -0800346 name: "adb_integration_test_adb",
347 main: "test_adb.py",
348 srcs: [
349 "test_adb.py",
350 ],
351 libs: [
352 "adb_py",
353 ],
354 version: {
355 py2: {
356 enabled: true,
357 },
358 py3: {
359 enabled: false,
360 },
GuangHui Liu35994392017-05-10 14:37:17 -0700361 },
GuangHui Liu35994392017-05-10 14:37:17 -0700362}
363
364python_binary_host {
Elliott Hughes307e7672018-02-16 17:58:14 -0800365 name: "adb_integration_test_device",
366 main: "test_device.py",
367 srcs: [
368 "test_device.py",
369 ],
370 libs: [
371 "adb_py",
372 ],
373 version: {
374 py2: {
375 enabled: true,
376 },
377 py3: {
378 enabled: false,
379 },
GuangHui Liu35994392017-05-10 14:37:17 -0700380 },
GuangHui Liu35994392017-05-10 14:37:17 -0700381}