1# Copyright 2005 The Android Open Source Project 2# 3# Android.mk for adb 4# 5 6LOCAL_PATH:= $(call my-dir) 7 8include $(LOCAL_PATH)/../platform_tools_tool_version.mk 9 10adb_host_sanitize := 11adb_target_sanitize := 12 13ADB_COMMON_CFLAGS := \ 14 -Wall -Wextra -Werror \ 15 -Wno-unused-parameter \ 16 -Wno-missing-field-initializers \ 17 -Wvla \ 18 -DADB_VERSION="\"$(tool_version)\"" \ 19 20ADB_COMMON_posix_CFLAGS := \ 21 -Wexit-time-destructors \ 22 -Wthread-safety \ 23 24ADB_COMMON_linux_CFLAGS := \ 25 $(ADB_COMMON_posix_CFLAGS) \ 26 27ADB_COMMON_darwin_CFLAGS := \ 28 $(ADB_COMMON_posix_CFLAGS) \ 29 30# Define windows.h and tchar.h Unicode preprocessor symbols so that 31# CreateFile(), _tfopen(), etc. map to versions that take wchar_t*, breaking the 32# build if you accidentally pass char*. Fix by calling like: 33# std::wstring path_wide; 34# if (!android::base::UTF8ToWide(path_utf8, &path_wide)) { /* error handling */ } 35# CreateFileW(path_wide.c_str()); 36ADB_COMMON_windows_CFLAGS := \ 37 -DUNICODE=1 -D_UNICODE=1 \ 38 39# libadb 40# ========================================================= 41 42# Much of adb is duplicated in bootable/recovery/minadb and fastboot. Changes 43# made to adb rarely get ported to the other two, so the trees have diverged a 44# bit. We'd like to stop this because it is a maintenance nightmare, but the 45# divergence makes this difficult to do all at once. For now, we will start 46# small by moving common files into a static library. Hopefully some day we can 47# get enough of adb in here that we no longer need minadb. https://b/17626262 48LIBADB_SRC_FILES := \ 49 adb.cpp \ 50 adb_io.cpp \ 51 adb_listeners.cpp \ 52 adb_trace.cpp \ 53 adb_utils.cpp \ 54 fdevent.cpp \ 55 sockets.cpp \ 56 socket_spec.cpp \ 57 sysdeps/errno.cpp \ 58 transport.cpp \ 59 transport_local.cpp \ 60 transport_usb.cpp \ 61 62LIBADB_TEST_SRCS := \ 63 adb_io_test.cpp \ 64 adb_listeners_test.cpp \ 65 adb_utils_test.cpp \ 66 fdevent_test.cpp \ 67 socket_spec_test.cpp \ 68 socket_test.cpp \ 69 sysdeps_test.cpp \ 70 sysdeps/stat_test.cpp \ 71 transport_test.cpp \ 72 73LIBADB_CFLAGS := \ 74 $(ADB_COMMON_CFLAGS) \ 75 -fvisibility=hidden \ 76 77LIBADB_linux_CFLAGS := \ 78 $(ADB_COMMON_linux_CFLAGS) \ 79 80LIBADB_darwin_CFLAGS := \ 81 $(ADB_COMMON_darwin_CFLAGS) \ 82 83LIBADB_windows_CFLAGS := \ 84 $(ADB_COMMON_windows_CFLAGS) \ 85 86LIBADB_darwin_SRC_FILES := \ 87 sysdeps_unix.cpp \ 88 sysdeps/posix/network.cpp \ 89 client/usb_dispatch.cpp \ 90 client/usb_libusb.cpp \ 91 client/usb_osx.cpp \ 92 93LIBADB_linux_SRC_FILES := \ 94 sysdeps_unix.cpp \ 95 sysdeps/posix/network.cpp \ 96 client/usb_dispatch.cpp \ 97 client/usb_libusb.cpp \ 98 client/usb_linux.cpp \ 99 100LIBADB_windows_SRC_FILES := \ 101 sysdeps_win32.cpp \ 102 sysdeps/win32/errno.cpp \ 103 sysdeps/win32/stat.cpp \ 104 client/usb_windows.cpp \ 105 106LIBADB_TEST_windows_SRCS := \ 107 sysdeps/win32/errno_test.cpp \ 108 sysdeps_win32_test.cpp \ 109 110include $(CLEAR_VARS) 111LOCAL_CLANG := true 112LOCAL_MODULE := libadbd_usb 113LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=0 114LOCAL_SRC_FILES := daemon/usb.cpp 115 116LOCAL_SANITIZE := $(adb_target_sanitize) 117 118# Even though we're building a static library (and thus there's no link step for 119# this to take effect), this adds the includes to our path. 120LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libbase 121 122include $(BUILD_STATIC_LIBRARY) 123 124include $(CLEAR_VARS) 125LOCAL_CLANG := true 126LOCAL_MODULE := libadbd 127LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=0 128LOCAL_SRC_FILES := \ 129 $(LIBADB_SRC_FILES) \ 130 adbd_auth.cpp \ 131 jdwp_service.cpp \ 132 sysdeps/posix/network.cpp \ 133 134LOCAL_SANITIZE := $(adb_target_sanitize) 135 136# Even though we're building a static library (and thus there's no link step for 137# this to take effect), this adds the includes to our path. 138LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libqemu_pipe libbase 139 140LOCAL_WHOLE_STATIC_LIBRARIES := libadbd_usb 141 142include $(BUILD_STATIC_LIBRARY) 143 144include $(CLEAR_VARS) 145LOCAL_MODULE := libadb 146LOCAL_MODULE_HOST_OS := darwin linux windows 147LOCAL_CFLAGS := $(LIBADB_CFLAGS) -DADB_HOST=1 148LOCAL_CFLAGS_windows := $(LIBADB_windows_CFLAGS) 149LOCAL_CFLAGS_linux := $(LIBADB_linux_CFLAGS) 150LOCAL_CFLAGS_darwin := $(LIBADB_darwin_CFLAGS) 151LOCAL_SRC_FILES := \ 152 $(LIBADB_SRC_FILES) \ 153 adb_auth_host.cpp \ 154 transport_mdns.cpp \ 155 156LOCAL_SRC_FILES_darwin := $(LIBADB_darwin_SRC_FILES) 157LOCAL_SRC_FILES_linux := $(LIBADB_linux_SRC_FILES) 158LOCAL_SRC_FILES_windows := $(LIBADB_windows_SRC_FILES) 159 160LOCAL_SANITIZE := $(adb_host_sanitize) 161 162# Even though we're building a static library (and thus there's no link step for 163# this to take effect), this adds the includes to our path. 164LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libbase libmdnssd 165LOCAL_STATIC_LIBRARIES_linux := libusb 166LOCAL_STATIC_LIBRARIES_darwin := libusb 167 168LOCAL_C_INCLUDES_windows := development/host/windows/usb/api/ 169LOCAL_MULTILIB := first 170 171include $(BUILD_HOST_STATIC_LIBRARY) 172 173include $(CLEAR_VARS) 174LOCAL_CLANG := true 175LOCAL_MODULE := adbd_test 176LOCAL_CFLAGS := -DADB_HOST=0 $(LIBADB_CFLAGS) 177LOCAL_SRC_FILES := \ 178 $(LIBADB_TEST_SRCS) \ 179 $(LIBADB_TEST_linux_SRCS) \ 180 shell_service.cpp \ 181 shell_service_protocol.cpp \ 182 shell_service_protocol_test.cpp \ 183 shell_service_test.cpp \ 184 185LOCAL_SANITIZE := $(adb_target_sanitize) 186LOCAL_STATIC_LIBRARIES := libadbd libcrypto_utils libcrypto libusb libmdnssd 187LOCAL_SHARED_LIBRARIES := liblog libbase libcutils 188include $(BUILD_NATIVE_TEST) 189 190# libdiagnose_usb 191# ========================================================= 192 193include $(CLEAR_VARS) 194LOCAL_MODULE := libdiagnose_usb 195LOCAL_MODULE_HOST_OS := darwin linux windows 196LOCAL_CFLAGS := $(LIBADB_CFLAGS) 197LOCAL_SRC_FILES := diagnose_usb.cpp 198# Even though we're building a static library (and thus there's no link step for 199# this to take effect), this adds the includes to our path. 200LOCAL_STATIC_LIBRARIES := libbase 201include $(BUILD_HOST_STATIC_LIBRARY) 202 203# adb_test 204# ========================================================= 205 206include $(CLEAR_VARS) 207LOCAL_MODULE := adb_test 208LOCAL_MODULE_HOST_OS := darwin linux windows 209LOCAL_CFLAGS := -DADB_HOST=1 $(LIBADB_CFLAGS) 210LOCAL_CFLAGS_windows := $(LIBADB_windows_CFLAGS) 211LOCAL_CFLAGS_linux := $(LIBADB_linux_CFLAGS) 212LOCAL_CFLAGS_darwin := $(LIBADB_darwin_CFLAGS) 213LOCAL_SRC_FILES := \ 214 $(LIBADB_TEST_SRCS) \ 215 adb_client.cpp \ 216 bugreport.cpp \ 217 bugreport_test.cpp \ 218 line_printer.cpp \ 219 services.cpp \ 220 shell_service_protocol.cpp \ 221 shell_service_protocol_test.cpp \ 222 223LOCAL_SRC_FILES_linux := $(LIBADB_TEST_linux_SRCS) 224LOCAL_SRC_FILES_darwin := $(LIBADB_TEST_darwin_SRCS) 225LOCAL_SRC_FILES_windows := $(LIBADB_TEST_windows_SRCS) 226LOCAL_SANITIZE := $(adb_host_sanitize) 227LOCAL_STATIC_LIBRARIES := \ 228 libadb \ 229 libbase \ 230 libcrypto_utils \ 231 libcrypto \ 232 libcutils \ 233 libdiagnose_usb \ 234 libmdnssd \ 235 libgmock_host \ 236 237LOCAL_STATIC_LIBRARIES_linux := libusb 238LOCAL_STATIC_LIBRARIES_darwin := libusb 239 240# Set entrypoint to wmain from sysdeps_win32.cpp instead of main 241LOCAL_LDFLAGS_windows := -municode 242LOCAL_LDLIBS_linux := -lrt -ldl -lpthread 243LOCAL_LDLIBS_darwin := -framework CoreFoundation -framework IOKit -lobjc 244LOCAL_LDLIBS_windows := -lws2_32 -luserenv 245LOCAL_STATIC_LIBRARIES_windows := AdbWinApi 246 247LOCAL_MULTILIB := first 248 249include $(BUILD_HOST_NATIVE_TEST) 250 251# adb host tool 252# ========================================================= 253include $(CLEAR_VARS) 254 255LOCAL_LDLIBS_linux := -lrt -ldl -lpthread 256 257LOCAL_LDLIBS_darwin := -lpthread -framework CoreFoundation -framework IOKit -framework Carbon -lobjc 258 259# Use wmain instead of main 260LOCAL_LDFLAGS_windows := -municode 261LOCAL_LDLIBS_windows := -lws2_32 -lgdi32 262LOCAL_STATIC_LIBRARIES_windows := AdbWinApi 263LOCAL_REQUIRED_MODULES_windows := AdbWinApi AdbWinUsbApi 264 265LOCAL_SRC_FILES := \ 266 adb_client.cpp \ 267 bugreport.cpp \ 268 client/main.cpp \ 269 console.cpp \ 270 commandline.cpp \ 271 file_sync_client.cpp \ 272 line_printer.cpp \ 273 services.cpp \ 274 shell_service_protocol.cpp \ 275 276LOCAL_CFLAGS += \ 277 $(ADB_COMMON_CFLAGS) \ 278 -D_GNU_SOURCE \ 279 -DADB_HOST=1 \ 280 281LOCAL_CFLAGS_windows := \ 282 $(ADB_COMMON_windows_CFLAGS) 283 284LOCAL_CFLAGS_linux := \ 285 $(ADB_COMMON_linux_CFLAGS) \ 286 287LOCAL_CFLAGS_darwin := \ 288 $(ADB_COMMON_darwin_CFLAGS) \ 289 -Wno-sizeof-pointer-memaccess -Wno-unused-parameter \ 290 291LOCAL_MODULE := adb 292LOCAL_MODULE_TAGS := debug 293LOCAL_MODULE_HOST_OS := darwin linux windows 294 295LOCAL_SANITIZE := $(adb_host_sanitize) 296LOCAL_STATIC_LIBRARIES := \ 297 libadb \ 298 libbase \ 299 libcrypto_utils \ 300 libcrypto \ 301 libdiagnose_usb \ 302 liblog \ 303 libmdnssd \ 304 305# Don't use libcutils on Windows. 306LOCAL_STATIC_LIBRARIES_darwin := libcutils 307LOCAL_STATIC_LIBRARIES_linux := libcutils 308 309LOCAL_STATIC_LIBRARIES_darwin += libusb 310LOCAL_STATIC_LIBRARIES_linux += libusb 311 312LOCAL_CXX_STL := libc++_static 313 314# Don't add anything here, we don't want additional shared dependencies 315# on the host adb tool, and shared libraries that link against libc++ 316# will violate ODR 317LOCAL_SHARED_LIBRARIES := 318 319include $(BUILD_HOST_EXECUTABLE) 320 321$(call dist-for-goals,dist_files sdk win_sdk,$(LOCAL_BUILT_MODULE)) 322ifdef HOST_CROSS_OS 323# Archive adb.exe for win_sdk build. 324$(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_adb.BUILT)) 325endif 326 327 328# adbd device daemon 329# ========================================================= 330 331include $(CLEAR_VARS) 332 333LOCAL_CLANG := true 334 335LOCAL_SRC_FILES := \ 336 daemon/main.cpp \ 337 daemon/mdns.cpp \ 338 services.cpp \ 339 file_sync_service.cpp \ 340 framebuffer_service.cpp \ 341 remount_service.cpp \ 342 set_verity_enable_state_service.cpp \ 343 shell_service.cpp \ 344 shell_service_protocol.cpp \ 345 346LOCAL_CFLAGS := \ 347 $(ADB_COMMON_CFLAGS) \ 348 $(ADB_COMMON_linux_CFLAGS) \ 349 -DADB_HOST=0 \ 350 -D_GNU_SOURCE \ 351 -Wno-deprecated-declarations \ 352 353LOCAL_CFLAGS += -DALLOW_ADBD_NO_AUTH=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0) 354 355ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 356LOCAL_CFLAGS += -DALLOW_ADBD_DISABLE_VERITY=1 357LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1 358endif 359 360LOCAL_MODULE := adbd 361 362LOCAL_FORCE_STATIC_EXECUTABLE := true 363 364LOCAL_SANITIZE := $(adb_target_sanitize) 365LOCAL_STRIP_MODULE := keep_symbols 366LOCAL_STATIC_LIBRARIES := \ 367 libadbd \ 368 libavb_user \ 369 libbase \ 370 libqemu_pipe \ 371 libbootloader_message \ 372 libfs_mgr \ 373 libfec \ 374 libfec_rs \ 375 libselinux \ 376 liblog \ 377 libext4_utils \ 378 libsquashfs_utils \ 379 libcutils \ 380 libbase \ 381 libcrypto_utils \ 382 libcrypto \ 383 libminijail \ 384 libmdnssd \ 385 libdebuggerd_handler \ 386 387include $(BUILD_EXECUTABLE) 388 389# adb integration test 390# ========================================================= 391$(call dist-for-goals,sdk,$(ALL_MODULES.adb_integration_test_adb.BUILT)) 392$(call dist-for-goals,sdk,$(ALL_MODULES.adb_integration_test_device.BUILT)) 393 394include $(call first-makefiles-under,$(LOCAL_PATH)) 395