| GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 1 | // 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 Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 15 | cc_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 Gao | c7567fa | 2018-02-27 15:49:23 -0800 | [diff] [blame] | 33 | use_version_lib: true, | 
|  | 34 |  | 
| Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 35 | 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 Gao | 2e1e789 | 2018-03-23 13:03:28 -0700 | [diff] [blame] | 75 | // -std=gnu++11 doesn't set _GNU_SOURCE on Windows. | 
| Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 76 | "-D_GNU_SOURCE", | 
| Josh Gao | 2e1e789 | 2018-03-23 13:03:28 -0700 | [diff] [blame] | 77 |  | 
|  | 78 | // MinGW hides some things behind _POSIX_SOURCE. | 
|  | 79 | "-D_POSIX_SOURCE", | 
| Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 80 | ], | 
| Josh Gao | f8a97c1 | 2018-03-23 15:37:20 -0700 | [diff] [blame] | 81 |  | 
|  | 82 | host_ldlibs: [ | 
|  | 83 | "-lws2_32", | 
|  | 84 | "-lgdi32", | 
|  | 85 | "-luserenv", | 
|  | 86 | ], | 
| Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 87 | }, | 
|  | 88 | }, | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | // libadb | 
|  | 92 | // ========================================================= | 
|  | 93 | // These files are compiled for both the host and the device. | 
|  | 94 | libadb_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 |  | 
|  | 110 | libadb_posix_srcs = [ | 
|  | 111 | "sysdeps_unix.cpp", | 
|  | 112 | "sysdeps/posix/network.cpp", | 
|  | 113 | ] | 
|  | 114 |  | 
|  | 115 | libadb_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 |  | 
|  | 127 | cc_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 |  | 
|  | 171 | cc_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 Gao | f8a97c1 | 2018-03-23 15:37:20 -0700 | [diff] [blame] | 185 |  | 
|  | 186 | target: { | 
|  | 187 | windows: { | 
|  | 188 | enabled: true, | 
|  | 189 | shared_libs: ["AdbWinApi"], | 
|  | 190 | }, | 
|  | 191 | }, | 
| Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 192 | } | 
|  | 193 |  | 
| Josh Gao | 9c59649 | 2018-04-04 11:27:24 -0700 | [diff] [blame] | 194 | cc_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 Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 223 | cc_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 Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 268 | shared_libs: ["AdbWinApi"], | 
|  | 269 | required: [ | 
|  | 270 | "AdbWinUsbApi", | 
|  | 271 | ], | 
|  | 272 | }, | 
|  | 273 | }, | 
|  | 274 | } | 
|  | 275 |  | 
|  | 276 | cc_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 |  | 
|  | 299 | cc_binary { | 
|  | 300 | name: "adbd", | 
|  | 301 | defaults: ["adb_defaults"], | 
|  | 302 |  | 
| Josh Gao | 8db99f8 | 2018-03-06 12:57:27 -0800 | [diff] [blame] | 303 | // adbd must be static, as it is copied into the recovery image. | 
|  | 304 | static_executable: true, | 
|  | 305 |  | 
| Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 306 | 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 |  | 
|  | 351 | cc_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 | ], | 
|  | 372 | } | 
|  | 373 |  | 
| GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 374 | python_binary_host { | 
| Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 375 | name: "adb_integration_test_adb", | 
|  | 376 | main: "test_adb.py", | 
|  | 377 | srcs: [ | 
|  | 378 | "test_adb.py", | 
|  | 379 | ], | 
|  | 380 | libs: [ | 
|  | 381 | "adb_py", | 
|  | 382 | ], | 
|  | 383 | version: { | 
|  | 384 | py2: { | 
|  | 385 | enabled: true, | 
|  | 386 | }, | 
|  | 387 | py3: { | 
|  | 388 | enabled: false, | 
|  | 389 | }, | 
| GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 390 | }, | 
| GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 391 | } | 
|  | 392 |  | 
|  | 393 | python_binary_host { | 
| Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 394 | name: "adb_integration_test_device", | 
|  | 395 | main: "test_device.py", | 
|  | 396 | srcs: [ | 
|  | 397 | "test_device.py", | 
|  | 398 | ], | 
|  | 399 | libs: [ | 
|  | 400 | "adb_py", | 
|  | 401 | ], | 
|  | 402 | version: { | 
|  | 403 | py2: { | 
|  | 404 | enabled: true, | 
|  | 405 | }, | 
|  | 406 | py3: { | 
|  | 407 | enabled: false, | 
|  | 408 | }, | 
| GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 409 | }, | 
| GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 410 | } |