GuangHui Liu | 3599439 | 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 | 361148b | 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 | 66766f8 | 2018-02-27 15:49:23 -0800 | [diff] [blame] | 33 | use_version_lib: true, |
| 34 | |
Josh Gao | 361148b | 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 | 96049b9 | 2018-03-23 13:03:28 -0700 | [diff] [blame] | 75 | // -std=gnu++11 doesn't set _GNU_SOURCE on Windows. |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 76 | "-D_GNU_SOURCE", |
Josh Gao | 96049b9 | 2018-03-23 13:03:28 -0700 | [diff] [blame] | 77 | |
| 78 | // MinGW hides some things behind _POSIX_SOURCE. |
| 79 | "-D_POSIX_SOURCE", |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 80 | ], |
Josh Gao | ea7b95a | 2018-03-23 15:37:20 -0700 | [diff] [blame] | 81 | |
| 82 | host_ldlibs: [ |
| 83 | "-lws2_32", |
| 84 | "-lgdi32", |
| 85 | "-luserenv", |
| 86 | ], |
Josh Gao | 361148b | 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", |
Josh Gao | 9f155db | 2018-04-03 14:37:11 -0700 | [diff] [blame] | 125 | "types_test.cpp", |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 126 | ] |
| 127 | |
| 128 | cc_library_host_static { |
| 129 | name: "libadb_host", |
| 130 | defaults: ["adb_defaults"], |
| 131 | |
| 132 | srcs: libadb_srcs + [ |
| 133 | "client/auth.cpp", |
| 134 | "client/usb_libusb.cpp", |
| 135 | "client/usb_dispatch.cpp", |
| 136 | "client/transport_mdns.cpp", |
| 137 | ], |
| 138 | |
| 139 | target: { |
| 140 | linux: { |
| 141 | srcs: ["client/usb_linux.cpp"], |
| 142 | }, |
| 143 | darwin: { |
| 144 | srcs: ["client/usb_osx.cpp"], |
| 145 | }, |
| 146 | |
| 147 | not_windows: { |
| 148 | srcs: libadb_posix_srcs, |
| 149 | }, |
| 150 | windows: { |
| 151 | enabled: true, |
| 152 | srcs: [ |
| 153 | "client/usb_windows.cpp", |
| 154 | "sysdeps_win32.cpp", |
| 155 | "sysdeps/win32/errno.cpp", |
| 156 | "sysdeps/win32/stat.cpp", |
| 157 | ], |
| 158 | shared_libs: ["AdbWinApi"], |
| 159 | }, |
| 160 | }, |
| 161 | |
| 162 | static_libs: [ |
| 163 | "libbase", |
| 164 | "libcrypto_utils", |
| 165 | "libcrypto", |
| 166 | "libdiagnose_usb", |
| 167 | "libmdnssd", |
| 168 | "libusb", |
| 169 | ], |
| 170 | } |
| 171 | |
| 172 | cc_test_host { |
| 173 | name: "adb_test", |
| 174 | defaults: ["adb_defaults"], |
| 175 | srcs: libadb_test_srcs, |
| 176 | static_libs: [ |
| 177 | "libadb_host", |
| 178 | "libbase", |
| 179 | "libcutils", |
| 180 | "libcrypto_utils", |
| 181 | "libcrypto", |
| 182 | "libmdnssd", |
| 183 | "libdiagnose_usb", |
| 184 | "libusb", |
| 185 | ], |
Josh Gao | ea7b95a | 2018-03-23 15:37:20 -0700 | [diff] [blame] | 186 | |
| 187 | target: { |
| 188 | windows: { |
| 189 | enabled: true, |
| 190 | shared_libs: ["AdbWinApi"], |
| 191 | }, |
| 192 | }, |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Josh Gao | 11e41d6 | 2018-04-04 11:27:24 -0700 | [diff] [blame] | 195 | cc_benchmark { |
| 196 | name: "adb_benchmark", |
| 197 | defaults: ["adb_defaults"], |
| 198 | |
| 199 | srcs: ["transport_benchmark.cpp"], |
| 200 | target: { |
| 201 | android: { |
| 202 | static_libs: [ |
| 203 | "libadbd", |
| 204 | ], |
| 205 | }, |
| 206 | host: { |
| 207 | static_libs: [ |
| 208 | "libadb_host", |
| 209 | ], |
| 210 | }, |
| 211 | }, |
| 212 | |
| 213 | static_libs: [ |
| 214 | "libbase", |
| 215 | "libcutils", |
| 216 | "libcrypto_utils", |
| 217 | "libcrypto", |
| 218 | "libdiagnose_usb", |
| 219 | "liblog", |
| 220 | "libusb", |
| 221 | ], |
| 222 | } |
| 223 | |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 224 | cc_binary_host { |
| 225 | name: "adb", |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 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 | 361148b | 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"], |
Jiyong Park | eb59039 | 2018-05-24 14:11:00 +0900 | [diff] [blame^] | 279 | recovery_available: true, |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 280 | |
| 281 | // libminadbd wants both, for some reason. |
| 282 | compile_multilib: "both", |
| 283 | srcs: libadb_srcs + libadb_posix_srcs + [ |
| 284 | "daemon/auth.cpp", |
| 285 | "daemon/usb.cpp", |
| 286 | "daemon/jdwp_service.cpp", |
| 287 | ], |
| 288 | |
| 289 | static_libs: [ |
| 290 | "libasyncio", |
| 291 | "libbootloader_message", |
| 292 | "libcrypto_utils", |
| 293 | "libcrypto", |
| 294 | "libdiagnose_usb", |
| 295 | "libqemu_pipe", |
| 296 | "libbase", |
| 297 | ], |
| 298 | } |
| 299 | |
| 300 | cc_binary { |
| 301 | name: "adbd", |
| 302 | defaults: ["adb_defaults"], |
| 303 | |
Josh Gao | 3e0540a | 2018-03-06 12:57:27 -0800 | [diff] [blame] | 304 | // adbd must be static, as it is copied into the recovery image. |
| 305 | static_executable: true, |
Jiyong Park | eb59039 | 2018-05-24 14:11:00 +0900 | [diff] [blame^] | 306 | recovery_available: true, |
Josh Gao | 3e0540a | 2018-03-06 12:57:27 -0800 | [diff] [blame] | 307 | |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 308 | srcs: [ |
| 309 | "daemon/main.cpp", |
| 310 | "daemon/mdns.cpp", |
| 311 | "daemon/file_sync_service.cpp", |
| 312 | "daemon/framebuffer_service.cpp", |
| 313 | "daemon/remount_service.cpp", |
| 314 | "daemon/set_verity_enable_state_service.cpp", |
| 315 | "daemon/shell_service.cpp", |
| 316 | "shell_service_protocol.cpp", |
| 317 | ], |
| 318 | |
| 319 | cflags: [ |
| 320 | "-D_GNU_SOURCE", |
| 321 | "-Wno-deprecated-declarations", |
| 322 | ], |
| 323 | |
| 324 | strip: { |
| 325 | keep_symbols: true, |
| 326 | }, |
| 327 | |
| 328 | static_libs: [ |
| 329 | "libadbd", |
| 330 | "libasyncio", |
| 331 | "libavb_user", |
| 332 | "libbootloader_message", |
| 333 | "libcrypto_utils", |
| 334 | "libcrypto", |
| 335 | "libdiagnose_usb", |
| 336 | "libfec", |
| 337 | "libfec_rs", |
| 338 | "libfs_mgr", |
| 339 | "liblog", |
| 340 | "libext4_utils", |
| 341 | "libmdnssd", |
| 342 | "libminijail", |
| 343 | "libselinux", |
| 344 | "libsquashfs_utils", |
| 345 | "libqemu_pipe", |
| 346 | "libdebuggerd_handler", |
| 347 | |
| 348 | "libbase", |
| 349 | "libcutils", |
| 350 | ], |
| 351 | } |
| 352 | |
| 353 | cc_test { |
| 354 | name: "adbd_test", |
| 355 | defaults: ["adb_defaults"], |
| 356 | srcs: libadb_test_srcs + [ |
| 357 | "daemon/shell_service.cpp", |
| 358 | "daemon/shell_service_test.cpp", |
| 359 | "shell_service_protocol.cpp", |
| 360 | "shell_service_protocol_test.cpp", |
| 361 | ], |
| 362 | |
| 363 | static_libs: [ |
| 364 | "libadbd", |
| 365 | "libbase", |
| 366 | "libcutils", |
| 367 | "libcrypto_utils", |
| 368 | "libcrypto", |
| 369 | "libdiagnose_usb", |
| 370 | "liblog", |
| 371 | "libusb", |
| 372 | "libmdnssd", |
| 373 | ], |
Elliott Hughes | ce226c9 | 2018-04-27 16:12:06 -0700 | [diff] [blame] | 374 | test_suites: ["device-tests"], |
Josh Gao | 361148b | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 375 | } |
| 376 | |
GuangHui Liu | 3599439 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 377 | python_binary_host { |
Elliott Hughes | 307e767 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 378 | name: "adb_integration_test_adb", |
| 379 | main: "test_adb.py", |
| 380 | srcs: [ |
| 381 | "test_adb.py", |
| 382 | ], |
| 383 | libs: [ |
| 384 | "adb_py", |
| 385 | ], |
| 386 | version: { |
| 387 | py2: { |
| 388 | enabled: true, |
| 389 | }, |
| 390 | py3: { |
| 391 | enabled: false, |
| 392 | }, |
GuangHui Liu | 3599439 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 393 | }, |
GuangHui Liu | 3599439 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | python_binary_host { |
Elliott Hughes | 307e767 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 397 | name: "adb_integration_test_device", |
| 398 | main: "test_device.py", |
| 399 | srcs: [ |
| 400 | "test_device.py", |
| 401 | ], |
| 402 | libs: [ |
| 403 | "adb_py", |
| 404 | ], |
| 405 | version: { |
| 406 | py2: { |
| 407 | enabled: true, |
| 408 | }, |
| 409 | py3: { |
| 410 | enabled: false, |
| 411 | }, |
GuangHui Liu | 3599439 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 412 | }, |
GuangHui Liu | 3599439 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 413 | } |