blob: 6f1d814a6eabc1164c1bb3cbd7863bdeaa154ed9 [file] [log] [blame]
The Android Open Source Project88b60792009-03-03 19:28:42 -08001###########################################################
2## Standard rules for building binary object files from
Ying Wangd8d37212014-03-21 16:17:04 -07003## asm/c/cpp/yacc/lex/etc source files.
The Android Open Source Project88b60792009-03-03 19:28:42 -08004##
5## The list of object files is exported in $(all_objects).
6###########################################################
7
Ying Wangd8d37212014-03-21 16:17:04 -07008#######################################
9include $(BUILD_SYSTEM)/base_rules.mk
Chih-Hung Hsieh32427d62018-04-12 10:55:54 -070010include $(BUILD_SYSTEM)/use_lld_setup.mk
Ying Wangd8d37212014-03-21 16:17:04 -070011#######################################
12
Dan Albertd3d894d2014-11-14 15:28:49 -080013##################################################
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)
Colin Crossaf7ac392022-11-09 15:52:56 -080022 ifdef USE_HOST_MUSL
23 my_system_shared_libraries := libc_musl
24 else
Dan Albertd3d894d2014-11-14 15:28:49 -080025 my_system_shared_libraries :=
Colin Crossaf7ac392022-11-09 15:52:56 -080026 endif
Dan Albertd3d894d2014-11-14 15:28:49 -080027 else
28 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
29 endif
30else
31 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Dimitry Ivanovcdf39272017-06-26 13:13:44 -070032 my_system_shared_libraries := libc libm libdl
Dan Albertd3d894d2014-11-14 15:28:49 -080033 else
34 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Dimitry Ivanovcdf39272017-06-26 13:13:44 -070035 my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries))
Dan Albertd3d894d2014-11-14 15:28:49 -080036 endif
37endif
38
Pirama Arumuga Nainard6b0a872022-02-04 14:08:50 -080039# 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
Dan Willemsenfc92fb22016-08-26 13:27:13 -070045my_soong_problems :=
46
Dan Albertd3d894d2014-11-14 15:28:49 -080047# 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)
Colin Crossa04abc82015-06-30 12:21:59 -070051my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080052my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
53my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
Dimitry Ivanovcdf39272017-06-26 13:13:44 -070054my_shared_libraries := $(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES))
Dan Willemsen8dae49c2017-02-15 15:48:11 -080055my_header_libraries := $(LOCAL_HEADER_LIBRARIES)
Dan Albertd3d894d2014-11-14 15:28:49 -080056my_cflags := $(LOCAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -080057my_conlyflags := $(LOCAL_CONLYFLAGS)
Dan Albertd3d894d2014-11-14 15:28:49 -080058my_cppflags := $(LOCAL_CPPFLAGS)
Dan Willemsen7a5c5d72018-10-07 19:41:21 -070059my_cflags_no_override := $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
60my_cppflags_no_override := $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
zijunzhaodeaf2482023-01-25 04:06:34 +000061ifeq ($(my_32_64_bit_suffix), 64)
62 my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_64_NO_OVERRIDE)
63endif
Pirama Arumuga Nainard6b0a872022-02-04 14:08:50 -080064ifdef 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
Dan Albertd3d894d2014-11-14 15:28:49 -080068my_ldflags := $(LOCAL_LDFLAGS)
69my_ldlibs := $(LOCAL_LDLIBS)
70my_asflags := $(LOCAL_ASFLAGS)
71my_cc := $(LOCAL_CC)
Ying Wangc671a7c2015-07-20 18:40:18 -070072my_cc_wrapper := $(CC_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080073my_cxx := $(LOCAL_CXX)
Ramy Medhate5839f92019-08-06 15:54:48 -040074my_cxx_link := $(LOCAL_CXX)
Jiyong Park425d4892017-08-18 12:22:57 +090075my_cxx_ldlibs :=
Ying Wangc671a7c2015-07-20 18:40:18 -070076my_cxx_wrapper := $(CXX_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080077my_c_includes := $(LOCAL_C_INCLUDES)
78my_generated_sources := $(LOCAL_GENERATED_SOURCES)
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -080079my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
Ying Wangfaeb6932015-04-07 11:59:34 -070080my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Dan Willemsenba6a1642016-09-29 12:08:29 -070081my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
Evgenii Stepanove1b96f32017-01-23 16:57:38 -080082my_arflags :=
Dan Albertd3d894d2014-11-14 15:28:49 -080083
Dan Willemsenceba3cb2020-08-05 17:06:34 -070084# 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
Colin Cross23dcf762019-11-11 16:04:34 -0800136# Configure the pool to use for clang rules.
137# If LOCAL_CC or LOCAL_CXX is set don't use goma or RBE.
Dan Willemsenceba3cb2020-08-05 17:06:34 -0700138# 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)
Colin Cross23dcf762019-11-11 16:04:34 -0800140my_pool :=
Dan Willemsenceba3cb2020-08-05 17:06:34 -0700141ifeq (,$(strip $(my_cc))$(strip $(my_cxx))$(strip $(my_tidy_checks)))
Colin Cross23dcf762019-11-11 16:04:34 -0800142 my_pool := $(GOMA_OR_RBE_POOL)
143endif
144
Roland Levillaincd80a6a2020-07-07 15:19:44 +0100145ifneq (,$(strip $(foreach dir,$(NATIVE_COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
146ifeq (,$(strip $(foreach dir,$(NATIVE_COVERAGE_EXCLUDE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
Ryan Campbell81c9d292016-09-12 13:56:50 -0700147 my_native_coverage := true
148else
149 my_native_coverage := false
150endif
Ryan Campbellb55ff742017-02-27 09:09:16 -0800151else
152 my_native_coverage := false
153endif
Dan Willemsene24da822019-01-10 13:10:17 -0800154ifneq ($(NATIVE_COVERAGE),true)
155 my_native_coverage := false
156endif
Ryan Campbell81c9d292016-09-12 13:56:50 -0700157
Colin Crossc3ad8042020-06-11 11:25:05 -0700158# Exclude directories from checking allowed manual binder interface lists.
Ivan Lozanob18979a2019-11-26 10:20:43 -0800159# 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
Colin Crossa82fa122016-10-20 12:38:21 -0700164my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
165ifdef SANITIZE_HOST
Dan Albertb58fb4a2014-11-14 17:15:00 -0800166ifdef LOCAL_IS_HOST_MODULE
167my_allow_undefined_symbols := true
Colin Crossa82fa122016-10-20 12:38:21 -0700168endif
Dan Albertb58fb4a2014-11-14 17:15:00 -0800169endif
170
Andrew Hsieh140761af02014-04-25 23:47:10 -0700171my_ndk_sysroot :=
172my_ndk_sysroot_include :=
173my_ndk_sysroot_lib :=
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700174my_api_level := 10000
175
Inseob Kim8b0ccda2020-08-04 00:51:33 +0900176my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
177
Dan Willemsenffa32582017-03-19 13:22:45 -0700178ifneq ($(LOCAL_SDK_VERSION),)
Ying Wang1a081002010-07-13 14:55:47 -0700179 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -0700180 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -0700181 endif
Nikola Veljkovicf7385622016-04-06 19:20:02 +0200182
Dan Albert02bf1382016-07-21 10:04:12 -0700183 # Make sure we've built the NDK.
Dan Albert248b8322017-12-14 13:52:04 -0800184 my_additional_dependencies += $(SOONG_OUT_DIR)/ndk_base.timestamp
Dan Albert02bf1382016-07-21 10:04:12 -0700185
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800186 ifneq (,$(filter arm64 x86_64,$(my_arch)))
Dan Albert02bf1382016-07-21 10:04:12 -0700187 my_min_sdk_version := 21
188 else
Dan Albert105e4fe2017-08-17 16:24:46 -0700189 my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION)
Dan Albert02bf1382016-07-21 10:04:12 -0700190 endif
191
192 # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map
193 # missing API levels to existing ones where necessary, but we're not doing
194 # that for the generated libraries. Clip the API level to the minimum where
195 # appropriate.
Dan Willemsenffa32582017-03-19 13:22:45 -0700196 my_ndk_api := $(LOCAL_SDK_VERSION)
197 ifneq ($(my_ndk_api),current)
198 my_ndk_api := $(call math_max,$(my_ndk_api),$(my_min_sdk_version))
Dan Albert988107d2016-11-08 15:10:09 -0800199 endif
200
Dan Albertf9f035d2020-07-16 17:12:07 -0700201 my_ndk_crt_version := $(my_ndk_api)
202
Dan Albert988107d2016-11-08 15:10:09 -0800203 my_ndk_hist_api := $(my_ndk_api)
204 ifeq ($(my_ndk_api),current)
Dan Albert988107d2016-11-08 15:10:09 -0800205 # The last API level supported by the old prebuilt NDKs.
206 my_ndk_hist_api := 24
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700207 else
208 my_api_level := $(my_ndk_api)
Dan Albert988107d2016-11-08 15:10:09 -0800209 endif
210
Dan Albert02bf1382016-07-21 10:04:12 -0700211 my_ndk_source_root := \
212 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources
213 my_ndk_sysroot := \
Dan Albert988107d2016-11-08 15:10:09 -0800214 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_hist_api)/arch-$(my_arch)
Dan Albert02bf1382016-07-21 10:04:12 -0700215 my_built_ndk := $(SOONG_OUT_DIR)/ndk
216 my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE)
217 my_ndk_sysroot_include := \
218 $(my_built_ndk)/sysroot/usr/include \
219 $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \
220 $(my_ndk_sysroot)/usr/include \
Dan Albert445bc2f2015-12-11 12:49:18 -0800221
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800222 # x86_64 is a multilib toolchain, so their libraries are
Dan Albert445bc2f2015-12-11 12:49:18 -0800223 # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib
224 # compiler, so its libraries are in /usr/lib.
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800225 ifneq (,$(filter x86_64,$(my_arch)))
Dan Albert02bf1382016-07-21 10:04:12 -0700226 my_ndk_libdir_name := lib64
Andrew Hsieh140761af02014-04-25 23:47:10 -0700227 else
Dan Albert02bf1382016-07-21 10:04:12 -0700228 my_ndk_libdir_name := lib
Andrew Hsieh140761af02014-04-25 23:47:10 -0700229 endif
Ying Wangcce4c972011-03-03 18:53:53 -0800230
Dan Albert02bf1382016-07-21 10:04:12 -0700231 my_ndk_platform_dir := \
232 $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch)
233 my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name)
234 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name)
235
Dan Willemsenffa32582017-03-19 13:22:45 -0700236 # The bionic linker now has support for packed relocations and gnu style
237 # hashes (which are much faster!), but shipping to older devices requires
238 # the old style hash. Fortunately, we can build with both and it'll work
239 # anywhere.
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800240 my_ldflags += -Wl,--hash-style=both
Dan Albertd3d894d2014-11-14 15:28:49 -0800241
Dan Willemsenffa32582017-03-19 13:22:45 -0700242 # We don't want to expose the relocation packer to the NDK just yet.
243 LOCAL_PACK_MODULE_RELOCATIONS := false
244
Ying Wangcce4c972011-03-03 18:53:53 -0800245 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
246 # See ndk/docs/CPLUSPLUS-SUPPORT.html
247 my_ndk_stl_include_path :=
248 my_ndk_stl_shared_lib_fullpath :=
Ying Wangcce4c972011-03-03 18:53:53 -0800249 my_ndk_stl_static_lib :=
Duane Sand1a074872014-11-08 15:25:18 -0800250 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800251 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800252 ifeq (,$(LOCAL_NDK_STL_VARIANT))
Dan Albert37099682017-12-15 20:01:03 +0000253 LOCAL_NDK_STL_VARIANT := system
Ying Wangcce4c972011-03-03 18:53:53 -0800254 endif
Dan Albert19fbd1c2018-01-04 13:34:21 -0800255 ifneq (1,$(words $(filter none system c++_static c++_shared, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -0700256 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800257 endif
Dan Albert19fbd1c2018-01-04 13:34:21 -0800258
Ying Wangcce4c972011-03-03 18:53:53 -0800259 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
260 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
Dan Albert0e2e71d2015-12-09 14:46:13 -0800261 my_system_shared_libraries += libstdc++
Dan Albert19fbd1c2018-01-04 13:34:21 -0800262 else ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800263 my_ndk_stl_include_path := \
264 $(my_ndk_source_root)/cxx-stl/llvm-libc++/include
265 my_ndk_stl_include_path += \
266 $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/include
Dan Albert09607702016-08-08 17:14:59 -0700267
268 my_libcxx_libdir := \
269 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)
270
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800271 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
272 my_ndk_stl_static_lib := \
273 $(my_libcxx_libdir)/libc++_static.a \
274 $(my_libcxx_libdir)/libc++abi.a
Dan Albert09607702016-08-08 17:14:59 -0700275 else
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800276 my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
277 endif
Dan Albert09607702016-08-08 17:14:59 -0700278
Dan Alberte6d958a2018-11-15 11:33:21 -0800279 ifneq ($(my_ndk_api),current)
280 ifeq ($(call math_lt,$(my_ndk_api),21),true)
281 my_ndk_stl_include_path += $(my_ndk_source_root)/android/support/include
282 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libandroid_support.a
283 endif
284 endif
285
Ryan Prichard6d748702021-03-31 15:30:30 -0700286 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a
Dan Albert2936a1e2016-09-14 16:08:04 -0700287 my_ldlibs += -ldl
Dan Albert0e2e71d2015-12-09 14:46:13 -0800288 else # LOCAL_NDK_STL_VARIANT must be none
289 # Do nothing.
290 endif
Pirama Arumuga Nainar9305e202018-12-20 13:47:44 -0800291
292 # Clang's coverage/profile runtime needs symbols like 'stderr' that were not
293 # exported from libc prior to API level 23
294 ifneq ($(my_ndk_api),current)
295 ifeq ($(call math_lt, $(my_ndk_api),23),true)
296 my_native_coverage := false
297 endif
298 endif
Dan Willemsenffa32582017-03-19 13:22:45 -0700299endif
300
Pirama Arumuga Nainarb8f898e2019-07-02 23:49:19 -0700301ifeq ($(NATIVE_COVERAGE),true)
302 ifndef LOCAL_IS_HOST_MODULE
303 my_ldflags += -Wl,--wrap,getenv
304
305 ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
306 ifeq ($(LOCAL_SDK_VERSION),)
307 my_whole_static_libraries += libprofile-extras
308 else
309 my_whole_static_libraries += libprofile-extras_ndk
310 endif
311 endif
312 endif
313endif
314
Dan Willemsenffa32582017-03-19 13:22:45 -0700315ifneq ($(LOCAL_USE_VNDK),)
Justin Yun65c680e2018-03-20 07:16:14 +0900316 # Required VNDK version for vendor modules is BOARD_VNDK_VERSION.
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700317 my_api_level := $(BOARD_VNDK_VERSION)
318 ifeq ($(my_api_level),current)
Justin Yun65c680e2018-03-20 07:16:14 +0900319 # Build with current PLATFORM_VNDK_VERSION.
320 # If PLATFORM_VNDK_VERSION has a CODENAME, it will return
321 # __ANDROID_API_FUTURE__.
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700322 my_api_level := $(call codename-or-sdk-to-sdk,$(PLATFORM_VNDK_VERSION))
Inseob Kimf0cec692019-12-03 15:09:44 +0900323 else
324 # Build with current BOARD_VNDK_VERSION.
325 my_api_level := $(call codename-or-sdk-to-sdk,$(BOARD_VNDK_VERSION))
Justin Yun65c680e2018-03-20 07:16:14 +0900326 endif
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700327 my_cflags += -D__ANDROID_VNDK__
Justin Yun69f71912021-03-08 19:31:37 +0900328 ifneq ($(LOCAL_USE_VNDK_VENDOR),)
329 # Vendor modules have LOCAL_USE_VNDK_VENDOR when
330 # BOARD_VNDK_VERSION is defined.
331 my_cflags += -D__ANDROID_VENDOR__
332 else ifneq ($(LOCAL_USE_VNDK_PRODUCT),)
333 # Product modules have LOCAL_USE_VNDK_PRODUCT when
334 # PRODUCT_PRODUCT_VNDK_VERSION is defined.
335 my_cflags += -D__ANDROID_PRODUCT__
336 endif
Dan Albertc1ca1902016-08-04 14:14:50 -0700337endif
Dan Albert02bf1382016-07-21 10:04:12 -0700338
Dan Albertc1ca1902016-08-04 14:14:50 -0700339ifndef LOCAL_IS_HOST_MODULE
340# For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We
341# no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're
342# linking my_shared_libraries by full path now.
343my_allowed_ldlibs :=
344
345# Sort ldlibs and ldflags between -l and other linker flags
346# We'll do this again later, since there are still changes happening, but that's fine.
347my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
348my_ldlibs := $(filter -l%,$(my_ldlib_flags))
349my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
350my_ldlib_flags :=
351
352# Move other ldlibs back to shared libraries
353my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs)))
354my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
Colin Cross0bd335f2017-09-08 14:41:22 -0700355else # LOCAL_IS_HOST_MODULE
Dan Willemsena3a06fe2017-09-26 20:26:11 -0700356 # Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of
Colin Cross0bd335f2017-09-08 14:41:22 -0700357 # device builds
Colin Crossaf7ac392022-11-09 15:52:56 -0800358 ifndef USE_HOST_MUSL
359 my_ldlibs += -ldl -lpthread -lm
360 ifneq ($(HOST_OS),darwin)
361 my_ldlibs += -lrt
362 endif
Colin Cross0bd335f2017-09-08 14:41:22 -0700363 endif
Dan Albertc1ca1902016-08-04 14:14:50 -0700364endif
365
Dan Willemsenffa32582017-03-19 13:22:45 -0700366ifneq ($(LOCAL_SDK_VERSION),)
Dan Albert016da582020-06-30 12:46:41 -0700367 my_all_ndk_libraries := $(NDK_KNOWN_LIBS)
Dan Albertc1ca1902016-08-04 14:14:50 -0700368 my_ndk_shared_libraries := \
369 $(filter $(my_all_ndk_libraries),\
370 $(my_shared_libraries) $(my_system_shared_libraries))
371
372 my_shared_libraries := \
373 $(filter-out $(my_all_ndk_libraries),$(my_shared_libraries))
Dan Albert02bf1382016-07-21 10:04:12 -0700374 my_system_shared_libraries := \
Dan Albertc1ca1902016-08-04 14:14:50 -0700375 $(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries))
Ying Wang1a081002010-07-13 14:55:47 -0700376endif
377
Dan Albert95994de2014-08-07 18:29:11 -0700378# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
379# all code is position independent, and then those warnings get promoted to
380# errors.
Alexey Polyudovcbb038c2016-08-01 17:36:39 -0700381ifneq ($(LOCAL_NO_PIC),true)
Dan Willemsenf2646902019-01-25 16:54:37 -0800382 ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
383 my_cflags += -fPIE
384 ifndef BUILD_HOST_static
385 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
386 my_ldflags += -pie
Colin Crossfeb4a7e2018-09-19 14:45:52 -0700387 endif
Colin Crossfeb4a7e2018-09-19 14:45:52 -0700388 endif
Dan Willemsenf2646902019-01-25 16:54:37 -0800389 else
390 my_cflags += -fPIC
Colin Crossfeb4a7e2018-09-19 14:45:52 -0700391 endif
Alexey Polyudovcbb038c2016-08-01 17:36:39 -0700392endif
Dan Albert4803ce22014-08-06 12:36:46 -0700393
Dan Willemsen7a549852015-08-13 17:51:40 -0700394ifdef LOCAL_IS_HOST_MODULE
Dan Willemsen85ac8d22015-08-18 17:47:06 -0700395my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
Dan Willemsen7a549852015-08-13 17:51:40 -0700396my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS))
397my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS))
Dan Willemsen8dae49c2017-02-15 15:48:11 -0800398my_header_libraries += $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)OS))
Dan Willemsen7a549852015-08-13 17:51:40 -0700399my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS))
400my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS))
401my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS))
402my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS))
403my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS))
404my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS))
405my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS))
406endif
407
Ying Wang6feb6d52014-04-17 10:03:35 -0700408my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
Colin Crossa04abc82015-06-30 12:21:59 -0700409my_src_files_exclude += $(LOCAL_SRC_FILES_EXCLUDE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_EXCLUDE_$(my_32_64_bit_suffix))
Ying Wang6feb6d52014-04-17 10:03:35 -0700410my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
411my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
412my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
413my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
414my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
415my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
416my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800417
Dan Willemsenc29172c2015-12-03 22:58:39 -0800418my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude))
419ifneq ($(my_missing_exclude_files),)
420$(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES)
421$(error $(my_missing_exclude_files))
422endif
Colin Crossa04abc82015-06-30 12:21:59 -0700423my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files))
424
Dan Willemsenc57894c2016-10-28 16:30:48 -0700425# Strip '/' from the beginning of each src file. This helps the ../ detection in case
426# the source file is in the form of /../file
427my_src_files := $(patsubst /%,%,$(my_src_files))
428
Dan Albertdb905e72014-08-18 11:14:38 -0700429my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700430ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700431my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700432endif
433ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700434my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700435endif
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700436ifeq ($(my_clang),false)
Dan Willemsenf0638392018-09-04 22:25:22 -0700437 $(call pretty-error,LOCAL_CLANG false is no longer supported)
Dan Willemsen77288172015-09-09 15:45:21 -0700438endif
439
Dan Albert76bfcd42017-02-03 16:16:11 -0800440ifeq ($(LOCAL_C_STD),)
441 my_c_std_version := $(DEFAULT_C_STD_VERSION)
442else ifeq ($(LOCAL_C_STD),experimental)
443 my_c_std_version := $(EXPERIMENTAL_C_STD_VERSION)
444else
445 my_c_std_version := $(LOCAL_C_STD)
446endif
447
448ifeq ($(LOCAL_CPP_STD),)
449 my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION)
450else ifeq ($(LOCAL_CPP_STD),experimental)
451 my_cpp_std_version := $(EXPERIMENTAL_CPP_STD_VERSION)
452else
453 my_cpp_std_version := $(LOCAL_CPP_STD)
454endif
Dan Albertda637392015-10-26 11:09:24 -0700455
Colin Crosse56e3562016-10-17 15:34:29 -0700456my_c_std_conlyflags :=
457my_cpp_std_cppflags :=
458ifneq (,$(my_c_std_version))
459 my_c_std_conlyflags := -std=$(my_c_std_version)
460endif
Dan Albertc7d307d2015-07-29 15:13:57 -0700461
Colin Crosse56e3562016-10-17 15:34:29 -0700462ifneq (,$(my_cpp_std_version))
463 my_cpp_std_cppflags := -std=$(my_cpp_std_version)
464endif
Tim Murray06659bc2014-08-13 11:53:07 -0700465
Yi Kong42e18962018-06-06 16:42:22 -0700466# Extra cflags for projects under external/ directory
Yi Kong0047dbe2018-06-12 15:28:26 -0700467ifneq ($(filter external/%,$(LOCAL_PATH)),)
Yi Kong42e18962018-06-06 16:42:22 -0700468 my_cflags += $(CLANG_EXTERNAL_CFLAGS)
469endif
Yi Kong42e18962018-06-06 16:42:22 -0700470
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800471# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700472my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
473my_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)
Dan Willemsen8dae49c2017-02-15 15:48:11 -0800474my_header_libraries := $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_HEADER_LIBRARIES_$(my_32_64_bit_suffix)) $(my_header_libraries)
Ying Wang6ef65192014-01-15 16:02:16 -0800475
Ying Wang75e8fcb2014-10-07 13:03:29 -0700476include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700477
Nicolas Geoffrayb7c9f322015-09-25 13:54:09 +0100478ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),)
479 my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)
480else
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700481 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER)
Nicolas Geoffrayb7c9f322015-09-25 13:54:09 +0100482endif
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700483
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700484include $(BUILD_SYSTEM)/config_sanitizers.mk
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400485
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700486ifneq ($(filter ../%,$(my_src_files)),)
487my_soong_problems += dotdot_srcs
488endif
489ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),)
490my_soong_problems += dotdot_incs
491endif
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700492
The Android Open Source Project88b60792009-03-03 19:28:42 -0800493###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800494## Explicitly declare assembly-only __ASSEMBLY__ macro for
495## assembly source
496###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800497my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800498
Dan Willemsenffa32582017-03-19 13:22:45 -0700499###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800500# TODO: support a mix of standard extensions so that this isn't necessary
501LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
502ifeq ($(LOCAL_CPP_EXTENSION),)
503 LOCAL_CPP_EXTENSION := .cpp
504endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800505
506# Certain modules like libdl have to have symbols resolved at runtime and blow
507# up if --no-undefined is passed to the linker.
508ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
Colin Crossa82fa122016-10-20 12:38:21 -0700509 ifeq ($(my_allow_undefined_symbols),)
510 ifneq ($(HOST_OS),darwin)
511 my_ldflags += -Wl,--no-undefined
512 endif
513 else
514 ifdef LOCAL_IS_HOST_MODULE
515 ifeq ($(HOST_OS),darwin)
516 # darwin defaults to treating undefined symbols as errors
517 my_ldflags += -Wl,-undefined,dynamic_lookup
518 endif
519 endif
520 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800521endif
522
Ying Wangfcdabd42011-04-25 14:22:41 -0700523ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
524$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
525else
526$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
527endif
528
The Android Open Source Project88b60792009-03-03 19:28:42 -0800529###########################################################
530## Define arm-vs-thumb-mode flags.
531###########################################################
532LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Ying Wangfaeb6932015-04-07 11:59:34 -0700533ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800534normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
535
Dave Bort95282482009-04-23 18:44:55 -0700536# Read the values from something like TARGET_arm_CFLAGS or
537# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
538# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800539normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400540
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800541else
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800542normal_objects_mode :=
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800543normal_objects_cflags :=
544endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800545
546###########################################################
547## Define per-module debugging flags. Users can turn on
548## debugging for a particular module by setting DEBUG_MODULE_ModuleName
549## to a non-empty value in their environment or buildspec.mk,
550## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
551## debug flags that they want to use.
552###########################################################
553ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
554 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
555else
556 debug_cflags :=
557endif
558
Tim Murraya7aa8002012-10-29 16:06:00 -0700559####################################################
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800560## Keep track of src -> obj mapping
561####################################################
562
563my_tracked_gen_files :=
564my_tracked_src_files :=
565
566###########################################################
567## Stuff source generated from one-off tools
568###########################################################
569$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
570
571my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
572
Dan Willemsen7f016152016-02-29 17:52:39 -0800573$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/%
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800574 @echo "Copy: $@"
575 $(copy-file-to-target)
576
577my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
578
579# Generated sources that will actually produce object files.
580# Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES,
581# since other compiled sources may depend on them, and we set up
582# the dependencies.
Dan Willemsen444c3232016-02-04 14:18:48 -0800583my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800584
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800585####################################################
Tim Murraya7aa8002012-10-29 16:06:00 -0700586## Compile RenderScript with reflected C++
587####################################################
588
Jeff Vander Stoepc44aa3b2019-07-12 08:33:31 -0700589renderscript_sources := $(filter %.rscript %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700590
591ifneq (,$(renderscript_sources))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700592my_soong_problems += rs
Tim Murraya7aa8002012-10-29 16:06:00 -0700593
594renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
595RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
596renderscript_intermediate := $(intermediates)/renderscript
597
Noah Presler4796a8c2015-08-13 17:04:10 -0700598renderscript_target_api :=
599
600ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
601renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
602else
603ifneq (,$(LOCAL_SDK_VERSION))
604# Set target-api for LOCAL_SDK_VERSIONs other than current.
Michael Wright0fb087f2015-11-06 15:20:51 +0000605ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900606renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
Noah Presler4796a8c2015-08-13 17:04:10 -0700607endif
608endif # LOCAL_SDK_VERSION is set
609endif # LOCAL_RENDERSCRIPT_TARGET_API is set
610
611
Tim Murraya7aa8002012-10-29 16:06:00 -0700612ifeq ($(LOCAL_RENDERSCRIPT_CC),)
613LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
614endif
615
616# Turn on all warnings and warnings as errors for RS compiles.
617# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
618renderscript_flags := -Wall -Werror
619renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700620# -m32 or -m64
621renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700622
Ying Wang6ef65192014-01-15 16:02:16 -0800623renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700624 $(TOPDIR)external/clang/lib/Headers \
Jean-Luc Brouilleteba44932017-01-08 17:40:21 -0800625 $(TOPDIR)frameworks/rs/script_api/include \
Tim Murraya7aa8002012-10-29 16:06:00 -0700626 $(LOCAL_RENDERSCRIPT_INCLUDES)
627
628ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800629renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700630endif
631
Ying Wangb9319562015-04-03 16:15:28 -0700632bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
Jeff Vander Stoepc44aa3b2019-07-12 08:33:31 -0700633 $(patsubst %.fs,%.d, $(patsubst %.rscript,%.d, $(notdir $(renderscript_sources)))))
Ying Wangb9319562015-04-03 16:15:28 -0700634
Ying Wang6ef65192014-01-15 16:02:16 -0800635$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700636$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
637$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
638$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
639$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
Colin Crosse2f541b2018-05-16 09:53:40 -0700640$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(patsubst current,0,$(renderscript_target_api))
Ying Wangb9319562015-04-03 16:15:28 -0700641$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
Tim Murraya7aa8002012-10-29 16:06:00 -0700642$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
643 $(transform-renderscripts-to-cpp-and-bc)
644
Dan Willemsen461d8442016-11-10 18:19:36 -0800645# include the dependency files (.d) generated by llvm-rs-cc.
646$(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp))
Tim Murraya7aa8002012-10-29 16:06:00 -0700647
648LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
649
650rs_generated_cpps := $(addprefix \
Jeff Vander Stoepc44aa3b2019-07-12 08:33:31 -0700651 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rscript,%.cpp, \
Tim Murraya7aa8002012-10-29 16:06:00 -0700652 $(notdir $(renderscript_sources)))))
653
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800654$(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps))
655
Kevin Lau Fangc45b82c2020-07-29 22:15:33 +0000656# This is just a no-op rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700657$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700658 @echo "Updated RS generated cpp file $@."
Ying Wange25b3982015-02-26 18:47:21 -0800659 $(hide) touch $@
Tim Murraya7aa8002012-10-29 16:06:00 -0700660
Ying Wang6ef65192014-01-15 16:02:16 -0800661my_c_includes += $(renderscript_intermediate)
662my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700663
664endif
665
666
The Android Open Source Project88b60792009-03-03 19:28:42 -0800667###########################################################
Ying Wangfaeb6932015-04-07 11:59:34 -0700668## Compile the .proto files to .cc (or .c) and then to .o
Ying Wanga5fc87a2010-11-02 18:43:16 -0700669###########################################################
Joe Onoratobfc78112017-10-07 23:44:05 -0400670ifeq ($(strip $(LOCAL_PROTOC_OPTIMIZE_TYPE)),)
671 LOCAL_PROTOC_OPTIMIZE_TYPE := lite
672endif
Ying Wangb8e01852014-01-23 15:09:04 -0800673proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700674ifneq ($(proto_sources),)
Ying Wang05f9f352016-05-05 20:02:08 -0700675proto_gen_dir := $(generated_sources_dir)/proto
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900676proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wangfaeb6932015-04-07 11:59:34 -0700677
Ying Wang05f9f352016-05-05 20:02:08 -0700678my_rename_cpp_ext :=
Yu Shan655f17c2019-01-25 17:11:02 -0800679ifneq (,$(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)))
Ying Wangfaeb6932015-04-07 11:59:34 -0700680my_proto_source_suffix := .c
681my_proto_c_includes := external/nanopb-c
Ying Wang05f9f352016-05-05 20:02:08 -0700682my_protoc_flags := --nanopb_out=$(proto_gen_dir) \
Yu Shan10be65d2018-08-03 23:48:10 +0000683 --plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-nanopb
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900684my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options)
Ying Wangfaeb6932015-04-07 11:59:34 -0700685else
Ying Wang05f9f352016-05-05 20:02:08 -0700686my_proto_source_suffix := $(LOCAL_CPP_EXTENSION)
687ifneq ($(my_proto_source_suffix),.cc)
688# aprotoc is hardcoded to write out only .cc file.
689# We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc.
690my_rename_cpp_ext := true
691endif
Ying Wangfaeb6932015-04-07 11:59:34 -0700692my_proto_c_includes := external/protobuf/src
693my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Joe Onoratobfc78112017-10-07 23:44:05 -0400694my_protoc_flags := --cpp_out=$(if $(filter lite lite-static,$(LOCAL_PROTOC_OPTIMIZE_TYPE)),lite:,)$(proto_gen_dir)
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900695my_protoc_deps :=
Ying Wangfaeb6932015-04-07 11:59:34 -0700696endif
Ying Wang05f9f352016-05-05 20:02:08 -0700697my_proto_c_includes += $(proto_gen_dir)
Ying Wangfaeb6932015-04-07 11:59:34 -0700698
Ying Wang05f9f352016-05-05 20:02:08 -0700699proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \
Ying Wangfaeb6932015-04-07 11:59:34 -0700700 $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700701
Ying Wangead89442014-02-25 11:18:40 -0800702# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
Ying Wang05f9f352016-05-05 20:02:08 -0700703ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
704$(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP)
705$(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags)
706$(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext)
707$(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700708 $(transform-proto-to-cc)
709
Ying Wang05f9f352016-05-05 20:02:08 -0700710$(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
Ying Wangfaeb6932015-04-07 11:59:34 -0700711endif
Ying Wang05f9f352016-05-05 20:02:08 -0700712# Ideally we can generate the source directly into $(intermediates).
713# But many Android.mks assume the .pb.hs are in $(generated_sources_dir).
714# As a workaround, we make a copy in the $(intermediates).
715proto_intermediate_dir := $(intermediates)/proto
716proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\
717 $(proto_generated_cpps))
718$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/%
719 @echo "Copy: $@"
720 $(copy-file-to-target)
721 $(hide) cp $(basename $<).h $(basename $@).h
722$(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps))
723
724my_generated_sources += $(proto_intermediate_cpps)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700725
Ying Wangfaeb6932015-04-07 11:59:34 -0700726my_c_includes += $(my_proto_c_includes)
727# Auto-export the generated proto source dir.
728my_export_c_include_dirs += $(my_proto_c_includes)
729
730ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc)
Ying Wang8a0d53e2015-04-08 09:54:34 -0700731 my_static_libraries += libprotobuf-c-nano-enable_malloc
Ying Wangfaeb6932015-04-07 11:59:34 -0700732else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c)
Ying Wang8a0d53e2015-04-08 09:54:34 -0700733 my_static_libraries += libprotobuf-c-nano
Yu Shan655f17c2019-01-25 17:11:02 -0800734else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc-16bit)
735 my_static_libraries += libprotobuf-c-nano-enable_malloc-16bit
736else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-16bit)
737 my_static_libraries += libprotobuf-c-nano-16bit
738else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc-32bit)
739 my_static_libraries += libprotobuf-c-nano-enable_malloc-32bit
740else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-32bit)
741 my_static_libraries += libprotobuf-c-nano-32bit
Ying Wangfaeb6932015-04-07 11:59:34 -0700742else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Dan Albertc3031c72014-11-11 10:42:17 -0800743 ifdef LOCAL_SDK_VERSION
Dan Alberta187fb52015-09-08 10:47:03 -0700744 my_static_libraries += libprotobuf-cpp-full-ndk
Dan Albertc3031c72014-11-11 10:42:17 -0800745 else
746 my_shared_libraries += libprotobuf-cpp-full
747 endif
Yabin Cui72a11562016-06-07 19:21:12 -0700748else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static)
749 my_static_libraries += libprotobuf-cpp-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700750else
Dan Albertc3031c72014-11-11 10:42:17 -0800751 ifdef LOCAL_SDK_VERSION
Dan Alberta187fb52015-09-08 10:47:03 -0700752 my_static_libraries += libprotobuf-cpp-lite-ndk
Dan Albertc3031c72014-11-11 10:42:17 -0800753 else
754 my_shared_libraries += libprotobuf-cpp-lite
755 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700756endif
Ying Wangead89442014-02-25 11:18:40 -0800757endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700758
Ying Wanga5fc87a2010-11-02 18:43:16 -0700759###########################################################
Christopher Wiley2df75d12015-10-14 17:27:24 -0700760## AIDL: Compile .aidl files to .cpp and .h files
761###########################################################
762aidl_src := $(strip $(filter %.aidl,$(my_src_files)))
763aidl_gen_cpp :=
764ifneq ($(aidl_src),)
765
Christopher Wiley257796c2016-01-19 08:58:35 -0800766# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
Christopher Wiley2df75d12015-10-14 17:27:24 -0700767aidl_gen_cpp_root := $(intermediates)/aidl-generated/src
768aidl_gen_include_root := $(intermediates)/aidl-generated/include
769
Christopher Wiley257796c2016-01-19 08:58:35 -0800770# Multi-architecture builds have distinct intermediates directories.
771# Thus we'll actually generate source for each architecture.
772$(foreach s,$(aidl_src),\
773 $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
Christopher Wiley087f3272016-01-19 09:26:10 -0800774$(foreach cpp,$(aidl_gen_cpp), \
Dan Willemsenfb842812016-11-13 09:42:19 -0800775 $(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800776$(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp))
Christopher Wiley2df75d12015-10-14 17:27:24 -0700777
Christopher Wiley2df75d12015-10-14 17:27:24 -0700778$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
779$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root)
780$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
781
Christopher Wileyc7e936f2015-11-19 07:06:01 -0800782# Add generated headers to include paths.
Christopher Wiley2df75d12015-10-14 17:27:24 -0700783my_c_includes += $(aidl_gen_include_root)
Christopher Wileyc7e936f2015-11-19 07:06:01 -0800784my_export_c_include_dirs += $(aidl_gen_include_root)
Christopher Wiley2df75d12015-10-14 17:27:24 -0700785# Pick up the generated C++ files later for transformation to .o files.
786my_generated_sources += $(aidl_gen_cpp)
787
788endif # $(aidl_src) non-empty
789
790###########################################################
Keun Soo Yim3d484752016-02-19 11:06:58 -0800791## Compile the .vts files to .cc (or .c) and then to .o
792###########################################################
793
794vts_src := $(strip $(filter %.vts,$(my_src_files)))
795vts_gen_cpp :=
796ifneq ($(vts_src),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700797my_soong_problems += vts
Keun Soo Yim3d484752016-02-19 11:06:58 -0800798
799# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
800vts_gen_cpp_root := $(intermediates)/vts-generated/src
801vts_gen_include_root := $(intermediates)/vts-generated/include
802
803# Multi-architecture builds have distinct intermediates directories.
804# Thus we'll actually generate source for each architecture.
805$(foreach s,$(vts_src),\
806 $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp)))
Keun Soo Yim3d484752016-02-19 11:06:58 -0800807$(call track-src-file-gen,$(vts_src),$(vts_gen_cpp))
808
809$(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
810$(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root)
Keun Soo Yim3c0ffa32016-09-08 18:30:28 -0700811$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) $(addprefix -m,$(LOCAL_VTS_MODE))
Keun Soo Yim3d484752016-02-19 11:06:58 -0800812
813# Add generated headers to include paths.
814my_c_includes += $(vts_gen_include_root)
815my_export_c_include_dirs += $(vts_gen_include_root)
816# Pick up the generated C++ files later for transformation to .o files.
817my_generated_sources += $(vts_gen_cpp)
818
819endif # $(vts_src) non-empty
820
821###########################################################
Ying Wangf0ebe162016-01-11 16:28:45 -0800822## YACC: Compile .y/.yy files to .c/.cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800823###########################################################
824
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000825y_yacc_sources := $(filter %.y,$(my_src_files))
Ying Wangf0ebe162016-01-11 16:28:45 -0800826y_yacc_cs := $(addprefix \
827 $(intermediates)/,$(y_yacc_sources:.y=.c))
828ifneq ($(y_yacc_cs),)
829$(y_yacc_cs): $(intermediates)/%.c: \
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800830 $(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) $(M4) \
Ying Wangf0ebe162016-01-11 16:28:45 -0800831 $(my_additional_dependencies)
832 $(call transform-y-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800833$(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs))
Ying Wangf0ebe162016-01-11 16:28:45 -0800834
835my_generated_sources += $(y_yacc_cs)
836endif
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000837
838yy_yacc_sources := $(filter %.yy,$(my_src_files))
839yy_yacc_cpps := $(addprefix \
840 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
Ying Wangf0ebe162016-01-11 16:28:45 -0800841ifneq ($(yy_yacc_cpps),)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000842$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800843 $(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) $(M4) \
Ying Wangf0ebe162016-01-11 16:28:45 -0800844 $(my_additional_dependencies)
845 $(call transform-y-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800846$(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps))
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000847
Ying Wangf0ebe162016-01-11 16:28:45 -0800848my_generated_sources += $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849endif
850
851###########################################################
Ying Wangf0ebe162016-01-11 16:28:45 -0800852## LEX: Compile .l/.ll files to .c/.cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800853###########################################################
854
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000855l_lex_sources := $(filter %.l,$(my_src_files))
Ying Wangf0ebe162016-01-11 16:28:45 -0800856l_lex_cs := $(addprefix \
857 $(intermediates)/,$(l_lex_sources:.l=.c))
858ifneq ($(l_lex_cs),)
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800859$(l_lex_cs): $(LEX) $(M4)
Ying Wangf0ebe162016-01-11 16:28:45 -0800860$(l_lex_cs): $(intermediates)/%.c: \
861 $(TOPDIR)$(LOCAL_PATH)/%.l
862 $(transform-l-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800863$(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs))
Ying Wangf0ebe162016-01-11 16:28:45 -0800864
865my_generated_sources += $(l_lex_cs)
866endif
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000867
868ll_lex_sources := $(filter %.ll,$(my_src_files))
869ll_lex_cpps := $(addprefix \
870 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
Ying Wangf0ebe162016-01-11 16:28:45 -0800871ifneq ($(ll_lex_cpps),)
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800872$(ll_lex_cpps): $(LEX) $(M4)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000873$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
874 $(TOPDIR)$(LOCAL_PATH)/%.ll
Ying Wangf0ebe162016-01-11 16:28:45 -0800875 $(transform-l-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800876$(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps))
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000877
Ying Wangf0ebe162016-01-11 16:28:45 -0800878my_generated_sources += $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800879endif
880
881###########################################################
882## C++: Compile .cpp files to .o.
883###########################################################
884
Dan Willemsen46267cb2019-01-25 14:35:58 -0800885ifneq ($(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)),)
886$(call pretty-error,Files ending in $(LOCAL_CPP_EXTENSION).arm are deprecated. See $(CHANGES_URL)#file_arm)
887endif
Ying Wangfb22a422015-03-10 18:03:11 -0700888
889dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
890dotdot_objects :=
891$(foreach s,$(dotdot_sources),\
892 $(eval $(call compile-dotdot-cpp-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -0700893 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -0800894 dotdot_objects,\
895 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800896$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
Ying Wangfb22a422015-03-10 18:03:11 -0700897
898cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
Dan Willemsen46267cb2019-01-25 14:35:58 -0800899cpp_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
900$(call track-src-file-obj,$(cpp_normal_sources),$(cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800901
Dan Willemsen46267cb2019-01-25 14:35:58 -0800902$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
903$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800904
905ifneq ($(strip $(cpp_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800906$(cpp_objects): .KATI_NINJA_POOL := $(my_pool)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700908 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000909 $(my_additional_dependencies) $(CLANG_CXX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800910 $(transform-$(PRIVATE_HOST)cpp-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900911$(call include-depfiles-for-objs, $(cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800912endif
913
Dan Willemsen46267cb2019-01-25 14:35:58 -0800914cpp_objects += $(dotdot_objects)
Ying Wangfb22a422015-03-10 18:03:11 -0700915
The Android Open Source Project88b60792009-03-03 19:28:42 -0800916###########################################################
917## C++: Compile generated .cpp files to .o.
918###########################################################
919
Ying Wangec6d6262014-01-16 16:21:03 -0800920gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800921gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800922$(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800923
924ifneq ($(strip $(gen_cpp_objects)),)
925# Compile all generated files as thumb.
Colin Cross23dcf762019-11-11 16:04:34 -0800926$(gen_cpp_objects): .KATI_NINJA_POOL := $(my_pool)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800927$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
928$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400929$(gen_cpp_objects): $(intermediates)/%.o: \
Ying Wang05f9f352016-05-05 20:02:08 -0700930 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000931 $(my_additional_dependencies) $(CLANG_CXX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932 $(transform-$(PRIVATE_HOST)cpp-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900933$(call include-depfiles-for-objs, $(gen_cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800934endif
935
936###########################################################
937## S: Compile generated .S and .s files to .o.
938###########################################################
939
Ying Wangec6d6262014-01-16 16:21:03 -0800940gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800941gen_S_objects := $(gen_S_sources:%.S=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800942$(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800943
944ifneq ($(strip $(gen_S_sources)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800945$(gen_S_objects): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400946$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000947 $(my_additional_dependencies) $(CLANG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800948 $(transform-$(PRIVATE_HOST)s-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900949$(call include-depfiles-for-objs, $(gen_S_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800950endif
951
Ying Wangec6d6262014-01-16 16:21:03 -0800952gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800953gen_s_objects := $(gen_s_sources:%.s=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800954$(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800955
956ifneq ($(strip $(gen_s_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800957$(gen_s_objects): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400958$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000959 $(my_additional_dependencies) $(CLANG)
Dan Willemsen461d8442016-11-10 18:19:36 -0800960 $(transform-$(PRIVATE_HOST)s-to-o)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800961endif
962
963gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
Dan Willemsen45d38c02016-01-15 16:38:46 -0800964$(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800965
966###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000967## o: Include generated .o files in output.
968###########################################################
969
Ying Wangec6d6262014-01-16 16:21:03 -0800970gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000971
972###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800973## C: Compile .c files to .o.
974###########################################################
975
Dan Willemsen46267cb2019-01-25 14:35:58 -0800976ifneq ($(filter %.c.arm,$(my_src_files)),)
977$(call pretty-error,Files ending in .c.arm are deprecated. See $(CHANGES_URL)#file_arm)
978endif
Ying Wangfb22a422015-03-10 18:03:11 -0700979
980dotdot_sources := $(filter ../%.c, $(my_src_files))
981dotdot_objects :=
982$(foreach s, $(dotdot_sources),\
983 $(eval $(call compile-dotdot-c-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -0700984 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -0800985 dotdot_objects,\
986 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800987$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
Ying Wangfb22a422015-03-10 18:03:11 -0700988
989c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
Dan Willemsen46267cb2019-01-25 14:35:58 -0800990c_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
991$(call track-src-file-obj,$(c_normal_sources),$(c_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800992
Dan Willemsen46267cb2019-01-25 14:35:58 -0800993$(dotdot_objects) $(c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
994$(dotdot_objects) $(c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800995
996ifneq ($(strip $(c_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800997$(c_objects): .KATI_NINJA_POOL := $(my_pool)
Ying Wang05f9f352016-05-05 20:02:08 -0700998$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000999 $(my_additional_dependencies) $(CLANG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001000 $(transform-$(PRIVATE_HOST)c-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001001$(call include-depfiles-for-objs, $(c_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001002endif
1003
Dan Willemsen46267cb2019-01-25 14:35:58 -08001004c_objects += $(dotdot_objects)
Ying Wangfb22a422015-03-10 18:03:11 -07001005
The Android Open Source Project88b60792009-03-03 19:28:42 -08001006###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001007## C: Compile generated .c files to .o.
1008###########################################################
1009
Ying Wangec6d6262014-01-16 16:21:03 -08001010gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001011gen_c_objects := $(gen_c_sources:%.c=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001012$(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001013
1014ifneq ($(strip $(gen_c_objects)),)
1015# Compile all generated files as thumb.
Colin Cross23dcf762019-11-11 16:04:34 -08001016$(gen_c_objects): .KATI_NINJA_POOL := $(my_pool)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001017$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
1018$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wang05f9f352016-05-05 20:02:08 -07001019$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001020 $(my_additional_dependencies) $(CLANG)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001021 $(transform-$(PRIVATE_HOST)c-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001022$(call include-depfiles-for-objs, $(gen_c_objects))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -07001023endif
1024
1025###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001026## ObjC: Compile .m files to .o
1027###########################################################
1028
Ying Wangb8e01852014-01-23 15:09:04 -08001029objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001030objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
Dan Willemsen62f2e562016-02-01 18:55:23 -08001031$(call track-src-file-obj,$(objc_sources),$(objc_objects))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001032
1033ifneq ($(strip $(objc_objects)),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001034my_soong_problems += objc
Colin Cross23dcf762019-11-11 16:04:34 -08001035$(objc_objects): .KATI_NINJA_POOL := $(my_pool)
Ying Wang05f9f352016-05-05 20:02:08 -07001036$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001037 $(my_additional_dependencies) $(CLANG)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001038 $(transform-$(PRIVATE_HOST)m-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001039$(call include-depfiles-for-objs, $(objc_objects))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +02001040endif
1041
1042###########################################################
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001043## ObjC++: Compile .mm files to .o
1044###########################################################
1045
1046objcpp_sources := $(filter %.mm,$(my_src_files))
1047objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o))
Dan Willemsen62f2e562016-02-01 18:55:23 -08001048$(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects))
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001049
1050ifneq ($(strip $(objcpp_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -08001051$(objcpp_objects): .KATI_NINJA_POOL := $(my_pool)
Ying Wang05f9f352016-05-05 20:02:08 -07001052$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001053 $(my_additional_dependencies) $(CLANG_CXX)
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001054 $(transform-$(PRIVATE_HOST)mm-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +09001055$(call include-depfiles-for-objs, $(objcpp_objects))
Scott James Remnantdd86e5a2015-09-17 15:40:49 -07001056endif
1057
1058###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001059## AS: Compile .S files to .o.
1060###########################################################
1061
Ying Wangb8e01852014-01-23 15:09:04 -08001062asm_sources_S := $(filter %.S,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -07001063dotdot_sources := $(filter ../%,$(asm_sources_S))
1064asm_sources_S := $(filter-out ../%,$(asm_sources_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001065asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001066$(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001067
Ying Wangfb22a422015-03-10 18:03:11 -07001068dotdot_objects_S :=
1069$(foreach s,$(dotdot_sources),\
1070 $(eval $(call compile-dotdot-s-file,$(s),\
1071 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -08001072 dotdot_objects_S,\
1073 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001074$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S))
Ying Wangfb22a422015-03-10 18:03:11 -07001075
The Android Open Source Project88b60792009-03-03 19:28:42 -08001076ifneq ($(strip $(asm_objects_S)),)
Colin Cross23dcf762019-11-11 16:04:34 -08001077$(asm_objects_S): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001078$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001079 $(my_additional_dependencies) $(CLANG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001080 $(transform-$(PRIVATE_HOST)s-to-o)
Shinichiro Hamaji72904772016-03-16 06:40:04 +09001081$(call include-depfiles-for-objs, $(asm_objects_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001082endif
1083
Ying Wangb8e01852014-01-23 15:09:04 -08001084asm_sources_s := $(filter %.s,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -07001085dotdot_sources := $(filter ../%,$(asm_sources_s))
1086asm_sources_s := $(filter-out ../%,$(asm_sources_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001087asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001088$(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001089
Ying Wangfb22a422015-03-10 18:03:11 -07001090dotdot_objects_s :=
1091$(foreach s,$(dotdot_sources),\
1092 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\
1093 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -08001094 dotdot_objects_s,\
1095 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001096$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s))
Ying Wangfb22a422015-03-10 18:03:11 -07001097
The Android Open Source Project88b60792009-03-03 19:28:42 -08001098ifneq ($(strip $(asm_objects_s)),)
Colin Cross23dcf762019-11-11 16:04:34 -08001099$(asm_objects_s): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001100$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001101 $(my_additional_dependencies) $(CLANG)
Dan Willemsen461d8442016-11-10 18:19:36 -08001102 $(transform-$(PRIVATE_HOST)s-to-o)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001103endif
1104
Ying Wangfb22a422015-03-10 18:03:11 -07001105asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
Dan Willemsen45d38c02016-01-15 16:38:46 -08001106$(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001107
1108
Ying Wangfe1e5c32015-03-09 18:57:40 -07001109# .asm for x86/x86_64 needs to be compiled with yasm.
Ying Wang7b913ce2014-06-05 19:05:47 -07001110asm_sources_asm := $(filter %.asm,$(my_src_files))
1111ifneq ($(strip $(asm_sources_asm)),)
1112asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
1113$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001114 $(my_additional_dependencies) $(YASM)
Ying Wang7b913ce2014-06-05 19:05:47 -07001115 $(transform-asm-to-o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001116$(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm))
Ying Wang7b913ce2014-06-05 19:05:47 -07001117
1118asm_objects += $(asm_objects_asm)
1119endif
Ying Wang7b913ce2014-06-05 19:05:47 -07001120
Vishwath Mohan96a130b2017-11-17 11:19:36 -08001121###################################################################
Inseob Kim8b0ccda2020-08-04 00:51:33 +09001122## Convert to sanitized names where they exist.
1123## These lists come from sanitizerStaticLibsMap; see
1124## build/soong/cc/sanitize.go
1125##
1126## $(1): list of static dependencies
1127## $(2): name of sanitizer (e.g. cfi, hwasan)
1128##################################################################
1129define use_soong_sanitized_static_libraries
1130 $(foreach lib,$(1),$(if $(filter $(lib),\
1131 $(SOONG_$(2)_$(my_image_variant)_$(my_arch)_STATIC_LIBRARIES)),\
1132 $(lib).$(2),$(lib)))
1133endef
1134
1135###################################################################
Vishwath Mohan96a130b2017-11-17 11:19:36 -08001136## When compiling a CFI enabled target, use the .cfi variant of any
1137## static dependencies (where they exist).
1138##################################################################
Vishwath Mohan96a130b2017-11-17 11:19:36 -08001139ifneq ($(filter cfi,$(my_sanitize)),)
Inseob Kim8b0ccda2020-08-04 00:51:33 +09001140 my_whole_static_libraries := $(call use_soong_sanitized_static_libraries,\
1141 $(my_whole_static_libraries),cfi)
1142 my_static_libraries := $(call use_soong_sanitized_static_libraries,\
1143 $(my_static_libraries),cfi)
Vishwath Mohan96a130b2017-11-17 11:19:36 -08001144endif
1145
Inseob Kim8b0ccda2020-08-04 00:51:33 +09001146###################################################################
1147## When compiling a hwasan enabled target, use the .hwasan variant
1148## of any static dependencies (where they exist).
1149##################################################################
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07001150ifneq ($(filter hwaddress,$(my_sanitize)),)
Inseob Kim8b0ccda2020-08-04 00:51:33 +09001151 my_whole_static_libraries := $(call use_soong_sanitized_static_libraries,\
1152 $(my_whole_static_libraries),hwasan)
1153 my_static_libraries := $(call use_soong_sanitized_static_libraries,\
1154 $(my_static_libraries),hwasan)
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07001155endif
1156
Kiyoung Kimad0d7712022-08-31 14:02:36 +09001157###################################################################
1158## When compiling against API imported module, use API import stub
1159## libraries.
1160##################################################################
1161
1162apiimport_postfix := .apiimport
1163
1164ifneq ($(LOCAL_USE_VNDK),)
1165 ifeq ($(LOCAL_USE_VNDK_PRODUCT),true)
1166 apiimport_postfix := .apiimport.product
1167 else
1168 apiimport_postfix := .apiimport.vendor
1169 endif
1170endif
1171
1172my_shared_libraries := $(foreach l,$(my_shared_libraries), \
1173 $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
1174my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries), \
1175 $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
1176my_header_libraries := $(foreach l,$(my_header_libraries), \
1177 $(if $(filter $(l), $(API_IMPORTED_HEADER_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
1178
Jiyong Parkc8f57d92017-04-18 20:15:14 +09001179###########################################################
1180## When compiling against the VNDK, use LL-NDK libraries
1181###########################################################
1182ifneq ($(LOCAL_USE_VNDK),)
Justin Yun2bfe0a12020-01-20 18:57:01 +09001183 #####################################################
1184 ## Soong modules may be built three times, once for
1185 ## /system, once for /vendor and once for /product.
1186 ## If we're using the VNDK, switch all soong
1187 ## libraries over to the /vendor or /product variant.
1188 #####################################################
1189 ifeq ($(LOCAL_USE_VNDK_PRODUCT),true)
1190 my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
1191 $(if $(SPLIT_PRODUCT.STATIC_LIBRARIES.$(l)),$(l).product,$(l)))
1192 my_static_libraries := $(foreach l,$(my_static_libraries),\
1193 $(if $(SPLIT_PRODUCT.STATIC_LIBRARIES.$(l)),$(l).product,$(l)))
1194 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
1195 $(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
1196 my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
1197 $(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
1198 my_header_libraries := $(foreach l,$(my_header_libraries),\
1199 $(if $(SPLIT_PRODUCT.HEADER_LIBRARIES.$(l)),$(l).product,$(l)))
1200 else
1201 my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
1202 $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
1203 my_static_libraries := $(foreach l,$(my_static_libraries),\
1204 $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
1205 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
1206 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
1207 my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
1208 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
1209 my_header_libraries := $(foreach l,$(my_header_libraries),\
1210 $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l)))
1211 endif
Jiyong Parkc8f57d92017-04-18 20:15:14 +09001212endif
Jeff Davidson680f0712015-01-08 18:25:30 -08001213
Jiyong Parkc3f13562018-03-19 18:12:39 +09001214# Platform can use vendor public libraries. If a required shared lib is one of
1215# the vendor public libraries, the lib is switched to the stub version of the lib.
1216ifeq ($(LOCAL_USE_VNDK),)
Colin Cross8fb525d2018-09-06 16:25:22 -07001217 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
1218 $(if $(filter $(l),$(VENDOR_PUBLIC_LIBRARIES)),$(l).vendorpublic,$(l)))
Jiyong Parkc3f13562018-03-19 18:12:39 +09001219endif
1220
Colin Crosse0c5e442020-04-07 16:50:32 +00001221###########################################################
1222## When compiling against the NDK, use SDK variants of Soong libraries
1223###########################################################
1224
1225ifneq ($(LOCAL_SDK_VERSION),)
1226 my_whole_static_libraries := $(call use_soong_sdk_libraries,$(my_whole_static_libraries))
1227 my_static_libraries := $(call use_soong_sdk_libraries,$(my_static_libraries))
1228 my_shared_libraries := $(call use_soong_sdk_libraries,$(my_shared_libraries))
1229 my_system_shared_libraries := $(call use_soong_sdk_libraries,$(my_system_shared_libraries))
1230 my_header_libraries := $(call use_soong_sdk_libraries,$(my_header_libraries))
1231endif
1232
Jeff Davidson680f0712015-01-08 18:25:30 -08001233##########################################################
1234## Set up installed module dependency
1235## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
1236## they may cusomize their install path with LOCAL_MODULE_PATH
1237##########################################################
1238# Get the list of INSTALLED libraries as module names.
Dan Willemsenffa32582017-03-19 13:22:45 -07001239ifneq ($(LOCAL_SDK_VERSION),)
Jeff Davidson680f0712015-01-08 18:25:30 -08001240 installed_shared_library_module_names := \
1241 $(my_shared_libraries)
1242else
1243 installed_shared_library_module_names := \
1244 $(my_shared_libraries) $(my_system_shared_libraries)
1245endif
1246
1247# The real dependency will be added after all Android.mks are loaded and the install paths
1248# of the shared libraries are determined.
1249ifdef LOCAL_INSTALLED_MODULE
1250ifdef installed_shared_library_module_names
1251$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Dimitry Ivanovcdf39272017-06-26 13:13:44 -07001252 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Jeff Davidson680f0712015-01-08 18:25:30 -08001253endif
1254endif
1255
1256
Ying Wang5f074802011-11-08 09:31:21 -08001257####################################################
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001258## Verify that NDK-built libraries only link against
1259## other NDK-built libraries
1260####################################################
1261
Dan Albert975e3032017-12-19 11:26:05 -08001262include $(BUILD_SYSTEM)/allowed_ndk_types.mk
1263
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001264ifdef LOCAL_SDK_VERSION
Dan Albert4297c392017-12-19 11:27:39 -08001265my_link_type := native:ndk:$(my_ndk_stl_family):$(my_ndk_stl_link_type)
Dan Albert975e3032017-12-19 11:26:05 -08001266my_warn_types := $(my_warn_ndk_types)
1267my_allowed_types := $(my_allowed_ndk_types)
Dan Willemsen9d2b3282017-04-07 20:58:43 -07001268else ifdef LOCAL_USE_VNDK
Jiyong Parka3fb1582017-08-16 18:28:12 +09001269 _name := $(patsubst %.vendor,%,$(LOCAL_MODULE))
Justin Yun2bfe0a12020-01-20 18:57:01 +09001270 _name := $(patsubst %.product,%,$(LOCAL_MODULE))
Jiyong Parka3fb1582017-08-16 18:28:12 +09001271 ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),)
1272 ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),)
1273 my_link_type := native:vndk
1274 else
1275 my_link_type := native:vndk_private
1276 endif
1277 my_warn_types :=
1278 my_allowed_types := native:vndk native:vndk_private
Justin Yun2bfe0a12020-01-20 18:57:01 +09001279 else ifeq ($(LOCAL_USE_VNDK_PRODUCT),true)
1280 # Modules installed to /product cannot directly depend on modules marked
1281 # with vendor_available: false
1282 my_link_type := native:product
1283 my_warn_types :=
1284 my_allowed_types := native:product native:vndk native:platform_vndk
Jiyong Parka3fb1582017-08-16 18:28:12 +09001285 else
1286 # Modules installed to /vendor cannot directly depend on modules marked
1287 # with vendor_available: false
1288 my_link_type := native:vendor
1289 my_warn_types :=
Vic Yang51512c52018-11-12 20:16:26 -08001290 my_allowed_types := native:vendor native:vndk native:platform_vndk
Jiyong Parka3fb1582017-08-16 18:28:12 +09001291 endif
Jiyong Parka52b6e92018-09-12 10:03:37 +09001292else ifneq ($(filter $(TARGET_RECOVERY_OUT)/%,$(call get_non_asan_path,$(LOCAL_MODULE_PATH))),)
Jiyong Park5dc34752018-08-28 12:32:45 +09001293my_link_type := native:recovery
1294my_warn_types :=
1295# TODO(b/113303515) remove native:platform and my_allowed_ndk_types
Vic Yang51512c52018-11-12 20:16:26 -08001296my_allowed_types := native:recovery native:platform native:platform_vndk $(my_allowed_ndk_types)
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001297else
Dan Willemsenb47d4e92017-04-08 00:31:31 -07001298my_link_type := native:platform
Dan Albert975e3032017-12-19 11:26:05 -08001299my_warn_types := $(my_warn_ndk_types)
Vic Yang51512c52018-11-12 20:16:26 -08001300my_allowed_types := $(my_allowed_ndk_types) native:platform native:platform_vndk
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001301endif
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001302
Dan Willemsenb47d4e92017-04-08 00:31:31 -07001303my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries))
1304ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
1305my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries))
1306endif
1307
1308my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
1309my_common :=
1310include $(BUILD_SYSTEM)/link_type.mk
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001311
The Android Open Source Project88b60792009-03-03 19:28:42 -08001312###########################################################
1313## Common object handling.
1314###########################################################
1315
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001316my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files))
1317ifneq ($(my_unused_src_files),)
Dan Willemsen9efeb1e2016-06-28 10:22:08 -07001318 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001319endif
1320
The Android Open Source Project88b60792009-03-03 19:28:42 -08001321# some rules depend on asm_objects being first. If your code depends on
1322# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001323normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -07001324 $(asm_objects) \
1325 $(cpp_objects) \
1326 $(gen_cpp_objects) \
1327 $(gen_asm_objects) \
1328 $(c_objects) \
1329 $(gen_c_objects) \
1330 $(objc_objects) \
Ying Wang05f9f352016-05-05 20:02:08 -07001331 $(objcpp_objects)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001332
1333new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f)))
1334new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f)))
1335
1336ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects)))
1337$(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old)
1338$(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects))))
1339$(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects))))
1340endif
1341
1342ifeq ($(BINARY_OBJECTS_ORDER),soong)
1343normal_objects := $(new_order_normal_objects)
1344endif
1345
1346normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001347
1348all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001349
Dan Willemsen11ee3412019-01-10 13:21:07 -08001350LOCAL_INTERMEDIATE_TARGETS += $(all_objects)
1351
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001352# Cleanup file tracking
1353$(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=))
1354my_tracked_gen_files :=
1355$(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=))
1356my_tracked_src_files :=
1357
Colin Cross2d206702014-02-13 13:41:52 -08001358my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001359
Dan Willemsenc9a657c2019-11-07 13:53:57 -08001360my_c_includes := $(foreach inc,$(my_c_includes),$(call clean-path,$(inc)))
1361
Dan Willemsen0cb422f2019-11-25 17:51:18 -08001362my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes)) $(filter ../%,$(my_c_includes)))
Dan Willemsen062e30b2016-05-24 13:06:07 -07001363ifneq ($(my_outside_includes),)
Dan Willemsen0cb422f2019-11-25 17:51:18 -08001364 ifeq ($(BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS),true)
1365 $(call pretty-warning,C_INCLUDES must be under the source or output directories: $(my_outside_includes))
1366 else
1367 $(call pretty-error,C_INCLUDES must be under the source or output directories: $(my_outside_includes))
1368 endif
Dan Willemsen062e30b2016-05-24 13:06:07 -07001369endif
1370
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001371# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
1372# use normal_objects here to avoid creating circular dependencies. This assumes
1373# that custom build rules which generate .o files don't consume other generated
1374# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -08001375$(normal_objects) : | $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001376ALL_C_CPP_ETC_OBJECTS += $(all_objects)
1377
The Android Open Source Project88b60792009-03-03 19:28:42 -08001378
1379###########################################################
1380# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001381###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001382
1383###########################################################
1384# The list of libraries that this module will link against are in
1385# these variables. Each is a list of bare module names like "libc libm".
1386#
1387# LOCAL_SHARED_LIBRARIES
1388# LOCAL_STATIC_LIBRARIES
1389# LOCAL_WHOLE_STATIC_LIBRARIES
1390#
1391# We need to convert the bare names into the dependencies that
1392# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
1393# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
1394# libraries, so that simply building this module doesn't force
1395# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
1396# should depend on the INSTALLED versions of the libraries so
1397# that they get installed when this module does.
1398###########################################################
1399# NOTE:
1400# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
1401# module without leaving anything out, which is useful for turning
1402# a collection of .a files into a .so file. Linking against a
1403# normal STATIC_LIBRARY will only pull in code/symbols that are
1404# referenced by the module. (see gcc/ld's --whole-archive option)
1405###########################################################
1406
1407# Get the list of BUILT libraries, which are under
1408# various intermediates directories.
1409so_suffix := $($(my_prefix)SHLIB_SUFFIX)
1410a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
1411
Dan Willemsenffa32582017-03-19 13:22:45 -07001412ifneq ($(LOCAL_SDK_VERSION),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001413built_shared_libraries := \
Dan Willemsen8cf6b652018-09-05 11:01:12 -07001414 $(foreach lib,$(my_shared_libraries), \
1415 $(call intermediates-dir-for, \
1416 SHARED_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(so_suffix))
Ying Wangc01f2dc2015-12-15 10:00:19 -08001417built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001418
Ying Wangd8d37212014-03-21 16:17:04 -07001419# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -08001420my_system_shared_libraries_fullpath := \
1421 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -07001422 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -07001423 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -07001424
Dan Albertc1ca1902016-08-04 14:14:50 -07001425# We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of
1426# whether the libs are generated or prebuilt, so we simply can't split into two
1427# lists and use addprefix.
1428my_ndk_shared_libraries_fullpath := \
1429 $(foreach _lib,$(my_ndk_shared_libraries),\
Dan Albert016da582020-06-30 12:46:41 -07001430 $(if $(filter $(NDK_KNOWN_LIBS),$(_lib)),\
Dan Albertc1ca1902016-08-04 14:14:50 -07001431 $(my_built_ndk_libs)/$(_lib)$(so_suffix),\
1432 $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix)))
Dan Albert02bf1382016-07-21 10:04:12 -07001433
1434built_shared_libraries += \
Dan Albertc1ca1902016-08-04 14:14:50 -07001435 $(my_ndk_shared_libraries_fullpath) \
Dan Albert02bf1382016-07-21 10:04:12 -07001436 $(my_system_shared_libraries_fullpath) \
1437
Dan Willemsenb4416302019-06-12 17:25:23 +00001438built_shared_library_deps += \
1439 $(my_ndk_shared_libraries_fullpath) \
1440 $(my_system_shared_libraries_fullpath) \
1441
Ying Wang1a081002010-07-13 14:55:47 -07001442else
Ying Wang1a081002010-07-13 14:55:47 -07001443built_shared_libraries := \
Dan Willemsen8cf6b652018-09-05 11:01:12 -07001444 $(foreach lib,$(installed_shared_library_module_names), \
1445 $(call intermediates-dir-for, \
1446 SHARED_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(so_suffix))
Ying Wangc01f2dc2015-12-15 10:00:19 -08001447built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +09001448my_system_shared_libraries_fullpath :=
Ying Wang1a081002010-07-13 14:55:47 -07001449endif
1450
The Android Open Source Project88b60792009-03-03 19:28:42 -08001451built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001452 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001453 $(call intermediates-dir-for, \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001454 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001455
Ying Wang848020f2012-08-14 10:13:16 -07001456ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -08001457built_static_libraries += $(my_ndk_stl_static_lib)
1458endif
1459
The Android Open Source Project88b60792009-03-03 19:28:42 -08001460built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -08001461 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001462 $(call intermediates-dir-for, \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001463 STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001464
The Android Open Source Project88b60792009-03-03 19:28:42 -08001465# We don't care about installed static libraries, since the
1466# libraries have already been linked into the module at that point.
1467# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +00001468# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001469installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -08001470 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
Jaewoong Junge8cb1952018-11-08 16:53:02 -08001471 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-STATIC_LIBRARIES-$(lib))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001472
Colin Cross579668b2018-08-14 13:13:47 -07001473$(notice_target): | $(installed_static_library_notice_file_targets)
1474$(LOCAL_INSTALLED_MODULE): | $(notice_target)
1475
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001476# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -07001477ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
1478LOCAL_RTTI_FLAG := -fno-rtti
1479endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001480
The Android Open Source Project88b60792009-03-03 19:28:42 -08001481###########################################################
1482# Rule-specific variable definitions
1483###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +08001484
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001485my_cflags += $(LOCAL_CLANG_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -08001486my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
Dan Albertd2fa96d2014-11-28 14:00:12 -08001487my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001488my_asflags += $(LOCAL_CLANG_ASFLAGS)
1489my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001490my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
Stephen Hines15680292014-11-26 00:53:46 -08001491my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix))
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001492my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
1493my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
1494my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
Dan Willemsen02268f02016-05-19 14:39:25 -07001495my_cflags := $(call convert-to-clang-flags,$(my_cflags))
1496my_cppflags := $(call convert-to-clang-flags,$(my_cppflags))
1497my_asflags := $(call convert-to-clang-flags,$(my_asflags))
1498my_ldflags := $(call convert-to-clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +08001499
Brad Hinegardner3e7f6b72022-10-27 19:01:10 +00001500# No one should ever use this flag. On GCC it's mere presence will disable all
Dan Albertdf3fd1d2015-08-12 14:54:16 -07001501# warnings, even those that are specified after it (contrary to typical warning
1502# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
1503# warnings that are *always* bugs.
1504my_illegal_flags := -w
1505my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags))
1506my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
1507my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
1508
Dan Albert5ae31dd2016-01-29 16:51:51 -08001509# We can enforce some rules more strictly in the code we own. my_strict
1510# indicates if this is code that we can be stricter with. If we have rules that
1511# we want to apply to *our* code (but maybe can't for vendor/device specific
1512# things), we could extend this to be a ternary value.
1513my_strict := true
1514ifneq ($(filter external/%,$(LOCAL_PATH)),)
1515 my_strict := false
1516endif
1517
1518# Can be used to make some annotations stricter for code we can fix (such as
1519# when we mark functions as deprecated).
1520ifeq ($(my_strict),true)
1521 my_cflags += -DANDROID_STRICT
1522endif
1523
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -08001524# Check if -Werror or -Wno-error is used in C compiler flags.
Colin Cross8fb525d2018-09-06 16:25:22 -07001525# Header libraries do not need cflags.
Colin Cross0d1f54e2019-11-12 15:53:04 -08001526my_all_cflags := $(my_cflags) $(my_cppflags) $(my_cflags_no_override)
Colin Cross8fb525d2018-09-06 16:25:22 -07001527ifneq (HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS))
1528 # Prebuilt modules do not need cflags.
1529 ifeq (,$(LOCAL_PREBUILT_MODULE_FILE))
Colin Cross8fb525d2018-09-06 16:25:22 -07001530 # Issue warning if -Wno-error is used.
1531 ifneq (,$(filter -Wno-error,$(my_all_cflags)))
1532 $(eval MODULES_USING_WNO_ERROR := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
1533 else
1534 # Issue warning if -Werror is not used. Add it.
1535 ifeq (,$(filter -Werror,$(my_all_cflags)))
1536 # Add -Wall -Werror unless the project is in the WARNING_ALLOWED project list.
1537 ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH))))
1538 my_cflags := -Wall -Werror $(my_cflags)
1539 else
Yi Kongee99ddf2022-05-19 20:13:55 +08001540 $(eval MODULES_WARNINGS_ALLOWED := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
Colin Cross8fb525d2018-09-06 16:25:22 -07001541 my_cflags := -Wall $(my_cflags)
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -08001542 endif
1543 endif
1544 endif
Chih-Hung Hsiehbab04882016-10-11 15:38:39 -07001545 endif
1546endif
1547
Colin Cross0d1f54e2019-11-12 15:53:04 -08001548ifneq (,$(filter -Weverything,$(my_all_cflags)))
1549 ifeq (,$(ANDROID_TEMPORARILY_ALLOW_WEVERYTHING))
1550 $(call pretty-error, -Weverything is not allowed in Android.mk files.\
1551 Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.)
1552 endif
1553endif
1554
Chih-Hung Hsiehbe5dd202018-08-26 20:37:49 -07001555ifneq ($(my_tidy_checks),)
Dan Willemsenceba3cb2020-08-05 17:06:34 -07001556 tidy_only: $(cpp_objects) $(c_objects) $(gen_c_objects) $(gen_cpp_objects)
1557
1558 # Add dependency of clang-tidy and clang-tidy.sh
George Burgess IV09e5d9b2019-04-04 16:21:53 -07001559 $(cpp_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
1560 $(c_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
1561 $(gen_cpp_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
1562 $(gen_c_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
Chih-Hung Hsiehbe5dd202018-08-26 20:37:49 -07001563endif
1564
Dan Willemsen6731b492016-06-07 16:55:57 -07001565# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
1566my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
1567my_ldlibs := $(filter -l%,$(my_ldlib_flags))
1568my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
1569
1570# One last verification check for ldlibs
Dan Willemsen6731b492016-06-07 16:55:57 -07001571my_allowed_ldlibs :=
Dan Willemsen4dbb3542017-09-26 00:14:01 -07001572ifndef LOCAL_IS_HOST_MODULE
1573 ifneq ($(LOCAL_SDK_VERSION),)
Dan Albert016da582020-06-30 12:46:41 -07001574 my_allowed_ldlibs := $(NDK_KNOWN_LIBS:lib%=-l%)
Dan Willemsen4dbb3542017-09-26 00:14:01 -07001575 endif
1576else
1577 my_allowed_ldlibs := $($(my_prefix)AVAILABLE_LIBRARIES)
Dan Willemsen6731b492016-06-07 16:55:57 -07001578endif
1579
1580my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs))
1581ifneq ($(my_bad_ldlibs),)
1582 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs))
1583endif
Dan Willemsen6731b492016-06-07 16:55:57 -07001584
Dan Willemsenc9aa6fc2016-09-13 10:44:44 -07001585# my_cxx_ldlibs may contain linker flags need to wrap certain libraries
1586# (start-group/end-group), so append after the check above.
1587my_ldlibs += $(my_cxx_ldlibs)
1588
Dan Willemsene24da822019-01-10 13:10:17 -08001589###########################################################
1590## Define PRIVATE_ variables from global vars
1591###########################################################
1592ifndef LOCAL_IS_HOST_MODULE
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001593
Dan Willemsene24da822019-01-10 13:10:17 -08001594ifdef LOCAL_USE_VNDK
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001595 my_target_global_c_includes :=
1596 my_target_global_c_system_includes := $(TARGET_OUT_HEADERS)
Dan Willemsene24da822019-01-10 13:10:17 -08001597else ifdef LOCAL_SDK_VERSION
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001598 my_target_global_c_includes :=
1599 my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
Dan Willemsene24da822019-01-10 13:10:17 -08001600else ifdef BOARD_VNDK_VERSION
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001601 my_target_global_c_includes := $(SRC_HEADERS) \
Dan Willemsene24da822019-01-10 13:10:17 -08001602 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001603 my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
Dan Willemsene24da822019-01-10 13:10:17 -08001604 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
1605else
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001606 my_target_global_c_includes := $(SRC_HEADERS) \
Dan Willemsene24da822019-01-10 13:10:17 -08001607 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001608 my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) $(TARGET_OUT_HEADERS) \
Dan Willemsene24da822019-01-10 13:10:17 -08001609 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
1610endif
1611
1612my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
1613my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
1614my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
1615ifeq ($(my_use_clang_lld),true)
1616 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
1617 include $(BUILD_SYSTEM)/pack_dyn_relocs_setup.mk
Pirama Arumuga Nainarbf2af952019-07-30 22:32:20 -07001618 ifeq ($(my_pack_module_relocations),true)
1619 my_target_global_ldflags += -Wl,--pack-dyn-relocs=android+relr -Wl,--use-android-relr-tags
1620 else
Dan Willemsene24da822019-01-10 13:10:17 -08001621 my_target_global_ldflags += -Wl,--pack-dyn-relocs=none
1622 endif
1623else
1624 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
1625endif # my_use_clang_lld
1626
Peter Collingbournee3606ae2019-07-25 17:43:04 -07001627my_target_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)TRIPLE)
1628ifndef LOCAL_IS_HOST_MODULE
1629 my_target_triple_flag := -target $(my_target_triple)$(my_api_level)
1630else
1631 my_target_triple_flag := -target $(my_target_triple)
1632endif
1633my_asflags += $(my_target_triple_flag)
1634my_cflags += $(my_target_triple_flag)
1635my_ldflags += $(my_target_triple_flag)
1636
Dan Willemsene24da822019-01-10 13:10:17 -08001637$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
1638$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
1639$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
1640$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
1641$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
1642$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
1643
1644else # LOCAL_IS_HOST_MODULE
1645
1646my_host_global_c_includes := $(SRC_HEADERS) \
1647 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
1648my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
1649 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
1650
1651my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
1652my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
1653my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
1654ifeq ($(my_use_clang_lld),true)
1655 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
1656else
1657 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
1658endif # my_use_clang_lld
1659
1660$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes)
1661$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes)
1662$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
1663$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
1664$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
1665$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
1666endif # LOCAL_IS_HOST_MODULE
1667
1668# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
1669# build with NATIVE_COVERAGE=true in your enviornment.
1670ifeq ($(NATIVE_COVERAGE),true)
1671 ifeq ($(my_native_coverage),true)
1672 # Note that clang coverage doesn't play nicely with acov out of the box.
1673 # Clang apparently generates .gcno files that aren't compatible with
1674 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov
1675 # with `--gcov-tool /usr/bin/gcov-4.6`.
1676 #
1677 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
1678 my_cflags += --coverage -O0
1679 my_ldflags += --coverage
1680 endif
1681
1682 my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
1683
1684 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
1685 $(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib)
1686endif
1687
Dan Willemsen18ffd582019-07-31 10:31:20 -07001688####################################################
1689## Import includes
1690####################################################
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001691imported_includes :=
1692
1693ifdef LOCAL_USE_VNDK
1694 imported_includes += $(call intermediates-dir-for,HEADER_LIBRARIES,device_kernel_headers,$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
1695else ifdef LOCAL_SDK_VERSION
1696 # Apps shouldn't need device-specific kernel headers
1697else ifdef BOARD_VNDK_VERSION
1698 # For devices building with the VNDK, only the VNDK gets device-specific kernel headers by default
1699 # In soong, it's entirely opt-in
1700else
1701 # For older non-VNDK builds, continue adding in kernel headers to everything like we used to
1702 imported_includes += $(call intermediates-dir-for,HEADER_LIBRARIES,device_kernel_headers,$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
1703endif
1704
Dan Willemsen18ffd582019-07-31 10:31:20 -07001705imported_includes := $(strip \
Dan Willemsene6bd1d22020-04-30 21:18:58 -07001706 $(imported_includes) \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001707 $(foreach l, $(installed_shared_library_module_names), \
1708 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
1709 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
1710 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
1711 $(foreach l, $(my_header_libraries), \
1712 $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
1713
1714$(foreach dep,$(imported_includes),\
1715 $(eval EXPORTS.$$(dep).USERS := $$(EXPORTS.$$(dep).USERS) $$(all_objects)))
1716
Dan Willemsene24da822019-01-10 13:10:17 -08001717###########################################################
1718## Define PRIVATE_ variables used by multiple module types
1719###########################################################
1720$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
1721 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
1722
1723ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
1724 LOCAL_NO_STATIC_ANALYZER := true
1725endif
1726
1727ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
1728 my_syntax_arch := host
1729else
1730 my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
1731endif
1732
1733ifeq ($(strip $(my_cc)),)
1734 my_cc := $(my_cc_wrapper) $(CLANG)
1735endif
1736
1737SYNTAX_TOOLS_PREFIX := \
1738 $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/libexec
1739
1740ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
1741 my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \
1742 $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer
1743endif
1744
1745$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
1746
1747ifeq ($(strip $(my_cxx)),)
1748 my_cxx := $(my_cxx_wrapper) $(CLANG_CXX)
1749endif
1750
Ramy Medhate5839f92019-08-06 15:54:48 -04001751ifeq ($(strip $(my_cxx_link)),)
1752 my_cxx_link := $(CLANG_CXX)
1753endif
1754
Dan Willemsene24da822019-01-10 13:10:17 -08001755ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
1756 my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
1757 $(SYNTAX_TOOLS_PREFIX)/c++-analyzer
Ramy Medhate5839f92019-08-06 15:54:48 -04001758 my_cxx_link := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
1759 $(SYNTAX_TOOLS_PREFIX)/c++-analyzer
Dan Willemsene24da822019-01-10 13:10:17 -08001760endif
1761
1762$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
1763$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Ramy Medhate5839f92019-08-06 15:54:48 -04001764$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX_LINK := $(my_cxx_link)
Dan Willemsene24da822019-01-10 13:10:17 -08001765
The Android Open Source Project88b60792009-03-03 19:28:42 -08001766$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001767$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Stephen Hines15680292014-11-26 00:53:46 -08001768$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001769$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
1770$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Dan Albertd1600412015-06-10 16:33:43 -07001771$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
1772$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001773$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001774$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001775$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Dan Willemsen18ffd582019-07-31 10:31:20 -07001776$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORTED_INCLUDES := $(imported_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001777$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001778$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001779$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
1780$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
Evgenii Stepanove1b96f32017-01-23 16:57:38 -08001781$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001782
1783# this is really the way to get the files onto the command line instead
1784# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1785$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1786$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1787$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
Ying Wang4aaa1a12016-03-22 18:23:13 -07001788$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001789
1790###########################################################
1791# Define library dependencies.
1792###########################################################
1793# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1794all_libraries := \
Ying Wangc01f2dc2015-12-15 10:00:19 -08001795 $(built_shared_library_deps) \
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +09001796 $(my_system_shared_libraries_fullpath) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001797 $(built_static_libraries) \
1798 $(built_whole_libraries)
1799
Ying Wang5f074802011-11-08 09:31:21 -08001800###########################################################
1801# Export includes
1802###########################################################
Dan Willemsen18ffd582019-07-31 10:31:20 -07001803
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001804# Headers exported by whole static libraries are also exported by this library.
Dan Willemsena7808ac2016-03-04 12:40:25 -08001805export_include_deps := $(strip \
1806 $(foreach l,$(my_whole_static_libraries), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001807 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001808# Re-export requested headers from shared libraries.
1809export_include_deps += $(strip \
1810 $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001811 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001812# Re-export requested headers from static libraries.
1813export_include_deps += $(strip \
1814 $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001815 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Dan Willemsen8dae49c2017-02-15 15:48:11 -08001816# Re-export requested headers from header libraries.
1817export_include_deps += $(strip \
1818 $(foreach l,$(LOCAL_EXPORT_HEADER_LIBRARY_HEADERS), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001819 $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Colin Cross6b9bddd2015-11-30 17:33:26 -08001820
Dan Willemsen18ffd582019-07-31 10:31:20 -07001821ifneq ($(strip $(my_export_c_include_dirs)$(export_include_deps)),)
Dan Willemsenfd1e67b2020-06-08 18:50:14 -07001822 EXPORTS_LIST += $(intermediates)
Dan Willemsenc9a657c2019-11-07 13:53:57 -08001823 EXPORTS.$(intermediates).FLAGS := $(foreach d,$(my_export_c_include_dirs),-I $(call clean-path,$(d)))
Dan Willemsen18ffd582019-07-31 10:31:20 -07001824 EXPORTS.$(intermediates).REEXPORT := $(export_include_deps)
1825 EXPORTS.$(intermediates).DEPS := $(my_export_c_include_deps) $(my_generated_sources) $(LOCAL_EXPORT_C_INCLUDE_DEPS)
1826endif
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001827
Dan Willemsen0be69072016-12-13 18:28:33 -08001828ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs)))
1829my_soong_problems += non_local__export_c_include_dirs
1830endif
1831
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001832SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
1833 $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems)
1834SOONG_CONV.$(LOCAL_MODULE).DEPS := \
1835 $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \
Dan Willemsen0bf506f2017-04-25 15:42:14 -07001836 $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY),\
1837 $(my_static_libraries) \
1838 $(my_whole_static_libraries) \
1839 $(my_shared_libraries) \
1840 $(my_system_shared_libraries))
Colin Cross3277ba32017-12-06 14:37:06 -08001841SOONG_CONV.$(LOCAL_MODULE).TYPE := native
Joe Onorato02fb89a2020-06-27 00:10:23 -07001842SOONG_CONV.$(LOCAL_MODULE).MAKEFILES := \
1843 $(SOONG_CONV.$(LOCAL_MODULE).MAKEFILES) $(LOCAL_MODULE_MAKEFILE)
1844SOONG_CONV.$(LOCAL_MODULE).INSTALLED:= \
1845 $(SOONG_CONV.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE)
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001846SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07001847
1848###########################################################
1849# Coverage packaging.
1850###########################################################
1851ifeq ($(my_native_coverage),true)
Ryan Campbell5a6ea362017-02-28 16:20:23 -08001852my_gcno_objects := \
1853 $(cpp_objects) \
1854 $(gen_cpp_objects) \
1855 $(c_objects) \
1856 $(gen_c_objects) \
1857 $(objc_objects) \
1858 $(objcpp_objects)
1859
1860LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(my_gcno_objects))
1861$(foreach f,$(my_gcno_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno))))
Ryan Campbell81c9d292016-09-12 13:56:50 -07001862endif