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", |
Pirama Arumuga Nainar | 7982178 | 2018-06-01 11:31:38 -0700 | [diff] [blame] | 22 | "-Wexit-time-destructors", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 23 | "-Wno-unused-parameter", |
| 24 | "-Wno-missing-field-initializers", |
| 25 | "-Wvla", |
| 26 | ], |
| 27 | rtti: true, |
| 28 | |
Josh Gao | c7567fa | 2018-02-27 15:49:23 -0800 | [diff] [blame] | 29 | use_version_lib: true, |
| 30 | |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 31 | compile_multilib: "first", |
| 32 | product_variables: { |
| 33 | debuggable: { |
| 34 | cflags: [ |
| 35 | "-DALLOW_ADBD_ROOT", |
| 36 | "-DALLOW_ADBD_DISABLE_VERITY", |
| 37 | "-DALLOW_ADBD_NO_AUTH", |
| 38 | ], |
| 39 | }, |
| 40 | }, |
| 41 | |
| 42 | target: { |
| 43 | android: { |
| 44 | cflags: ["-DADB_HOST=0"], |
| 45 | }, |
| 46 | |
| 47 | host: { |
| 48 | cflags: ["-DADB_HOST=1"], |
| 49 | }, |
| 50 | |
| 51 | darwin: { |
| 52 | host_ldlibs: [ |
| 53 | "-lpthread", |
| 54 | "-framework CoreFoundation", |
| 55 | "-framework IOKit", |
| 56 | "-lobjc", |
| 57 | ], |
| 58 | }, |
| 59 | |
| 60 | windows: { |
| 61 | cflags: [ |
| 62 | // Define windows.h and tchar.h Unicode preprocessor symbols so that |
| 63 | // CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the |
| 64 | // build if you accidentally pass char*. Fix by calling like: |
| 65 | // std::wstring path_wide; |
| 66 | // if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ } |
| 67 | // CreateFileW(path_wide.c_str()); |
| 68 | "-DUNICODE=1", |
| 69 | "-D_UNICODE=1", |
| 70 | |
Josh Gao | 2e1e789 | 2018-03-23 13:03:28 -0700 | [diff] [blame] | 71 | // -std=gnu++11 doesn't set _GNU_SOURCE on Windows. |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 72 | "-D_GNU_SOURCE", |
Josh Gao | 2e1e789 | 2018-03-23 13:03:28 -0700 | [diff] [blame] | 73 | |
| 74 | // MinGW hides some things behind _POSIX_SOURCE. |
| 75 | "-D_POSIX_SOURCE", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 76 | ], |
Josh Gao | f8a97c1 | 2018-03-23 15:37:20 -0700 | [diff] [blame] | 77 | |
| 78 | host_ldlibs: [ |
| 79 | "-lws2_32", |
| 80 | "-lgdi32", |
| 81 | "-luserenv", |
| 82 | ], |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 83 | }, |
Pirama Arumuga Nainar | 7982178 | 2018-06-01 11:31:38 -0700 | [diff] [blame] | 84 | |
| 85 | not_windows: { |
| 86 | cflags: [ |
| 87 | "-Wthread-safety", |
| 88 | ], |
| 89 | }, |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 90 | }, |
| 91 | } |
| 92 | |
| 93 | // libadb |
| 94 | // ========================================================= |
| 95 | // These files are compiled for both the host and the device. |
| 96 | libadb_srcs = [ |
| 97 | "adb.cpp", |
| 98 | "adb_io.cpp", |
| 99 | "adb_listeners.cpp", |
| 100 | "adb_trace.cpp", |
Josh Gao | 6e1246c | 2018-05-24 22:54:50 -0700 | [diff] [blame] | 101 | "adb_unique_fd.cpp", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 102 | "adb_utils.cpp", |
| 103 | "fdevent.cpp", |
| 104 | "services.cpp", |
| 105 | "sockets.cpp", |
| 106 | "socket_spec.cpp", |
| 107 | "sysdeps/errno.cpp", |
| 108 | "transport.cpp", |
Josh Gao | 6082e7d | 2018-04-05 16:16:04 -0700 | [diff] [blame] | 109 | "transport_fd.cpp", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 110 | "transport_local.cpp", |
| 111 | "transport_usb.cpp", |
| 112 | ] |
| 113 | |
| 114 | libadb_posix_srcs = [ |
| 115 | "sysdeps_unix.cpp", |
| 116 | "sysdeps/posix/network.cpp", |
| 117 | ] |
| 118 | |
| 119 | libadb_test_srcs = [ |
| 120 | "adb_io_test.cpp", |
| 121 | "adb_listeners_test.cpp", |
| 122 | "adb_utils_test.cpp", |
| 123 | "fdevent_test.cpp", |
| 124 | "socket_spec_test.cpp", |
| 125 | "socket_test.cpp", |
| 126 | "sysdeps_test.cpp", |
| 127 | "sysdeps/stat_test.cpp", |
| 128 | "transport_test.cpp", |
Josh Gao | 7c738cd | 2018-04-03 14:37:11 -0700 | [diff] [blame] | 129 | "types_test.cpp", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 130 | ] |
| 131 | |
| 132 | cc_library_host_static { |
| 133 | name: "libadb_host", |
| 134 | defaults: ["adb_defaults"], |
| 135 | |
| 136 | srcs: libadb_srcs + [ |
| 137 | "client/auth.cpp", |
| 138 | "client/usb_libusb.cpp", |
| 139 | "client/usb_dispatch.cpp", |
| 140 | "client/transport_mdns.cpp", |
| 141 | ], |
| 142 | |
| 143 | target: { |
| 144 | linux: { |
| 145 | srcs: ["client/usb_linux.cpp"], |
| 146 | }, |
| 147 | darwin: { |
| 148 | srcs: ["client/usb_osx.cpp"], |
| 149 | }, |
| 150 | |
| 151 | not_windows: { |
| 152 | srcs: libadb_posix_srcs, |
| 153 | }, |
| 154 | windows: { |
| 155 | enabled: true, |
| 156 | srcs: [ |
| 157 | "client/usb_windows.cpp", |
| 158 | "sysdeps_win32.cpp", |
| 159 | "sysdeps/win32/errno.cpp", |
| 160 | "sysdeps/win32/stat.cpp", |
| 161 | ], |
| 162 | shared_libs: ["AdbWinApi"], |
| 163 | }, |
| 164 | }, |
| 165 | |
| 166 | static_libs: [ |
| 167 | "libbase", |
| 168 | "libcrypto_utils", |
| 169 | "libcrypto", |
| 170 | "libdiagnose_usb", |
| 171 | "libmdnssd", |
| 172 | "libusb", |
| 173 | ], |
| 174 | } |
| 175 | |
| 176 | cc_test_host { |
| 177 | name: "adb_test", |
| 178 | defaults: ["adb_defaults"], |
| 179 | srcs: libadb_test_srcs, |
| 180 | static_libs: [ |
| 181 | "libadb_host", |
| 182 | "libbase", |
| 183 | "libcutils", |
| 184 | "libcrypto_utils", |
| 185 | "libcrypto", |
| 186 | "libmdnssd", |
| 187 | "libdiagnose_usb", |
| 188 | "libusb", |
| 189 | ], |
Josh Gao | f8a97c1 | 2018-03-23 15:37:20 -0700 | [diff] [blame] | 190 | |
| 191 | target: { |
| 192 | windows: { |
| 193 | enabled: true, |
| 194 | shared_libs: ["AdbWinApi"], |
| 195 | }, |
| 196 | }, |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 197 | } |
| 198 | |
Josh Gao | 9c59649 | 2018-04-04 11:27:24 -0700 | [diff] [blame] | 199 | cc_benchmark { |
| 200 | name: "adb_benchmark", |
| 201 | defaults: ["adb_defaults"], |
| 202 | |
| 203 | srcs: ["transport_benchmark.cpp"], |
| 204 | target: { |
| 205 | android: { |
| 206 | static_libs: [ |
| 207 | "libadbd", |
| 208 | ], |
| 209 | }, |
| 210 | host: { |
| 211 | static_libs: [ |
| 212 | "libadb_host", |
| 213 | ], |
| 214 | }, |
| 215 | }, |
| 216 | |
| 217 | static_libs: [ |
| 218 | "libbase", |
| 219 | "libcutils", |
| 220 | "libcrypto_utils", |
| 221 | "libcrypto", |
| 222 | "libdiagnose_usb", |
| 223 | "liblog", |
| 224 | "libusb", |
| 225 | ], |
| 226 | } |
| 227 | |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 228 | cc_binary_host { |
| 229 | name: "adb", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 230 | |
| 231 | defaults: ["adb_defaults"], |
| 232 | |
| 233 | srcs: [ |
| 234 | "client/adb_client.cpp", |
| 235 | "client/bugreport.cpp", |
| 236 | "client/commandline.cpp", |
| 237 | "client/file_sync_client.cpp", |
| 238 | "client/main.cpp", |
| 239 | "client/console.cpp", |
| 240 | "client/line_printer.cpp", |
| 241 | "shell_service_protocol.cpp", |
| 242 | ], |
| 243 | |
| 244 | static_libs: [ |
| 245 | "libadb_host", |
| 246 | "libbase", |
| 247 | "libcutils", |
| 248 | "libcrypto_utils", |
| 249 | "libcrypto", |
| 250 | "libdiagnose_usb", |
| 251 | "liblog", |
| 252 | "libmdnssd", |
| 253 | "libusb", |
| 254 | ], |
| 255 | |
| 256 | stl: "libc++_static", |
| 257 | |
| 258 | // Don't add anything here, we don't want additional shared dependencies |
| 259 | // on the host adb tool, and shared libraries that link against libc++ |
| 260 | // will violate ODR |
| 261 | shared_libs: [], |
| 262 | |
| 263 | target: { |
| 264 | darwin: { |
| 265 | cflags: [ |
| 266 | "-Wno-sizeof-pointer-memaccess", |
| 267 | ], |
| 268 | }, |
| 269 | windows: { |
| 270 | enabled: true, |
| 271 | ldflags: ["-municode"], |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 272 | shared_libs: ["AdbWinApi"], |
| 273 | required: [ |
| 274 | "AdbWinUsbApi", |
| 275 | ], |
| 276 | }, |
| 277 | }, |
| 278 | } |
| 279 | |
| 280 | cc_library_static { |
| 281 | name: "libadbd", |
| 282 | defaults: ["adb_defaults"], |
Jiyong Park | a0e7504 | 2018-05-24 14:11:00 +0900 | [diff] [blame] | 283 | recovery_available: true, |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 284 | |
| 285 | // libminadbd wants both, for some reason. |
| 286 | compile_multilib: "both", |
| 287 | srcs: libadb_srcs + libadb_posix_srcs + [ |
| 288 | "daemon/auth.cpp", |
| 289 | "daemon/usb.cpp", |
| 290 | "daemon/jdwp_service.cpp", |
| 291 | ], |
| 292 | |
| 293 | static_libs: [ |
| 294 | "libasyncio", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 295 | "libcrypto_utils", |
| 296 | "libcrypto", |
| 297 | "libdiagnose_usb", |
| 298 | "libqemu_pipe", |
| 299 | "libbase", |
| 300 | ], |
Jerry Zhang | b156c60 | 2018-05-07 15:14:47 -0700 | [diff] [blame] | 301 | |
| 302 | export_include_dirs: [ |
| 303 | "daemon/include", |
| 304 | ], |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | cc_binary { |
| 308 | name: "adbd", |
| 309 | defaults: ["adb_defaults"], |
| 310 | |
Jiyong Park | a0e7504 | 2018-05-24 14:11:00 +0900 | [diff] [blame] | 311 | recovery_available: true, |
Josh Gao | 8db99f8 | 2018-03-06 12:57:27 -0800 | [diff] [blame] | 312 | |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 313 | srcs: [ |
| 314 | "daemon/main.cpp", |
| 315 | "daemon/mdns.cpp", |
| 316 | "daemon/file_sync_service.cpp", |
| 317 | "daemon/framebuffer_service.cpp", |
| 318 | "daemon/remount_service.cpp", |
| 319 | "daemon/set_verity_enable_state_service.cpp", |
Josh Gao | 997cfac | 2018-07-25 18:15:52 -0700 | [diff] [blame^] | 320 | "daemon/services.cpp", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 321 | "daemon/shell_service.cpp", |
| 322 | "shell_service_protocol.cpp", |
| 323 | ], |
| 324 | |
| 325 | cflags: [ |
| 326 | "-D_GNU_SOURCE", |
| 327 | "-Wno-deprecated-declarations", |
| 328 | ], |
| 329 | |
| 330 | strip: { |
| 331 | keep_symbols: true, |
| 332 | }, |
| 333 | |
| 334 | static_libs: [ |
| 335 | "libadbd", |
| 336 | "libasyncio", |
| 337 | "libavb_user", |
| 338 | "libbootloader_message", |
| 339 | "libcrypto_utils", |
| 340 | "libcrypto", |
| 341 | "libdiagnose_usb", |
| 342 | "libfec", |
| 343 | "libfec_rs", |
| 344 | "libfs_mgr", |
| 345 | "liblog", |
| 346 | "libext4_utils", |
| 347 | "libmdnssd", |
| 348 | "libminijail", |
| 349 | "libselinux", |
| 350 | "libsquashfs_utils", |
| 351 | "libqemu_pipe", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 352 | |
| 353 | "libbase", |
| 354 | "libcutils", |
| 355 | ], |
| 356 | } |
| 357 | |
| 358 | cc_test { |
| 359 | name: "adbd_test", |
| 360 | defaults: ["adb_defaults"], |
| 361 | srcs: libadb_test_srcs + [ |
Josh Gao | 997cfac | 2018-07-25 18:15:52 -0700 | [diff] [blame^] | 362 | "daemon/services.cpp", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 363 | "daemon/shell_service.cpp", |
| 364 | "daemon/shell_service_test.cpp", |
| 365 | "shell_service_protocol.cpp", |
| 366 | "shell_service_protocol_test.cpp", |
| 367 | ], |
| 368 | |
| 369 | static_libs: [ |
| 370 | "libadbd", |
| 371 | "libbase", |
Josh Gao | 997cfac | 2018-07-25 18:15:52 -0700 | [diff] [blame^] | 372 | "libbootloader_message", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 373 | "libcutils", |
| 374 | "libcrypto_utils", |
| 375 | "libcrypto", |
| 376 | "libdiagnose_usb", |
| 377 | "liblog", |
| 378 | "libusb", |
| 379 | "libmdnssd", |
Jiyong Park | 011ee12 | 2018-05-29 16:41:30 +0900 | [diff] [blame] | 380 | "libselinux", |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 381 | ], |
Elliott Hughes | 40fdf3f | 2018-04-27 16:12:06 -0700 | [diff] [blame] | 382 | test_suites: ["device-tests"], |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 383 | } |
| 384 | |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 385 | python_binary_host { |
Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 386 | name: "adb_integration_test_adb", |
| 387 | main: "test_adb.py", |
| 388 | srcs: [ |
| 389 | "test_adb.py", |
| 390 | ], |
| 391 | libs: [ |
| 392 | "adb_py", |
| 393 | ], |
| 394 | version: { |
| 395 | py2: { |
| 396 | enabled: true, |
| 397 | }, |
| 398 | py3: { |
| 399 | enabled: false, |
| 400 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 401 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | python_binary_host { |
Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 405 | name: "adb_integration_test_device", |
| 406 | main: "test_device.py", |
| 407 | srcs: [ |
| 408 | "test_device.py", |
| 409 | ], |
| 410 | libs: [ |
| 411 | "adb_py", |
| 412 | ], |
| 413 | version: { |
| 414 | py2: { |
| 415 | enabled: true, |
| 416 | }, |
| 417 | py3: { |
| 418 | enabled: false, |
| 419 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 420 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 421 | } |