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