1 ########################################################### 2 ## Standard rules for building binary object files from 3 ## asm/c/cpp/yacc/lex/etc source files. 4 ## 5 ## The list of object files is exported in $(all_objects). 6 ########################################################### 7 8 ####################################### 9 include $(BUILD_SYSTEM)/base_rules.mk 10 ####################################### 11 12 ################################################## 13 # Compute the dependency of the shared libraries 14 ################################################## 15 # On the target, we compile with -nostdlib, so we must add in the 16 # default system shared libraries, unless they have requested not 17 # to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would 18 # supply that, for example, when building libc itself. 19 ifdef LOCAL_IS_HOST_MODULE 20 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) 21 my_system_shared_libraries := 22 else 23 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) 24 endif 25 else 26 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) 27 my_system_shared_libraries := libc libm libdl 28 else 29 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) 30 my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries)) 31 endif 32 endif 33 34 my_soong_problems := 35 36 # The following LOCAL_ variables will be modified in this file. 37 # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, 38 # we can't modify them in place. 39 my_src_files := $(LOCAL_SRC_FILES) 40 my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE) 41 my_static_libraries := $(LOCAL_STATIC_LIBRARIES) 42 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) 43 my_shared_libraries := $(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES)) 44 my_header_libraries := $(LOCAL_HEADER_LIBRARIES) 45 my_cflags := $(LOCAL_CFLAGS) 46 my_conlyflags := $(LOCAL_CONLYFLAGS) 47 my_cppflags := $(LOCAL_CPPFLAGS) 48 my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE) 49 my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE) 50 my_ldflags := $(LOCAL_LDFLAGS) 51 my_ldlibs := $(LOCAL_LDLIBS) 52 my_asflags := $(LOCAL_ASFLAGS) 53 my_cc := $(LOCAL_CC) 54 my_cc_wrapper := $(CC_WRAPPER) 55 my_cxx := $(LOCAL_CXX) 56 my_cxx_ldlibs := 57 my_cxx_wrapper := $(CXX_WRAPPER) 58 my_c_includes := $(LOCAL_C_INCLUDES) 59 my_generated_sources := $(LOCAL_GENERATED_SOURCES) 60 my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES) 61 my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS) 62 my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS) 63 my_arflags := 64 65 ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH))))) 66 ifeq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_EXCLUDE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH))))) 67 my_native_coverage := true 68 else 69 my_native_coverage := false 70 endif 71 else 72 my_native_coverage := false 73 endif 74 75 my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)) 76 ifdef SANITIZE_HOST 77 ifdef LOCAL_IS_HOST_MODULE 78 my_allow_undefined_symbols := true 79 endif 80 endif 81 82 my_ndk_sysroot := 83 my_ndk_sysroot_include := 84 my_ndk_sysroot_lib := 85 ifneq ($(LOCAL_SDK_VERSION),) 86 ifdef LOCAL_IS_HOST_MODULE 87 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) 88 endif 89 90 # Make sure we've built the NDK. 91 my_additional_dependencies += $(SOONG_OUT_DIR)/ndk.timestamp 92 93 # mips32r6 is not supported by the NDK. No released NDK contains these 94 # libraries, but the r10 in prebuilts/ndk had a local hack to add them :( 95 # 96 # We need to find a real solution to this problem, but until we do just drop 97 # mips32r6 things back to r10 to get the tree building again. 98 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) 99 ifeq ($(LOCAL_NDK_VERSION), current) 100 LOCAL_NDK_VERSION := r10 101 endif 102 endif 103 104 my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 105 ifneq (,$(filter arm64 mips64 x86_64,$(my_arch))) 106 my_min_sdk_version := 21 107 else 108 my_min_sdk_version := 9 109 endif 110 111 # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map 112 # missing API levels to existing ones where necessary, but we're not doing 113 # that for the generated libraries. Clip the API level to the minimum where 114 # appropriate. 115 my_ndk_api := $(LOCAL_SDK_VERSION) 116 ifneq ($(my_ndk_api),current) 117 my_ndk_api := $(call math_max,$(my_ndk_api),$(my_min_sdk_version)) 118 endif 119 120 my_ndk_api_def := $(my_ndk_api) 121 my_ndk_hist_api := $(my_ndk_api) 122 ifeq ($(my_ndk_api),current) 123 my_ndk_api_def := __ANDROID_API_FUTURE__ 124 # The last API level supported by the old prebuilt NDKs. 125 my_ndk_hist_api := 24 126 endif 127 128 129 # Traditionally this has come from android/api-level.h, but with the libc 130 # headers unified it must be set by the build system since we don't have 131 # per-API level copies of that header now. 132 my_cflags += -D__ANDROID_API__=$(my_ndk_api_def) 133 134 my_ndk_source_root := \ 135 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources 136 my_ndk_sysroot := \ 137 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_hist_api)/arch-$(my_arch) 138 my_built_ndk := $(SOONG_OUT_DIR)/ndk 139 my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE) 140 my_ndk_sysroot_include := \ 141 $(my_built_ndk)/sysroot/usr/include \ 142 $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \ 143 $(my_ndk_sysroot)/usr/include \ 144 145 # x86_64 and and mips64 are both multilib toolchains, so their libraries are 146 # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib 147 # compiler, so its libraries are in /usr/lib. 148 # 149 # Mips32r6 is yet another variation, with libraries installed in libr6. 150 # 151 # For the rest, the libraries are installed simply to /usr/lib. 152 ifneq (,$(filter x86_64 mips64,$(my_arch))) 153 my_ndk_libdir_name := lib64 154 else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) 155 my_ndk_libdir_name := libr6 156 else 157 my_ndk_libdir_name := lib 158 endif 159 160 my_ndk_platform_dir := \ 161 $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch) 162 my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name) 163 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name) 164 165 # The bionic linker now has support for packed relocations and gnu style 166 # hashes (which are much faster!), but shipping to older devices requires 167 # the old style hash. Fortunately, we can build with both and it'll work 168 # anywhere. 169 # 170 # This is not currently supported on MIPS architectures. 171 ifeq (,$(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 172 my_ldflags += -Wl,--hash-style=both 173 endif 174 175 # We don't want to expose the relocation packer to the NDK just yet. 176 LOCAL_PACK_MODULE_RELOCATIONS := false 177 178 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. 179 # See ndk/docs/CPLUSPLUS-SUPPORT.html 180 my_ndk_stl_include_path := 181 my_ndk_stl_shared_lib_fullpath := 182 my_ndk_stl_static_lib := 183 my_ndk_cpp_std_version := 184 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI) 185 ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) 186 my_cpu_variant := mips32r6 187 endif 188 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT)) 189 ifeq (,$(LOCAL_NDK_STL_VARIANT)) 190 LOCAL_NDK_STL_VARIANT := system 191 endif 192 ifneq (1,$(words $(filter none system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) 193 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) 194 endif 195 ifeq (system,$(LOCAL_NDK_STL_VARIANT)) 196 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include 197 my_system_shared_libraries += libstdc++ 198 else # LOCAL_NDK_STL_VARIANT is not system 199 ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) 200 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport 201 my_system_shared_libraries += libstdc++ 202 ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) 203 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a 204 my_ldlibs += -ldl 205 else 206 my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so 207 endif 208 else # LOCAL_NDK_STL_VARIANT is not stlport_* either 209 ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT))) 210 # Pre-r11 NDKs used libgabi++ for libc++'s C++ ABI, but r11 and later use 211 # libc++abi. 212 # 213 # r13 no longer has the inner directory as a side effect of just using 214 # external/libcxx. 215 ifeq (r10,$(LOCAL_NDK_VERSION)) 216 my_ndk_stl_include_path := \ 217 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include 218 my_ndk_stl_include_path += \ 219 $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include 220 else ifeq (r11,$(LOCAL_NDK_VERSION)) 221 my_ndk_stl_include_path := \ 222 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include 223 my_ndk_stl_include_path += \ 224 $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/libcxxabi/include 225 else 226 my_ndk_stl_include_path := \ 227 $(my_ndk_source_root)/cxx-stl/llvm-libc++/include 228 my_ndk_stl_include_path += \ 229 $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/include 230 endif 231 my_ndk_stl_include_path += $(my_ndk_source_root)/android/support/include 232 233 my_libcxx_libdir := \ 234 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant) 235 236 ifneq (,$(filter r10 r11,$(LOCAL_NDK_VERSION))) 237 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) 238 my_ndk_stl_static_lib := $(my_libcxx_libdir)/libc++_static.a 239 else 240 my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so 241 endif 242 else 243 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) 244 my_ndk_stl_static_lib := \ 245 $(my_libcxx_libdir)/libc++_static.a \ 246 $(my_libcxx_libdir)/libc++abi.a 247 else 248 my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so 249 endif 250 251 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libandroid_support.a 252 ifneq (,$(filter armeabi armeabi-v7a,$(my_cpu_variant))) 253 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a 254 endif 255 endif 256 257 my_ldlibs += -ldl 258 259 my_ndk_cpp_std_version := c++11 260 else # LOCAL_NDK_STL_VARIANT is not c++_* either 261 ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT))) 262 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \ 263 $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include 264 my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/libgnustl_static.a 265 else # LOCAL_NDK_STL_VARIANT must be none 266 # Do nothing. 267 endif 268 endif 269 endif 270 endif 271 endif 272 273 ifneq ($(LOCAL_USE_VNDK),) 274 my_cflags += -D__ANDROID_API__=__ANDROID_API_FUTURE__ -D__ANDROID_VNDK__ 275 endif 276 277 ifndef LOCAL_IS_HOST_MODULE 278 # For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We 279 # no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're 280 # linking my_shared_libraries by full path now. 281 my_allowed_ldlibs := 282 283 # Sort ldlibs and ldflags between -l and other linker flags 284 # We'll do this again later, since there are still changes happening, but that's fine. 285 my_ldlib_flags := $(my_ldflags) $(my_ldlibs) 286 my_ldlibs := $(filter -l%,$(my_ldlib_flags)) 287 my_ldflags := $(filter-out -l%,$(my_ldlib_flags)) 288 my_ldlib_flags := 289 290 # Move other ldlibs back to shared libraries 291 my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs))) 292 my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs)) 293 endif 294 295 ifneq ($(LOCAL_SDK_VERSION),) 296 my_all_ndk_libraries := \ 297 $(NDK_MIGRATED_LIBS) $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES)) 298 my_ndk_shared_libraries := \ 299 $(filter $(my_all_ndk_libraries),\ 300 $(my_shared_libraries) $(my_system_shared_libraries)) 301 302 my_shared_libraries := \ 303 $(filter-out $(my_all_ndk_libraries),$(my_shared_libraries)) 304 my_system_shared_libraries := \ 305 $(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries)) 306 endif 307 308 # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because 309 # all code is position independent, and then those warnings get promoted to 310 # errors. 311 ifneq ($(LOCAL_NO_PIC),true) 312 ifneq ($($(my_prefix)OS),windows) 313 ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) 314 my_cflags += -fPIE 315 else 316 my_cflags += -fPIC 317 endif 318 endif 319 endif 320 321 ifdef LOCAL_IS_HOST_MODULE 322 my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) 323 my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS)) 324 my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS)) 325 my_header_libraries += $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)OS)) 326 my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS)) 327 my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS)) 328 my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS)) 329 my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS)) 330 my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS)) 331 my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS)) 332 my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS)) 333 endif 334 335 my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) 336 my_src_files_exclude += $(LOCAL_SRC_FILES_EXCLUDE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_EXCLUDE_$(my_32_64_bit_suffix)) 337 my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) 338 my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) 339 my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) 340 my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) 341 my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) 342 my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) 343 my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix)) 344 345 my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude)) 346 ifneq ($(my_missing_exclude_files),) 347 $(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES) 348 $(error $(my_missing_exclude_files)) 349 endif 350 my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files)) 351 352 # Strip '/' from the beginning of each src file. This helps the ../ detection in case 353 # the source file is in the form of /../file 354 my_src_files := $(patsubst /%,%,$(my_src_files)) 355 356 my_clang := $(strip $(LOCAL_CLANG)) 357 ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) 358 my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) 359 endif 360 ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 361 my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 362 endif 363 364 # if custom toolchain is in use, default is not to use clang, if not explicitly required 365 ifneq ($(my_cc)$(my_cxx),) 366 ifeq ($(my_clang),) 367 my_clang := false 368 endif 369 endif 370 # Issue warning if LOCAL_CLANG* is set to false and the local makefile is not found 371 # in the exception project list. 372 ifeq ($(my_clang),false) 373 ifeq ($(call find_in_local_clang_exception_projects,$(LOCAL_MODULE_MAKEFILE))$(LOCAL_IS_AUX_MODULE),) 374 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_CLANG is set to false) 375 endif 376 endif 377 378 # clang is enabled by default for host builds 379 # enable it unless we've specifically disabled clang above 380 ifdef LOCAL_IS_HOST_MODULE 381 ifeq ($($(my_prefix)OS),windows) 382 ifeq ($(my_clang),true) 383 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Clang is not yet supported for windows binaries) 384 endif 385 my_clang := false 386 else 387 ifeq ($(my_clang),) 388 my_clang := true 389 endif 390 endif 391 # Add option to make gcc the default for device build 392 else ifeq ($(USE_CLANG_PLATFORM_BUILD),false) 393 ifeq ($(my_clang),) 394 my_clang := false 395 endif 396 else ifeq ($(my_clang),) 397 my_clang := true 398 endif 399 400 ifeq ($(LOCAL_C_STD),) 401 my_c_std_version := $(DEFAULT_C_STD_VERSION) 402 else ifeq ($(LOCAL_C_STD),experimental) 403 my_c_std_version := $(EXPERIMENTAL_C_STD_VERSION) 404 else 405 my_c_std_version := $(LOCAL_C_STD) 406 endif 407 408 ifeq ($(LOCAL_CPP_STD),) 409 my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION) 410 else ifeq ($(LOCAL_CPP_STD),experimental) 411 my_cpp_std_version := $(EXPERIMENTAL_CPP_STD_VERSION) 412 else 413 my_cpp_std_version := $(LOCAL_CPP_STD) 414 endif 415 416 ifneq ($(my_clang),true) 417 # GCC uses an invalid C++14 ABI (emits calls to 418 # __cxa_throw_bad_array_length, which is not a valid C++ RT ABI). 419 # http://b/25022512 420 my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION) 421 endif 422 423 ifdef LOCAL_SDK_VERSION 424 # The NDK handles this itself. 425 my_cpp_std_version := $(my_ndk_cpp_std_version) 426 endif 427 428 ifdef LOCAL_IS_HOST_MODULE 429 ifneq ($(my_clang),true) 430 # The host GCC doesn't support C++14 (and is deprecated, so likely 431 # never will). Build these modules with C++11. 432 my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION) 433 endif 434 endif 435 436 my_c_std_conlyflags := 437 my_cpp_std_cppflags := 438 ifneq (,$(my_c_std_version)) 439 my_c_std_conlyflags := -std=$(my_c_std_version) 440 endif 441 442 ifneq (,$(my_cpp_std_version)) 443 my_cpp_std_cppflags := -std=$(my_cpp_std_version) 444 endif 445 446 # arch-specific static libraries go first so that generic ones can depend on them 447 my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) 448 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries) 449 my_header_libraries := $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_HEADER_LIBRARIES_$(my_32_64_bit_suffix)) $(my_header_libraries) 450 451 # soong defined modules already have done through this 452 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 453 include $(BUILD_SYSTEM)/cxx_stl_setup.mk 454 endif 455 456 # Add static HAL libraries 457 ifdef LOCAL_HAL_STATIC_LIBRARIES 458 $(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ 459 $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ 460 $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ 461 $(eval my_static_libraries += $(lib).default))) 462 b_lib := 463 endif 464 465 ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),) 466 my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER) 467 else 468 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER) 469 endif 470 471 # Modules from soong do not need this since the dependencies are already handled there. 472 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 473 include $(BUILD_SYSTEM)/config_sanitizers.mk 474 475 ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true) 476 # Add in libcompiler_rt for all regular device builds 477 ifeq (,$(WITHOUT_LIBCOMPILER_RT)) 478 my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) 479 endif 480 endif 481 482 # Statically link libwinpthread when cross compiling win32. 483 ifeq ($($(my_prefix)OS),windows) 484 my_static_libraries += libwinpthread 485 endif 486 endif # this module is not from soong 487 488 ifneq ($(filter ../%,$(my_src_files)),) 489 my_soong_problems += dotdot_srcs 490 endif 491 ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),) 492 my_soong_problems += dotdot_incs 493 endif 494 ifneq ($(filter %.arm,$(my_src_files)),) 495 my_soong_problems += srcs_dotarm 496 endif 497 498 #################################################### 499 ## Add FDO flags if FDO is turned on and supported 500 ## Please note that we will do option filtering during FDO build. 501 ## i.e. Os->O2, remove -fno-early-inline and -finline-limit. 502 ################################################################## 503 my_fdo_build := 504 ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),) 505 ifeq ($(BUILD_FDO_INSTRUMENT),true) 506 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS) 507 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS) 508 my_fdo_build := true 509 else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),) 510 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS) 511 my_fdo_build := true 512 endif 513 # Disable ccache (or other compiler wrapper) except gomacc, which 514 # can handle -fprofile-use properly. 515 my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper)) 516 my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper)) 517 endif 518 519 ########################################################### 520 ## Explicitly declare assembly-only __ASSEMBLY__ macro for 521 ## assembly source 522 ########################################################### 523 my_asflags += -D__ASSEMBLY__ 524 525 ########################################################### 526 ## Define PRIVATE_ variables from global vars 527 ########################################################### 528 ifndef LOCAL_IS_HOST_MODULE 529 ifdef LOCAL_USE_VNDK 530 my_target_global_c_includes := \ 531 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) 532 my_target_global_c_system_includes := \ 533 $(TARGET_OUT_HEADERS) \ 534 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) 535 else ifdef LOCAL_SDK_VERSION 536 my_target_global_c_includes := 537 my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) 538 else ifdef BOARD_VNDK_VERSION 539 my_target_global_c_includes := $(SRC_HEADERS) \ 540 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \ 541 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) 542 my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \ 543 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \ 544 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES) 545 else 546 my_target_global_c_includes := $(SRC_HEADERS) \ 547 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \ 548 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) 549 my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) $(TARGET_OUT_HEADERS) \ 550 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \ 551 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES) 552 endif 553 554 ifeq ($(my_clang),true) 555 my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) 556 my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) 557 my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) 558 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) 559 else 560 my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) 561 my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) 562 my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) 563 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) 564 endif # my_clang 565 566 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes) 567 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes) 568 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) 569 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags) 570 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) 571 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) 572 573 else # LOCAL_IS_HOST_MODULE 574 575 my_host_global_c_includes := $(SRC_HEADERS) \ 576 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) 577 my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \ 578 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES) 579 580 ifeq ($(my_clang),true) 581 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) 582 my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) 583 my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) 584 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) 585 else 586 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) 587 my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) 588 my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) 589 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) 590 endif # my_clang 591 592 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes) 593 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes) 594 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) 595 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags) 596 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) 597 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) 598 endif # LOCAL_IS_HOST_MODULE 599 600 # To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and 601 # build with NATIVE_COVERAGE=true in your enviornment. Note that the build 602 # system is not sensitive to changes to NATIVE_COVERAGE, so you should do a 603 # clean build of your module after toggling it. 604 ifeq ($(NATIVE_COVERAGE),true) 605 ifeq ($(my_native_coverage),true) 606 # Note that clang coverage doesn't play nicely with acov out of the box. 607 # Clang apparently generates .gcno files that aren't compatible with 608 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov 609 # with `--gcov-tool /usr/bin/gcov-4.6`. 610 # 611 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output 612 my_cflags += --coverage -O0 613 my_ldflags += --coverage 614 endif 615 616 ifeq ($(my_clang),true) 617 my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT) 618 else 619 my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,$(filter AUX,$(my_kind)),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a 620 endif 621 622 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib) 623 $(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib) 624 else 625 my_native_coverage := false 626 endif 627 628 ########################################################### 629 ## Define PRIVATE_ variables used by multiple module types 630 ########################################################### 631 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ 632 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) 633 634 ifeq ($(strip $(WITH_STATIC_ANALYZER)),) 635 LOCAL_NO_STATIC_ANALYZER := true 636 endif 637 638 # Clang does not recognize all gcc flags. 639 # Use static analyzer only if clang is used. 640 ifneq ($(my_clang),true) 641 LOCAL_NO_STATIC_ANALYZER := true 642 endif 643 644 ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) 645 my_syntax_arch := host 646 else 647 my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 648 endif 649 650 ifeq ($(strip $(my_cc)),) 651 ifeq ($(my_clang),true) 652 my_cc := $(CLANG) 653 else 654 my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) 655 endif 656 my_cc := $(my_cc_wrapper) $(my_cc) 657 endif 658 659 ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 660 my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \ 661 $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer 662 endif 663 664 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) 665 666 ifeq ($(strip $(my_cxx)),) 667 ifeq ($(my_clang),true) 668 my_cxx := $(CLANG_CXX) 669 else 670 my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) 671 endif 672 my_cxx := $(my_cxx_wrapper) $(my_cxx) 673 endif 674 675 ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) 676 my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \ 677 $(SYNTAX_TOOLS_PREFIX)/c++-analyzer 678 endif 679 680 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker) 681 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) 682 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) 683 684 # TODO: support a mix of standard extensions so that this isn't necessary 685 LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) 686 ifeq ($(LOCAL_CPP_EXTENSION),) 687 LOCAL_CPP_EXTENSION := .cpp 688 endif 689 690 # Certain modules like libdl have to have symbols resolved at runtime and blow 691 # up if --no-undefined is passed to the linker. 692 ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) 693 ifeq ($(my_allow_undefined_symbols),) 694 ifneq ($(HOST_OS),darwin) 695 my_ldflags += -Wl,--no-undefined 696 endif 697 else 698 ifdef LOCAL_IS_HOST_MODULE 699 ifeq ($(HOST_OS),darwin) 700 # darwin defaults to treating undefined symbols as errors 701 my_ldflags += -Wl,-undefined,dynamic_lookup 702 endif 703 endif 704 endif 705 endif 706 707 ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) 708 $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true 709 else 710 $(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := 711 endif 712 713 ########################################################### 714 ## Define arm-vs-thumb-mode flags. 715 ########################################################### 716 LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) 717 ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) 718 arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) 719 normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) 720 721 # Read the values from something like TARGET_arm_CFLAGS or 722 # TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't 723 # actually used (although they are usually empty). 724 arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) 725 normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) 726 ifeq ($(my_clang),true) 727 arm_objects_cflags := $(call convert-to-clang-flags,$(arm_objects_cflags)) 728 normal_objects_cflags := $(call convert-to-clang-flags,$(normal_objects_cflags)) 729 endif 730 731 else 732 arm_objects_mode := 733 normal_objects_mode := 734 arm_objects_cflags := 735 normal_objects_cflags := 736 endif 737 738 ########################################################### 739 ## Define per-module debugging flags. Users can turn on 740 ## debugging for a particular module by setting DEBUG_MODULE_ModuleName 741 ## to a non-empty value in their environment or buildspec.mk, 742 ## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the 743 ## debug flags that they want to use. 744 ########################################################### 745 ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) 746 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) 747 else 748 debug_cflags := 749 endif 750 751 #################################################### 752 ## Keep track of src -> obj mapping 753 #################################################### 754 755 my_tracked_gen_files := 756 my_tracked_src_files := 757 758 ########################################################### 759 ## Stuff source generated from one-off tools 760 ########################################################### 761 $(my_generated_sources): PRIVATE_MODULE := $(my_register_name) 762 763 my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) 764 765 $(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% 766 @echo "Copy: $@" 767 $(copy-file-to-target) 768 769 my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) 770 771 # Generated sources that will actually produce object files. 772 # Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES, 773 # since other compiled sources may depend on them, and we set up 774 # the dependencies. 775 my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources)) 776 777 ALL_GENERATED_SOURCES += $(my_generated_sources) 778 779 #################################################### 780 ## Compile RenderScript with reflected C++ 781 #################################################### 782 783 renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) 784 785 ifneq (,$(renderscript_sources)) 786 my_soong_problems += rs 787 788 renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) 789 RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp 790 renderscript_intermediate := $(intermediates)/renderscript 791 792 renderscript_target_api := 793 794 ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) 795 renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) 796 else 797 ifneq (,$(LOCAL_SDK_VERSION)) 798 # Set target-api for LOCAL_SDK_VERSIONs other than current. 799 ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) 800 renderscript_target_api := $(LOCAL_SDK_VERSION) 801 endif 802 endif # LOCAL_SDK_VERSION is set 803 endif # LOCAL_RENDERSCRIPT_TARGET_API is set 804 805 806 ifeq ($(LOCAL_RENDERSCRIPT_CC),) 807 LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) 808 endif 809 810 # Turn on all warnings and warnings as errors for RS compiles. 811 # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error 812 renderscript_flags := -Wall -Werror 813 renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) 814 # -m32 or -m64 815 renderscript_flags += -m$(my_32_64_bit_suffix) 816 817 renderscript_includes := \ 818 $(TOPDIR)external/clang/lib/Headers \ 819 $(TOPDIR)frameworks/rs/script_api/include \ 820 $(LOCAL_RENDERSCRIPT_INCLUDES) 821 822 ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) 823 renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) 824 endif 825 826 bc_dep_files := $(addprefix $(renderscript_intermediate)/, \ 827 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) 828 829 $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) 830 $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) 831 $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) 832 $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) 833 $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) 834 $(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) 835 $(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files) 836 $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) 837 $(transform-renderscripts-to-cpp-and-bc) 838 839 # include the dependency files (.d) generated by llvm-rs-cc. 840 $(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp)) 841 842 LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) 843 844 rs_generated_cpps := $(addprefix \ 845 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ 846 $(notdir $(renderscript_sources))))) 847 848 $(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps)) 849 850 # This is just a dummy rule to make sure gmake doesn't skip updating the dependents. 851 $(rs_generated_cpps) : $(RenderScript_file_stamp) 852 @echo "Updated RS generated cpp file $@." 853 $(hide) touch $@ 854 855 my_c_includes += $(renderscript_intermediate) 856 my_generated_sources += $(rs_generated_cpps) 857 858 endif 859 860 861 ########################################################### 862 ## Compile the .proto files to .cc (or .c) and then to .o 863 ########################################################### 864 proto_sources := $(filter %.proto,$(my_src_files)) 865 ifneq ($(proto_sources),) 866 proto_gen_dir := $(generated_sources_dir)/proto 867 proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) 868 869 my_rename_cpp_ext := 870 ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE))) 871 my_proto_source_suffix := .c 872 my_proto_c_includes := external/nanopb-c 873 my_protoc_flags := --nanopb_out=$(proto_gen_dir) \ 874 --plugin=external/nanopb-c/generator/protoc-gen-nanopb 875 my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options) 876 else 877 my_proto_source_suffix := $(LOCAL_CPP_EXTENSION) 878 ifneq ($(my_proto_source_suffix),.cc) 879 # aprotoc is hardcoded to write out only .cc file. 880 # We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc. 881 my_rename_cpp_ext := true 882 endif 883 my_proto_c_includes := external/protobuf/src 884 my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI 885 my_protoc_flags := --cpp_out=$(proto_gen_dir) 886 my_protoc_deps := 887 endif 888 my_proto_c_includes += $(proto_gen_dir) 889 890 proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \ 891 $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath))) 892 893 # Ensure the transform-proto-to-cc rule is only defined once in multilib build. 894 ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined 895 $(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP) 896 $(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags) 897 $(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext) 898 $(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC) 899 $(transform-proto-to-cc) 900 901 $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true 902 endif 903 # Ideally we can generate the source directly into $(intermediates). 904 # But many Android.mks assume the .pb.hs are in $(generated_sources_dir). 905 # As a workaround, we make a copy in the $(intermediates). 906 proto_intermediate_dir := $(intermediates)/proto 907 proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\ 908 $(proto_generated_cpps)) 909 $(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/% 910 @echo "Copy: $@" 911 $(copy-file-to-target) 912 $(hide) cp $(basename $<).h $(basename $@).h 913 $(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps)) 914 915 my_generated_sources += $(proto_intermediate_cpps) 916 917 my_c_includes += $(my_proto_c_includes) 918 # Auto-export the generated proto source dir. 919 my_export_c_include_dirs += $(my_proto_c_includes) 920 921 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc) 922 my_static_libraries += libprotobuf-c-nano-enable_malloc 923 else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c) 924 my_static_libraries += libprotobuf-c-nano 925 else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) 926 ifdef LOCAL_SDK_VERSION 927 my_static_libraries += libprotobuf-cpp-full-ndk 928 else 929 my_shared_libraries += libprotobuf-cpp-full 930 endif 931 else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static) 932 my_static_libraries += libprotobuf-cpp-lite 933 else 934 ifdef LOCAL_SDK_VERSION 935 my_static_libraries += libprotobuf-cpp-lite-ndk 936 else 937 my_shared_libraries += libprotobuf-cpp-lite 938 endif 939 endif 940 endif # $(proto_sources) non-empty 941 942 ########################################################### 943 ## AIDL: Compile .aidl files to .cpp and .h files 944 ########################################################### 945 aidl_src := $(strip $(filter %.aidl,$(my_src_files))) 946 aidl_gen_cpp := 947 ifneq ($(aidl_src),) 948 949 # Use the intermediates directory to avoid writing our own .cpp -> .o rules. 950 aidl_gen_cpp_root := $(intermediates)/aidl-generated/src 951 aidl_gen_include_root := $(intermediates)/aidl-generated/include 952 953 # Multi-architecture builds have distinct intermediates directories. 954 # Thus we'll actually generate source for each architecture. 955 $(foreach s,$(aidl_src),\ 956 $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp))) 957 $(foreach cpp,$(aidl_gen_cpp), \ 958 $(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp))) 959 $(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp)) 960 961 $(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) 962 $(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root) 963 $(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) 964 965 # Add generated headers to include paths. 966 my_c_includes += $(aidl_gen_include_root) 967 my_export_c_include_dirs += $(aidl_gen_include_root) 968 # Pick up the generated C++ files later for transformation to .o files. 969 my_generated_sources += $(aidl_gen_cpp) 970 971 endif # $(aidl_src) non-empty 972 973 ########################################################### 974 ## Compile the .vts files to .cc (or .c) and then to .o 975 ########################################################### 976 977 vts_src := $(strip $(filter %.vts,$(my_src_files))) 978 vts_gen_cpp := 979 ifneq ($(vts_src),) 980 my_soong_problems += vts 981 982 # Use the intermediates directory to avoid writing our own .cpp -> .o rules. 983 vts_gen_cpp_root := $(intermediates)/vts-generated/src 984 vts_gen_include_root := $(intermediates)/vts-generated/include 985 986 # Multi-architecture builds have distinct intermediates directories. 987 # Thus we'll actually generate source for each architecture. 988 $(foreach s,$(vts_src),\ 989 $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp))) 990 $(foreach cpp,$(vts_gen_cpp), \ 991 $(call include-depfile,$(addsuffix .vts.P,$(basename $(cpp))),$(cpp))) 992 $(call track-src-file-gen,$(vts_src),$(vts_gen_cpp)) 993 994 $(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) 995 $(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root) 996 $(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) $(addprefix -m,$(LOCAL_VTS_MODE)) 997 998 # Add generated headers to include paths. 999 my_c_includes += $(vts_gen_include_root) 1000 my_export_c_include_dirs += $(vts_gen_include_root) 1001 # Pick up the generated C++ files later for transformation to .o files. 1002 my_generated_sources += $(vts_gen_cpp) 1003 1004 endif # $(vts_src) non-empty 1005 1006 ########################################################### 1007 ## YACC: Compile .y/.yy files to .c/.cpp and then to .o. 1008 ########################################################### 1009 1010 y_yacc_sources := $(filter %.y,$(my_src_files)) 1011 y_yacc_cs := $(addprefix \ 1012 $(intermediates)/,$(y_yacc_sources:.y=.c)) 1013 ifneq ($(y_yacc_cs),) 1014 $(y_yacc_cs): $(intermediates)/%.c: \ 1015 $(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) \ 1016 $(my_additional_dependencies) 1017 $(call transform-y-to-c-or-cpp) 1018 $(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs)) 1019 1020 my_generated_sources += $(y_yacc_cs) 1021 endif 1022 1023 yy_yacc_sources := $(filter %.yy,$(my_src_files)) 1024 yy_yacc_cpps := $(addprefix \ 1025 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) 1026 ifneq ($(yy_yacc_cpps),) 1027 $(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 1028 $(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) \ 1029 $(my_additional_dependencies) 1030 $(call transform-y-to-c-or-cpp) 1031 $(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps)) 1032 1033 my_generated_sources += $(yy_yacc_cpps) 1034 endif 1035 1036 ########################################################### 1037 ## LEX: Compile .l/.ll files to .c/.cpp and then to .o. 1038 ########################################################### 1039 1040 l_lex_sources := $(filter %.l,$(my_src_files)) 1041 l_lex_cs := $(addprefix \ 1042 $(intermediates)/,$(l_lex_sources:.l=.c)) 1043 ifneq ($(l_lex_cs),) 1044 $(l_lex_cs): $(intermediates)/%.c: \ 1045 $(TOPDIR)$(LOCAL_PATH)/%.l 1046 $(transform-l-to-c-or-cpp) 1047 $(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs)) 1048 1049 my_generated_sources += $(l_lex_cs) 1050 endif 1051 1052 ll_lex_sources := $(filter %.ll,$(my_src_files)) 1053 ll_lex_cpps := $(addprefix \ 1054 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) 1055 ifneq ($(ll_lex_cpps),) 1056 $(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ 1057 $(TOPDIR)$(LOCAL_PATH)/%.ll 1058 $(transform-l-to-c-or-cpp) 1059 $(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps)) 1060 1061 my_generated_sources += $(ll_lex_cpps) 1062 endif 1063 1064 ########################################################### 1065 ## C++: Compile .cpp files to .o. 1066 ########################################################### 1067 1068 # we also do this on host modules, even though 1069 # it's not really arm, because there are files that are shared. 1070 cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) 1071 dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources)) 1072 cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources)) 1073 cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) 1074 $(call track-src-file-obj,$(patsubst %,%.arm,$(cpp_arm_sources)),$(cpp_arm_objects)) 1075 1076 # For source files starting with ../, we remove all the ../ in the object file path, 1077 # to avoid object file escaping the intermediate directory. 1078 dotdot_arm_objects := 1079 $(foreach s,$(dotdot_arm_sources),\ 1080 $(eval $(call compile-dotdot-cpp-file,$(s),\ 1081 $(my_additional_dependencies),\ 1082 dotdot_arm_objects))) 1083 $(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects)) 1084 1085 dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files)) 1086 dotdot_objects := 1087 $(foreach s,$(dotdot_sources),\ 1088 $(eval $(call compile-dotdot-cpp-file,$(s),\ 1089 $(my_additional_dependencies),\ 1090 dotdot_objects))) 1091 $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects)) 1092 1093 cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))) 1094 cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) 1095 $(call track-src-file-obj,$(cpp_normal_sources),$(cpp_normal_objects)) 1096 1097 $(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 1098 $(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 1099 $(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 1100 $(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 1101 1102 cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) 1103 1104 ifneq ($(strip $(cpp_objects)),) 1105 $(cpp_objects): $(intermediates)/%.o: \ 1106 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ 1107 $(my_additional_dependencies) 1108 $(transform-$(PRIVATE_HOST)cpp-to-o) 1109 $(call include-depfiles-for-objs, $(cpp_objects)) 1110 endif 1111 1112 cpp_objects += $(dotdot_arm_objects) $(dotdot_objects) 1113 1114 ########################################################### 1115 ## C++: Compile generated .cpp files to .o. 1116 ########################################################### 1117 1118 gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources)) 1119 gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) 1120 $(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects)) 1121 1122 ifneq ($(strip $(gen_cpp_objects)),) 1123 # Compile all generated files as thumb. 1124 # TODO: support compiling certain generated files as arm. 1125 $(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 1126 $(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 1127 $(gen_cpp_objects): $(intermediates)/%.o: \ 1128 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ 1129 $(my_additional_dependencies) 1130 $(transform-$(PRIVATE_HOST)cpp-to-o) 1131 $(call include-depfiles-for-objs, $(gen_cpp_objects)) 1132 endif 1133 1134 ########################################################### 1135 ## S: Compile generated .S and .s files to .o. 1136 ########################################################### 1137 1138 gen_S_sources := $(filter %.S,$(my_generated_sources)) 1139 gen_S_objects := $(gen_S_sources:%.S=%.o) 1140 $(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects)) 1141 1142 ifneq ($(strip $(gen_S_sources)),) 1143 $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ 1144 $(my_additional_dependencies) 1145 $(transform-$(PRIVATE_HOST)s-to-o) 1146 $(call include-depfiles-for-objs, $(gen_S_objects)) 1147 endif 1148 1149 gen_s_sources := $(filter %.s,$(my_generated_sources)) 1150 gen_s_objects := $(gen_s_sources:%.s=%.o) 1151 $(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects)) 1152 1153 ifneq ($(strip $(gen_s_objects)),) 1154 $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ 1155 $(my_additional_dependencies) 1156 $(transform-$(PRIVATE_HOST)s-to-o) 1157 endif 1158 1159 gen_asm_objects := $(gen_S_objects) $(gen_s_objects) 1160 $(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 1161 1162 ########################################################### 1163 ## o: Include generated .o files in output. 1164 ########################################################### 1165 1166 gen_o_objects := $(filter %.o,$(my_generated_sources)) 1167 1168 ########################################################### 1169 ## C: Compile .c files to .o. 1170 ########################################################### 1171 1172 c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) 1173 dotdot_arm_sources := $(filter ../%,$(c_arm_sources)) 1174 c_arm_sources := $(filter-out ../%,$(c_arm_sources)) 1175 c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) 1176 $(call track-src-file-obj,$(patsubst %,%.arm,$(c_arm_sources)),$(c_arm_objects)) 1177 1178 # For source files starting with ../, we remove all the ../ in the object file path, 1179 # to avoid object file escaping the intermediate directory. 1180 dotdot_arm_objects := 1181 $(foreach s,$(dotdot_arm_sources),\ 1182 $(eval $(call compile-dotdot-c-file,$(s),\ 1183 $(my_additional_dependencies),\ 1184 dotdot_arm_objects))) 1185 $(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects)) 1186 1187 dotdot_sources := $(filter ../%.c, $(my_src_files)) 1188 dotdot_objects := 1189 $(foreach s, $(dotdot_sources),\ 1190 $(eval $(call compile-dotdot-c-file,$(s),\ 1191 $(my_additional_dependencies),\ 1192 dotdot_objects))) 1193 $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects)) 1194 1195 c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files))) 1196 c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) 1197 $(call track-src-file-obj,$(c_normal_sources),$(c_normal_objects)) 1198 1199 $(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) 1200 $(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) 1201 $(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 1202 $(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 1203 1204 c_objects := $(c_arm_objects) $(c_normal_objects) 1205 1206 ifneq ($(strip $(c_objects)),) 1207 $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \ 1208 $(my_additional_dependencies) 1209 $(transform-$(PRIVATE_HOST)c-to-o) 1210 $(call include-depfiles-for-objs, $(c_objects)) 1211 endif 1212 1213 c_objects += $(dotdot_arm_objects) $(dotdot_objects) 1214 1215 ########################################################### 1216 ## C: Compile generated .c files to .o. 1217 ########################################################### 1218 1219 gen_c_sources := $(filter %.c,$(my_generated_sources)) 1220 gen_c_objects := $(gen_c_sources:%.c=%.o) 1221 $(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects)) 1222 1223 ifneq ($(strip $(gen_c_objects)),) 1224 # Compile all generated files as thumb. 1225 # TODO: support compiling certain generated files as arm. 1226 $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) 1227 $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 1228 $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \ 1229 $(my_additional_dependencies) 1230 $(transform-$(PRIVATE_HOST)c-to-o) 1231 $(call include-depfiles-for-objs, $(gen_c_objects)) 1232 endif 1233 1234 ########################################################### 1235 ## ObjC: Compile .m files to .o 1236 ########################################################### 1237 1238 objc_sources := $(filter %.m,$(my_src_files)) 1239 objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) 1240 $(call track-src-file-obj,$(objc_sources),$(objc_objects)) 1241 1242 ifneq ($(strip $(objc_objects)),) 1243 my_soong_problems += objc 1244 $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \ 1245 $(my_additional_dependencies) 1246 $(transform-$(PRIVATE_HOST)m-to-o) 1247 $(call include-depfiles-for-objs, $(objc_objects)) 1248 endif 1249 1250 ########################################################### 1251 ## ObjC++: Compile .mm files to .o 1252 ########################################################### 1253 1254 objcpp_sources := $(filter %.mm,$(my_src_files)) 1255 objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o)) 1256 $(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects)) 1257 1258 ifneq ($(strip $(objcpp_objects)),) 1259 $(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \ 1260 $(my_additional_dependencies) 1261 $(transform-$(PRIVATE_HOST)mm-to-o) 1262 $(call include-depfiles-for-objs, $(objcpp_objects)) 1263 endif 1264 1265 ########################################################### 1266 ## AS: Compile .S files to .o. 1267 ########################################################### 1268 1269 asm_sources_S := $(filter %.S,$(my_src_files)) 1270 dotdot_sources := $(filter ../%,$(asm_sources_S)) 1271 asm_sources_S := $(filter-out ../%,$(asm_sources_S)) 1272 asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) 1273 $(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S)) 1274 1275 dotdot_objects_S := 1276 $(foreach s,$(dotdot_sources),\ 1277 $(eval $(call compile-dotdot-s-file,$(s),\ 1278 $(my_additional_dependencies),\ 1279 dotdot_objects_S))) 1280 $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S)) 1281 1282 ifneq ($(strip $(asm_objects_S)),) 1283 $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ 1284 $(my_additional_dependencies) 1285 $(transform-$(PRIVATE_HOST)s-to-o) 1286 $(call include-depfiles-for-objs, $(asm_objects_S)) 1287 endif 1288 1289 asm_sources_s := $(filter %.s,$(my_src_files)) 1290 dotdot_sources := $(filter ../%,$(asm_sources_s)) 1291 asm_sources_s := $(filter-out ../%,$(asm_sources_s)) 1292 asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) 1293 $(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s)) 1294 1295 dotdot_objects_s := 1296 $(foreach s,$(dotdot_sources),\ 1297 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\ 1298 $(my_additional_dependencies),\ 1299 dotdot_objects_s))) 1300 $(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s)) 1301 1302 ifneq ($(strip $(asm_objects_s)),) 1303 $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ 1304 $(my_additional_dependencies) 1305 $(transform-$(PRIVATE_HOST)s-to-o) 1306 endif 1307 1308 asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s) 1309 $(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) 1310 1311 1312 # .asm for x86/x86_64 needs to be compiled with yasm. 1313 asm_sources_asm := $(filter %.asm,$(my_src_files)) 1314 ifneq ($(strip $(asm_sources_asm)),) 1315 asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o)) 1316 $(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \ 1317 $(my_additional_dependencies) 1318 $(transform-asm-to-o) 1319 $(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm)) 1320 1321 asm_objects += $(asm_objects_asm) 1322 endif 1323 1324 ########################################################### 1325 ## When compiling against the VNDK, use LL-NDK libraries 1326 ########################################################### 1327 ifneq ($(LOCAL_USE_VNDK),) 1328 #################################################### 1329 ## Soong modules may be built twice, once for /system 1330 ## and once for /vendor. If we're using the VNDK, 1331 ## switch all soong libraries over to the /vendor 1332 ## variant. 1333 #################################################### 1334 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 1335 # We don't do this renaming for soong-defined modules since they already have correct 1336 # names (with .vendor suffix when necessary) in their LOCAL_*_LIBRARIES. 1337 my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\ 1338 $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) 1339 my_static_libraries := $(foreach l,$(my_static_libraries),\ 1340 $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l))) 1341 my_shared_libraries := $(foreach l,$(my_shared_libraries),\ 1342 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) 1343 my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\ 1344 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) 1345 my_header_libraries := $(foreach l,$(my_header_libraries),\ 1346 $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l))) 1347 endif 1348 endif 1349 1350 ########################################################## 1351 ## Set up installed module dependency 1352 ## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for 1353 ## they may cusomize their install path with LOCAL_MODULE_PATH 1354 ########################################################## 1355 # Get the list of INSTALLED libraries as module names. 1356 ifneq ($(LOCAL_SDK_VERSION),) 1357 installed_shared_library_module_names := \ 1358 $(my_shared_libraries) 1359 else 1360 installed_shared_library_module_names := \ 1361 $(my_shared_libraries) $(my_system_shared_libraries) 1362 endif 1363 1364 # The real dependency will be added after all Android.mks are loaded and the install paths 1365 # of the shared libraries are determined. 1366 ifdef LOCAL_INSTALLED_MODULE 1367 ifdef installed_shared_library_module_names 1368 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 1369 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names)) 1370 endif 1371 endif 1372 1373 1374 #################################################### 1375 ## Import includes 1376 #################################################### 1377 import_includes := $(intermediates)/import_includes 1378 import_includes_deps := $(strip \ 1379 $(if $(LOCAL_USE_VNDK),\ 1380 $(call intermediates-dir-for,HEADER_LIBRARIES,device_kernel_headers,$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ 1381 $(foreach l, $(installed_shared_library_module_names), \ 1382 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ 1383 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ 1384 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ 1385 $(foreach l, $(my_header_libraries), \ 1386 $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) 1387 $(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps) 1388 $(import_includes) : $(import_includes_deps) 1389 @echo Import includes file: $@ 1390 $(hide) mkdir -p $(dir $@) && rm -f $@ 1391 ifdef import_includes_deps 1392 $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \ 1393 cat $$f >> $@; \ 1394 done 1395 else 1396 $(hide) touch $@ 1397 endif 1398 1399 #################################################### 1400 ## Verify that NDK-built libraries only link against 1401 ## other NDK-built libraries 1402 #################################################### 1403 1404 ifdef LOCAL_SDK_VERSION 1405 my_link_type := native:ndk 1406 my_warn_types := 1407 my_allowed_types := native:ndk 1408 else ifdef LOCAL_USE_VNDK 1409 my_link_type := native:vendor 1410 my_warn_types := 1411 my_allowed_types := native:vendor 1412 else 1413 my_link_type := native:platform 1414 my_warn_types := 1415 my_allowed_types := native:ndk native:platform 1416 endif 1417 1418 my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries)) 1419 ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 1420 my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries)) 1421 endif 1422 1423 my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 1424 my_common := 1425 include $(BUILD_SYSTEM)/link_type.mk 1426 1427 ########################################################### 1428 ## Common object handling. 1429 ########################################################### 1430 1431 my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files)) 1432 ifneq ($(my_unused_src_files),) 1433 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files)) 1434 endif 1435 1436 # some rules depend on asm_objects being first. If your code depends on 1437 # being first, it's reasonable to require it to be assembly 1438 normal_objects := \ 1439 $(asm_objects) \ 1440 $(cpp_objects) \ 1441 $(gen_cpp_objects) \ 1442 $(gen_asm_objects) \ 1443 $(c_objects) \ 1444 $(gen_c_objects) \ 1445 $(objc_objects) \ 1446 $(objcpp_objects) 1447 1448 new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f))) 1449 new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f))) 1450 1451 ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects))) 1452 $(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old) 1453 $(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects)))) 1454 $(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects)))) 1455 endif 1456 1457 ifeq ($(BINARY_OBJECTS_ORDER),soong) 1458 normal_objects := $(new_order_normal_objects) 1459 endif 1460 1461 normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) 1462 1463 all_objects := $(normal_objects) $(gen_o_objects) 1464 1465 # Cleanup file tracking 1466 $(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=)) 1467 my_tracked_gen_files := 1468 $(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=)) 1469 my_tracked_src_files := 1470 1471 my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir) 1472 1473 # The platform JNI header is for platform modules only. 1474 ifeq ($(LOCAL_SDK_VERSION)$(LOCAL_USE_VNDK),) 1475 my_c_includes += $(JNI_H_INCLUDE) 1476 endif 1477 1478 my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes))) 1479 ifneq ($(my_outside_includes),) 1480 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): C_INCLUDES must be under the source or output directories: $(my_outside_includes)) 1481 endif 1482 1483 # all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; 1484 # use normal_objects here to avoid creating circular dependencies. This assumes 1485 # that custom build rules which generate .o files don't consume other generated 1486 # sources as input (or if they do they take care of that dependency themselves). 1487 $(normal_objects) : | $(my_generated_sources) 1488 $(all_objects) : $(import_includes) 1489 ALL_C_CPP_ETC_OBJECTS += $(all_objects) 1490 1491 1492 ########################################################### 1493 # Standard library handling. 1494 ########################################################### 1495 1496 ########################################################### 1497 # The list of libraries that this module will link against are in 1498 # these variables. Each is a list of bare module names like "libc libm". 1499 # 1500 # LOCAL_SHARED_LIBRARIES 1501 # LOCAL_STATIC_LIBRARIES 1502 # LOCAL_WHOLE_STATIC_LIBRARIES 1503 # 1504 # We need to convert the bare names into the dependencies that 1505 # we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. 1506 # LOCAL_BUILT_MODULE should depend on the BUILT versions of the 1507 # libraries, so that simply building this module doesn't force 1508 # an install of a library. Similarly, LOCAL_INSTALLED_MODULE 1509 # should depend on the INSTALLED versions of the libraries so 1510 # that they get installed when this module does. 1511 ########################################################### 1512 # NOTE: 1513 # WHOLE_STATIC_LIBRARIES are libraries that are pulled into the 1514 # module without leaving anything out, which is useful for turning 1515 # a collection of .a files into a .so file. Linking against a 1516 # normal STATIC_LIBRARY will only pull in code/symbols that are 1517 # referenced by the module. (see gcc/ld's --whole-archive option) 1518 ########################################################### 1519 1520 # Get the list of BUILT libraries, which are under 1521 # various intermediates directories. 1522 so_suffix := $($(my_prefix)SHLIB_SUFFIX) 1523 a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) 1524 1525 ifneq ($(LOCAL_SDK_VERSION),) 1526 built_shared_libraries := \ 1527 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 1528 $(addsuffix $(so_suffix), \ 1529 $(my_shared_libraries))) 1530 built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries)) 1531 1532 # Add the NDK libraries to the built module dependency 1533 my_system_shared_libraries_fullpath := \ 1534 $(my_ndk_stl_shared_lib_fullpath) \ 1535 $(addprefix $(my_ndk_sysroot_lib)/, \ 1536 $(addsuffix $(so_suffix), $(my_system_shared_libraries))) 1537 1538 # We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of 1539 # whether the libs are generated or prebuilt, so we simply can't split into two 1540 # lists and use addprefix. 1541 my_ndk_shared_libraries_fullpath := \ 1542 $(foreach _lib,$(my_ndk_shared_libraries),\ 1543 $(if $(filter $(NDK_MIGRATED_LIBS),$(_lib)),\ 1544 $(my_built_ndk_libs)/$(_lib)$(so_suffix),\ 1545 $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix))) 1546 1547 built_shared_libraries += \ 1548 $(my_ndk_shared_libraries_fullpath) \ 1549 $(my_system_shared_libraries_fullpath) \ 1550 1551 else 1552 built_shared_libraries := \ 1553 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 1554 $(addsuffix $(so_suffix), \ 1555 $(installed_shared_library_module_names))) 1556 built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries)) 1557 my_system_shared_libraries_fullpath := 1558 endif 1559 1560 built_static_libraries := \ 1561 $(foreach lib,$(my_static_libraries), \ 1562 $(call intermediates-dir-for, \ 1563 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) 1564 1565 ifdef LOCAL_SDK_VERSION 1566 built_static_libraries += $(my_ndk_stl_static_lib) 1567 endif 1568 1569 built_whole_libraries := \ 1570 $(foreach lib,$(my_whole_static_libraries), \ 1571 $(call intermediates-dir-for, \ 1572 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) 1573 1574 # We don't care about installed static libraries, since the 1575 # libraries have already been linked into the module at that point. 1576 # We do, however, care about the NOTICE files for any static 1577 # libraries that we use. (see notice_files.mk) 1578 1579 installed_static_library_notice_file_targets := \ 1580 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \ 1581 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) 1582 1583 # Default is -fno-rtti. 1584 ifeq ($(strip $(LOCAL_RTTI_FLAG)),) 1585 LOCAL_RTTI_FLAG := -fno-rtti 1586 endif 1587 1588 ########################################################### 1589 # Rule-specific variable definitions 1590 ########################################################### 1591 1592 ifeq ($(my_clang),true) 1593 my_cflags += $(LOCAL_CLANG_CFLAGS) 1594 my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS) 1595 my_cppflags += $(LOCAL_CLANG_CPPFLAGS) 1596 my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE) 1597 my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE) 1598 my_asflags += $(LOCAL_CLANG_ASFLAGS) 1599 my_ldflags += $(LOCAL_CLANG_LDFLAGS) 1600 my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix)) 1601 my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix)) 1602 my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix)) 1603 my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix)) 1604 my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix)) 1605 my_cflags := $(call convert-to-clang-flags,$(my_cflags)) 1606 my_cppflags := $(call convert-to-clang-flags,$(my_cppflags)) 1607 my_asflags := $(call convert-to-clang-flags,$(my_asflags)) 1608 my_ldflags := $(call convert-to-clang-flags,$(my_ldflags)) 1609 else 1610 # gcc does not handle hidden functions in a manner compatible with LLVM libcxx 1611 # see b/27908145 1612 my_cflags += -Wno-attributes 1613 endif 1614 1615 ifeq ($(my_fdo_build), true) 1616 my_cflags := $(patsubst -Os,-O2,$(my_cflags)) 1617 fdo_incompatible_flags := -fno-early-inlining -finline-limit=% 1618 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags)) 1619 endif 1620 1621 # No one should ever use this flag. On GCC it's mere presence will disable all 1622 # warnings, even those that are specified after it (contrary to typical warning 1623 # flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the 1624 # warnings that are *always* bugs. 1625 my_illegal_flags := -w 1626 my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags)) 1627 my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags)) 1628 my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags)) 1629 1630 # We can enforce some rules more strictly in the code we own. my_strict 1631 # indicates if this is code that we can be stricter with. If we have rules that 1632 # we want to apply to *our* code (but maybe can't for vendor/device specific 1633 # things), we could extend this to be a ternary value. 1634 my_strict := true 1635 ifneq ($(filter external/%,$(LOCAL_PATH)),) 1636 my_strict := false 1637 endif 1638 1639 # Can be used to make some annotations stricter for code we can fix (such as 1640 # when we mark functions as deprecated). 1641 ifeq ($(my_strict),true) 1642 my_cflags += -DANDROID_STRICT 1643 endif 1644 1645 # Add -Werror if LOCAL_PATH is in the WARNING_DISALLOWED project list, 1646 # or not in the WARNING_ALLOWED project list. 1647 ifneq (,$(strip $(call find_warning_disallowed_projects,$(LOCAL_PATH)))) 1648 my_cflags_no_override += -Werror 1649 else 1650 ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH)))) 1651 my_cflags_no_override += -Werror 1652 endif 1653 endif 1654 1655 # Disable clang-tidy if it is not found. 1656 ifeq ($(PATH_TO_CLANG_TIDY),) 1657 my_tidy_enabled := false 1658 else 1659 # If LOCAL_TIDY is not defined, use global WITH_TIDY 1660 my_tidy_enabled := $(LOCAL_TIDY) 1661 ifeq ($(my_tidy_enabled),) 1662 my_tidy_enabled := $(WITH_TIDY) 1663 endif 1664 endif 1665 1666 # my_tidy_checks is empty if clang-tidy is disabled. 1667 my_tidy_checks := 1668 my_tidy_flags := 1669 ifneq (,$(filter 1 true,$(my_tidy_enabled))) 1670 ifneq ($(my_clang),true) 1671 # Disable clang-tidy if clang is disabled. 1672 my_tidy_enabled := false 1673 else 1674 tidy_only: $(cpp_objects) $(c_objects) 1675 # Set up global default checks 1676 my_tidy_checks := $(WITH_TIDY_CHECKS) 1677 ifeq ($(my_tidy_checks),) 1678 my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH)) 1679 endif 1680 # Append local clang-tidy checks. 1681 ifneq ($(LOCAL_TIDY_CHECKS),) 1682 my_tidy_checks := $(my_tidy_checks),$(LOCAL_TIDY_CHECKS) 1683 endif 1684 # Set up global default clang-tidy flags, which is none. 1685 my_tidy_flags := $(WITH_TIDY_FLAGS) 1686 # Use local clang-tidy flags if specified. 1687 ifneq ($(LOCAL_TIDY_FLAGS),) 1688 my_tidy_flags := $(LOCAL_TIDY_FLAGS) 1689 endif 1690 # If tidy flags are not specified, default to check all header files. 1691 ifeq ($(my_tidy_flags),) 1692 my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH)) 1693 endif 1694 1695 # We might be using the static analyzer through clang-tidy. 1696 # https://bugs.llvm.org/show_bug.cgi?id=32914 1697 ifneq ($(my_tidy_checks),) 1698 my_tidy_flags += "-extra-arg-before=-D__clang_analyzer__" 1699 endif 1700 endif 1701 endif 1702 1703 my_tidy_checks := $(subst $(space),,$(my_tidy_checks)) 1704 1705 # Move -l* entries from ldflags to ldlibs, and everything else to ldflags 1706 my_ldlib_flags := $(my_ldflags) $(my_ldlibs) 1707 my_ldlibs := $(filter -l%,$(my_ldlib_flags)) 1708 my_ldflags := $(filter-out -l%,$(my_ldlib_flags)) 1709 1710 # One last verification check for ldlibs 1711 ifndef LOCAL_IS_HOST_MODULE 1712 my_allowed_ldlibs := 1713 ifneq ($(LOCAL_SDK_VERSION),) 1714 my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES)) 1715 endif 1716 1717 my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs)) 1718 ifneq ($(my_bad_ldlibs),) 1719 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs)) 1720 endif 1721 endif 1722 1723 # my_cxx_ldlibs may contain linker flags need to wrap certain libraries 1724 # (start-group/end-group), so append after the check above. 1725 my_ldlibs += $(my_cxx_ldlibs) 1726 1727 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) 1728 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) 1729 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags) 1730 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) 1731 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) 1732 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override) 1733 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override) 1734 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) 1735 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) 1736 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) 1737 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) 1738 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) 1739 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) 1740 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks) 1741 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags) 1742 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags) 1743 1744 # this is really the way to get the files onto the command line instead 1745 # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work 1746 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) 1747 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) 1748 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) 1749 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects)) 1750 1751 ########################################################### 1752 # Define library dependencies. 1753 ########################################################### 1754 # all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. 1755 all_libraries := \ 1756 $(built_shared_library_deps) \ 1757 $(my_system_shared_libraries_fullpath) \ 1758 $(built_static_libraries) \ 1759 $(built_whole_libraries) 1760 1761 # Also depend on the notice files for any static libraries that 1762 # are linked into this module. This will force them to be installed 1763 # when this module is. 1764 $(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) 1765 1766 ########################################################### 1767 # Export includes 1768 ########################################################### 1769 export_includes := $(intermediates)/export_includes 1770 export_cflags := $(foreach d,$(my_export_c_include_dirs),-I $(d)) 1771 # Soong exports cflags instead of include dirs, so that -isystem can be included. 1772 ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 1773 export_cflags += $(LOCAL_EXPORT_CFLAGS) 1774 else ifdef LOCAL_EXPORT_CFLAGS 1775 $(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead) 1776 endif 1777 $(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags) 1778 # Headers exported by whole static libraries are also exported by this library. 1779 export_include_deps := $(strip \ 1780 $(foreach l,$(my_whole_static_libraries), \ 1781 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) 1782 # Re-export requested headers from shared libraries. 1783 export_include_deps += $(strip \ 1784 $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \ 1785 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) 1786 # Re-export requested headers from static libraries. 1787 export_include_deps += $(strip \ 1788 $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \ 1789 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) 1790 # Re-export requested headers from header libraries. 1791 export_include_deps += $(strip \ 1792 $(foreach l,$(LOCAL_EXPORT_HEADER_LIBRARY_HEADERS), \ 1793 $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) 1794 $(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps) 1795 # By adding $(my_generated_sources) it makes sure the headers get generated 1796 # before any dependent source files get compiled. 1797 $(export_includes) : $(my_export_c_include_deps) $(my_generated_sources) $(export_include_deps) $(LOCAL_EXPORT_C_INCLUDE_DEPS) 1798 @echo Export includes file: $< -- $@ 1799 $(hide) mkdir -p $(dir $@) && rm -f $@.tmp && touch $@.tmp 1800 ifdef export_cflags 1801 $(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >>$@.tmp 1802 endif 1803 ifdef export_include_deps 1804 $(hide) for f in $(PRIVATE_REEXPORTED_INCLUDES); do \ 1805 cat $$f >> $@.tmp; \ 1806 done 1807 endif 1808 $(hide) if cmp -s $@.tmp $@ ; then \ 1809 rm $@.tmp ; \ 1810 else \ 1811 mv $@.tmp $@ ; \ 1812 fi 1813 export_cflags := 1814 1815 # Kati adds restat=1 to ninja. GNU make does nothing for this. 1816 .KATI_RESTAT: $(export_includes) 1817 1818 # Make sure export_includes gets generated when you are running mm/mmm 1819 $(LOCAL_BUILT_MODULE) : | $(export_includes) 1820 1821 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 1822 ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs))) 1823 my_soong_problems += non_local__export_c_include_dirs 1824 endif 1825 1826 SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \ 1827 $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems) 1828 SOONG_CONV.$(LOCAL_MODULE).DEPS := \ 1829 $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \ 1830 $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY),\ 1831 $(my_static_libraries) \ 1832 $(my_whole_static_libraries) \ 1833 $(my_shared_libraries) \ 1834 $(my_system_shared_libraries)) 1835 SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE) 1836 endif 1837 1838 ########################################################### 1839 # Coverage packaging. 1840 ########################################################### 1841 ifeq ($(my_native_coverage),true) 1842 my_gcno_objects := \ 1843 $(cpp_objects) \ 1844 $(gen_cpp_objects) \ 1845 $(c_objects) \ 1846 $(gen_c_objects) \ 1847 $(objc_objects) \ 1848 $(objcpp_objects) 1849 1850 LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(my_gcno_objects)) 1851 $(foreach f,$(my_gcno_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno)))) 1852 endif 1853