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 | |
| 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. |
| 85 | libadb_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 | |
| 101 | libadb_posix_srcs = [ |
| 102 | "sysdeps_unix.cpp", |
| 103 | "sysdeps/posix/network.cpp", |
| 104 | ] |
| 105 | |
| 106 | libadb_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 | |
| 118 | cc_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 | |
| 162 | cc_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 | |
| 178 | cc_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 | |
| 236 | cc_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 | |
| 259 | cc_binary { |
| 260 | name: "adbd", |
| 261 | defaults: ["adb_defaults"], |
| 262 | |
Josh Gao | 8db99f8 | 2018-03-06 12:57:27 -0800 | [diff] [blame^] | 263 | // adbd must be static, as it is copied into the recovery image. |
| 264 | static_executable: true, |
| 265 | |
Josh Gao | 2776845 | 2018-01-02 12:01:43 -0800 | [diff] [blame] | 266 | srcs: [ |
| 267 | "daemon/main.cpp", |
| 268 | "daemon/mdns.cpp", |
| 269 | "daemon/file_sync_service.cpp", |
| 270 | "daemon/framebuffer_service.cpp", |
| 271 | "daemon/remount_service.cpp", |
| 272 | "daemon/set_verity_enable_state_service.cpp", |
| 273 | "daemon/shell_service.cpp", |
| 274 | "shell_service_protocol.cpp", |
| 275 | ], |
| 276 | |
| 277 | cflags: [ |
| 278 | "-D_GNU_SOURCE", |
| 279 | "-Wno-deprecated-declarations", |
| 280 | ], |
| 281 | |
| 282 | strip: { |
| 283 | keep_symbols: true, |
| 284 | }, |
| 285 | |
| 286 | static_libs: [ |
| 287 | "libadbd", |
| 288 | "libasyncio", |
| 289 | "libavb_user", |
| 290 | "libbootloader_message", |
| 291 | "libcrypto_utils", |
| 292 | "libcrypto", |
| 293 | "libdiagnose_usb", |
| 294 | "libfec", |
| 295 | "libfec_rs", |
| 296 | "libfs_mgr", |
| 297 | "liblog", |
| 298 | "libext4_utils", |
| 299 | "libmdnssd", |
| 300 | "libminijail", |
| 301 | "libselinux", |
| 302 | "libsquashfs_utils", |
| 303 | "libqemu_pipe", |
| 304 | "libdebuggerd_handler", |
| 305 | |
| 306 | "libbase", |
| 307 | "libcutils", |
| 308 | ], |
| 309 | } |
| 310 | |
| 311 | cc_test { |
| 312 | name: "adbd_test", |
| 313 | defaults: ["adb_defaults"], |
| 314 | srcs: libadb_test_srcs + [ |
| 315 | "daemon/shell_service.cpp", |
| 316 | "daemon/shell_service_test.cpp", |
| 317 | "shell_service_protocol.cpp", |
| 318 | "shell_service_protocol_test.cpp", |
| 319 | ], |
| 320 | |
| 321 | static_libs: [ |
| 322 | "libadbd", |
| 323 | "libbase", |
| 324 | "libcutils", |
| 325 | "libcrypto_utils", |
| 326 | "libcrypto", |
| 327 | "libdiagnose_usb", |
| 328 | "liblog", |
| 329 | "libusb", |
| 330 | "libmdnssd", |
| 331 | ], |
| 332 | } |
| 333 | |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 334 | python_binary_host { |
Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 335 | name: "adb_integration_test_adb", |
| 336 | main: "test_adb.py", |
| 337 | srcs: [ |
| 338 | "test_adb.py", |
| 339 | ], |
| 340 | libs: [ |
| 341 | "adb_py", |
| 342 | ], |
| 343 | version: { |
| 344 | py2: { |
| 345 | enabled: true, |
| 346 | }, |
| 347 | py3: { |
| 348 | enabled: false, |
| 349 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 350 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | python_binary_host { |
Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 354 | name: "adb_integration_test_device", |
| 355 | main: "test_device.py", |
| 356 | srcs: [ |
| 357 | "test_device.py", |
| 358 | ], |
| 359 | libs: [ |
| 360 | "adb_py", |
| 361 | ], |
| 362 | version: { |
| 363 | py2: { |
| 364 | enabled: true, |
| 365 | }, |
| 366 | py3: { |
| 367 | enabled: false, |
| 368 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 369 | }, |
GuangHui Liu | 41bda34 | 2017-05-10 14:37:17 -0700 | [diff] [blame] | 370 | } |