blob: 63c4d96d120b79b098c7e49000f11b3faaf66064 [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 ],
81 },
82 },
83}
84
85// libadb
86// =========================================================
87// These files are compiled for both the host and the device.
88libadb_srcs = [
89 "adb.cpp",
90 "adb_io.cpp",
91 "adb_listeners.cpp",
92 "adb_trace.cpp",
93 "adb_utils.cpp",
94 "fdevent.cpp",
95 "services.cpp",
96 "sockets.cpp",
97 "socket_spec.cpp",
98 "sysdeps/errno.cpp",
99 "transport.cpp",
100 "transport_local.cpp",
101 "transport_usb.cpp",
102]
103
104libadb_posix_srcs = [
105 "sysdeps_unix.cpp",
106 "sysdeps/posix/network.cpp",
107]
108
109libadb_test_srcs = [
110 "adb_io_test.cpp",
111 "adb_listeners_test.cpp",
112 "adb_utils_test.cpp",
113 "fdevent_test.cpp",
114 "socket_spec_test.cpp",
115 "socket_test.cpp",
116 "sysdeps_test.cpp",
117 "sysdeps/stat_test.cpp",
118 "transport_test.cpp",
119]
120
121cc_library_host_static {
122 name: "libadb_host",
123 defaults: ["adb_defaults"],
124
125 srcs: libadb_srcs + [
126 "client/auth.cpp",
127 "client/usb_libusb.cpp",
128 "client/usb_dispatch.cpp",
129 "client/transport_mdns.cpp",
130 ],
131
132 target: {
133 linux: {
134 srcs: ["client/usb_linux.cpp"],
135 },
136 darwin: {
137 srcs: ["client/usb_osx.cpp"],
138 },
139
140 not_windows: {
141 srcs: libadb_posix_srcs,
142 },
143 windows: {
144 enabled: true,
145 srcs: [
146 "client/usb_windows.cpp",
147 "sysdeps_win32.cpp",
148 "sysdeps/win32/errno.cpp",
149 "sysdeps/win32/stat.cpp",
150 ],
151 shared_libs: ["AdbWinApi"],
152 },
153 },
154
155 static_libs: [
156 "libbase",
157 "libcrypto_utils",
158 "libcrypto",
159 "libdiagnose_usb",
160 "libmdnssd",
161 "libusb",
162 ],
163}
164
165cc_test_host {
166 name: "adb_test",
167 defaults: ["adb_defaults"],
168 srcs: libadb_test_srcs,
169 static_libs: [
170 "libadb_host",
171 "libbase",
172 "libcutils",
173 "libcrypto_utils",
174 "libcrypto",
175 "libmdnssd",
176 "libdiagnose_usb",
177 "libusb",
178 ],
179}
180
181cc_binary_host {
182 name: "adb",
183 tags: ["debug"],
184
185 defaults: ["adb_defaults"],
186
187 srcs: [
188 "client/adb_client.cpp",
189 "client/bugreport.cpp",
190 "client/commandline.cpp",
191 "client/file_sync_client.cpp",
192 "client/main.cpp",
193 "client/console.cpp",
194 "client/line_printer.cpp",
195 "shell_service_protocol.cpp",
196 ],
197
198 static_libs: [
199 "libadb_host",
200 "libbase",
201 "libcutils",
202 "libcrypto_utils",
203 "libcrypto",
204 "libdiagnose_usb",
205 "liblog",
206 "libmdnssd",
207 "libusb",
208 ],
209
210 stl: "libc++_static",
211
212 // Don't add anything here, we don't want additional shared dependencies
213 // on the host adb tool, and shared libraries that link against libc++
214 // will violate ODR
215 shared_libs: [],
216
217 target: {
218 darwin: {
219 cflags: [
220 "-Wno-sizeof-pointer-memaccess",
221 ],
222 },
223 windows: {
224 enabled: true,
225 ldflags: ["-municode"],
226 host_ldlibs: [
227 "-lws2_32",
228 "-lgdi32",
229 ],
230
231 shared_libs: ["AdbWinApi"],
232 required: [
233 "AdbWinUsbApi",
234 ],
235 },
236 },
237}
238
239cc_library_static {
240 name: "libadbd",
241 defaults: ["adb_defaults"],
242
243 // libminadbd wants both, for some reason.
244 compile_multilib: "both",
245 srcs: libadb_srcs + libadb_posix_srcs + [
246 "daemon/auth.cpp",
247 "daemon/usb.cpp",
248 "daemon/jdwp_service.cpp",
249 ],
250
251 static_libs: [
252 "libasyncio",
253 "libbootloader_message",
254 "libcrypto_utils",
255 "libcrypto",
256 "libdiagnose_usb",
257 "libqemu_pipe",
258 "libbase",
259 ],
260}
261
262cc_binary {
263 name: "adbd",
264 defaults: ["adb_defaults"],
265
Josh Gao8db99f82018-03-06 12:57:27 -0800266 // adbd must be static, as it is copied into the recovery image.
267 static_executable: true,
268
Josh Gao27768452018-01-02 12:01:43 -0800269 srcs: [
270 "daemon/main.cpp",
271 "daemon/mdns.cpp",
272 "daemon/file_sync_service.cpp",
273 "daemon/framebuffer_service.cpp",
274 "daemon/remount_service.cpp",
275 "daemon/set_verity_enable_state_service.cpp",
276 "daemon/shell_service.cpp",
277 "shell_service_protocol.cpp",
278 ],
279
280 cflags: [
281 "-D_GNU_SOURCE",
282 "-Wno-deprecated-declarations",
283 ],
284
285 strip: {
286 keep_symbols: true,
287 },
288
289 static_libs: [
290 "libadbd",
291 "libasyncio",
292 "libavb_user",
293 "libbootloader_message",
294 "libcrypto_utils",
295 "libcrypto",
296 "libdiagnose_usb",
297 "libfec",
298 "libfec_rs",
299 "libfs_mgr",
300 "liblog",
301 "libext4_utils",
302 "libmdnssd",
303 "libminijail",
304 "libselinux",
305 "libsquashfs_utils",
306 "libqemu_pipe",
307 "libdebuggerd_handler",
308
309 "libbase",
310 "libcutils",
311 ],
312}
313
314cc_test {
315 name: "adbd_test",
316 defaults: ["adb_defaults"],
317 srcs: libadb_test_srcs + [
318 "daemon/shell_service.cpp",
319 "daemon/shell_service_test.cpp",
320 "shell_service_protocol.cpp",
321 "shell_service_protocol_test.cpp",
322 ],
323
324 static_libs: [
325 "libadbd",
326 "libbase",
327 "libcutils",
328 "libcrypto_utils",
329 "libcrypto",
330 "libdiagnose_usb",
331 "liblog",
332 "libusb",
333 "libmdnssd",
334 ],
335}
336
GuangHui Liu41bda342017-05-10 14:37:17 -0700337python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800338 name: "adb_integration_test_adb",
339 main: "test_adb.py",
340 srcs: [
341 "test_adb.py",
342 ],
343 libs: [
344 "adb_py",
345 ],
346 version: {
347 py2: {
348 enabled: true,
349 },
350 py3: {
351 enabled: false,
352 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700353 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700354}
355
356python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800357 name: "adb_integration_test_device",
358 main: "test_device.py",
359 srcs: [
360 "test_device.py",
361 ],
362 libs: [
363 "adb_py",
364 ],
365 version: {
366 py2: {
367 enabled: true,
368 },
369 py3: {
370 enabled: false,
371 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700372 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700373}