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