blob: 1310b06ba1d9ddb8d63f41e1aa88596c2c9f140a [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
33 compile_multilib: "first",
34 product_variables: {
35 debuggable: {
36 cflags: [
37 "-DALLOW_ADBD_ROOT",
38 "-DALLOW_ADBD_DISABLE_VERITY",
39 "-DALLOW_ADBD_NO_AUTH",
40 ],
41 },
42 },
43
44 target: {
45 android: {
46 cflags: ["-DADB_HOST=0"],
47 },
48
49 host: {
50 cflags: ["-DADB_HOST=1"],
51 },
52
53 darwin: {
54 host_ldlibs: [
55 "-lpthread",
56 "-framework CoreFoundation",
57 "-framework IOKit",
58 "-lobjc",
59 ],
60 },
61
62 windows: {
63 cflags: [
64 // Define windows.h and tchar.h Unicode preprocessor symbols so that
65 // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the
66 // build if you accidentally pass char*. Fix by calling like:
67 // std::wstring path_wide;
68 // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ }
69 // CreateFileW(path_wide.c_str());
70 "-DUNICODE=1",
71 "-D_UNICODE=1",
72
73 // -std=gnu++14 doesn't set _GNU_SOURCE on Windows.
74 "-D_GNU_SOURCE",
75 ],
76 },
77 },
78}
79
80// libadb
81// =========================================================
82// These files are compiled for both the host and the device.
83libadb_srcs = [
84 "adb.cpp",
85 "adb_io.cpp",
86 "adb_listeners.cpp",
87 "adb_trace.cpp",
88 "adb_utils.cpp",
89 "fdevent.cpp",
90 "services.cpp",
91 "sockets.cpp",
92 "socket_spec.cpp",
93 "sysdeps/errno.cpp",
94 "transport.cpp",
95 "transport_local.cpp",
96 "transport_usb.cpp",
97]
98
99libadb_posix_srcs = [
100 "sysdeps_unix.cpp",
101 "sysdeps/posix/network.cpp",
102]
103
104libadb_test_srcs = [
105 "adb_io_test.cpp",
106 "adb_listeners_test.cpp",
107 "adb_utils_test.cpp",
108 "fdevent_test.cpp",
109 "socket_spec_test.cpp",
110 "socket_test.cpp",
111 "sysdeps_test.cpp",
112 "sysdeps/stat_test.cpp",
113 "transport_test.cpp",
114]
115
116cc_library_host_static {
117 name: "libadb_host",
118 defaults: ["adb_defaults"],
119
120 srcs: libadb_srcs + [
121 "client/auth.cpp",
122 "client/usb_libusb.cpp",
123 "client/usb_dispatch.cpp",
124 "client/transport_mdns.cpp",
125 ],
126
127 target: {
128 linux: {
129 srcs: ["client/usb_linux.cpp"],
130 },
131 darwin: {
132 srcs: ["client/usb_osx.cpp"],
133 },
134
135 not_windows: {
136 srcs: libadb_posix_srcs,
137 },
138 windows: {
139 enabled: true,
140 srcs: [
141 "client/usb_windows.cpp",
142 "sysdeps_win32.cpp",
143 "sysdeps/win32/errno.cpp",
144 "sysdeps/win32/stat.cpp",
145 ],
146 shared_libs: ["AdbWinApi"],
147 },
148 },
149
150 static_libs: [
151 "libbase",
152 "libcrypto_utils",
153 "libcrypto",
154 "libdiagnose_usb",
155 "libmdnssd",
156 "libusb",
157 ],
158}
159
160cc_test_host {
161 name: "adb_test",
162 defaults: ["adb_defaults"],
163 srcs: libadb_test_srcs,
164 static_libs: [
165 "libadb_host",
166 "libbase",
167 "libcutils",
168 "libcrypto_utils",
169 "libcrypto",
170 "libmdnssd",
171 "libdiagnose_usb",
172 "libusb",
173 ],
174}
175
176cc_binary_host {
177 name: "adb",
178 tags: ["debug"],
179
180 defaults: ["adb_defaults"],
181
182 srcs: [
183 "client/adb_client.cpp",
184 "client/bugreport.cpp",
185 "client/commandline.cpp",
186 "client/file_sync_client.cpp",
187 "client/main.cpp",
188 "client/console.cpp",
189 "client/line_printer.cpp",
190 "shell_service_protocol.cpp",
191 ],
192
193 static_libs: [
194 "libadb_host",
195 "libbase",
196 "libcutils",
197 "libcrypto_utils",
198 "libcrypto",
199 "libdiagnose_usb",
200 "liblog",
201 "libmdnssd",
202 "libusb",
203 ],
204
205 stl: "libc++_static",
206
207 // Don't add anything here, we don't want additional shared dependencies
208 // on the host adb tool, and shared libraries that link against libc++
209 // will violate ODR
210 shared_libs: [],
211
212 target: {
213 darwin: {
214 cflags: [
215 "-Wno-sizeof-pointer-memaccess",
216 ],
217 },
218 windows: {
219 enabled: true,
220 ldflags: ["-municode"],
221 host_ldlibs: [
222 "-lws2_32",
223 "-lgdi32",
224 ],
225
226 shared_libs: ["AdbWinApi"],
227 required: [
228 "AdbWinUsbApi",
229 ],
230 },
231 },
232}
233
234cc_library_static {
235 name: "libadbd",
236 defaults: ["adb_defaults"],
237
238 // libminadbd wants both, for some reason.
239 compile_multilib: "both",
240 srcs: libadb_srcs + libadb_posix_srcs + [
241 "daemon/auth.cpp",
242 "daemon/usb.cpp",
243 "daemon/jdwp_service.cpp",
244 ],
245
246 static_libs: [
247 "libasyncio",
248 "libbootloader_message",
249 "libcrypto_utils",
250 "libcrypto",
251 "libdiagnose_usb",
252 "libqemu_pipe",
253 "libbase",
254 ],
255}
256
257cc_binary {
258 name: "adbd",
259 defaults: ["adb_defaults"],
260
261 srcs: [
262 "daemon/main.cpp",
263 "daemon/mdns.cpp",
264 "daemon/file_sync_service.cpp",
265 "daemon/framebuffer_service.cpp",
266 "daemon/remount_service.cpp",
267 "daemon/set_verity_enable_state_service.cpp",
268 "daemon/shell_service.cpp",
269 "shell_service_protocol.cpp",
270 ],
271
272 cflags: [
273 "-D_GNU_SOURCE",
274 "-Wno-deprecated-declarations",
275 ],
276
277 strip: {
278 keep_symbols: true,
279 },
280
281 static_libs: [
282 "libadbd",
283 "libasyncio",
284 "libavb_user",
285 "libbootloader_message",
286 "libcrypto_utils",
287 "libcrypto",
288 "libdiagnose_usb",
289 "libfec",
290 "libfec_rs",
291 "libfs_mgr",
292 "liblog",
293 "libext4_utils",
294 "libmdnssd",
295 "libminijail",
296 "libselinux",
297 "libsquashfs_utils",
298 "libqemu_pipe",
299 "libdebuggerd_handler",
300
301 "libbase",
302 "libcutils",
303 ],
304}
305
306cc_test {
307 name: "adbd_test",
308 defaults: ["adb_defaults"],
309 srcs: libadb_test_srcs + [
310 "daemon/shell_service.cpp",
311 "daemon/shell_service_test.cpp",
312 "shell_service_protocol.cpp",
313 "shell_service_protocol_test.cpp",
314 ],
315
316 static_libs: [
317 "libadbd",
318 "libbase",
319 "libcutils",
320 "libcrypto_utils",
321 "libcrypto",
322 "libdiagnose_usb",
323 "liblog",
324 "libusb",
325 "libmdnssd",
326 ],
327}
328
GuangHui Liu41bda342017-05-10 14:37:17 -0700329python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800330 name: "adb_integration_test_adb",
331 main: "test_adb.py",
332 srcs: [
333 "test_adb.py",
334 ],
335 libs: [
336 "adb_py",
337 ],
338 version: {
339 py2: {
340 enabled: true,
341 },
342 py3: {
343 enabled: false,
344 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700345 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700346}
347
348python_binary_host {
Elliott Hughesdc699a22018-02-16 17:58:14 -0800349 name: "adb_integration_test_device",
350 main: "test_device.py",
351 srcs: [
352 "test_device.py",
353 ],
354 libs: [
355 "adb_py",
356 ],
357 version: {
358 py2: {
359 enabled: true,
360 },
361 py3: {
362 enabled: false,
363 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700364 },
GuangHui Liu41bda342017-05-10 14:37:17 -0700365}