blob: 0582920c144288b919236aae825d7c08ed637777 [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)
22 my_system_shared_libraries :=
23 else
24 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
25 endif
26else
27 ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
Dimitry Ivanovcdf39272017-06-26 13:13:44 -070028 my_system_shared_libraries := libc libm libdl
Dan Albertd3d894d2014-11-14 15:28:49 -080029 else
30 my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
Dimitry Ivanovcdf39272017-06-26 13:13:44 -070031 my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries))
Dan Albertd3d894d2014-11-14 15:28:49 -080032 endif
33endif
34
Dan Willemsenfc92fb22016-08-26 13:27:13 -070035my_soong_problems :=
36
Dan Albertd3d894d2014-11-14 15:28:49 -080037# The following LOCAL_ variables will be modified in this file.
38# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
39# we can't modify them in place.
40my_src_files := $(LOCAL_SRC_FILES)
Colin Crossa04abc82015-06-30 12:21:59 -070041my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080042my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
43my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
Dimitry Ivanovcdf39272017-06-26 13:13:44 -070044my_shared_libraries := $(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES))
Dan Willemsen8dae49c2017-02-15 15:48:11 -080045my_header_libraries := $(LOCAL_HEADER_LIBRARIES)
Dan Albertd3d894d2014-11-14 15:28:49 -080046my_cflags := $(LOCAL_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -080047my_conlyflags := $(LOCAL_CONLYFLAGS)
Dan Albertd3d894d2014-11-14 15:28:49 -080048my_cppflags := $(LOCAL_CPPFLAGS)
Dan Willemsen7a5c5d72018-10-07 19:41:21 -070049my_cflags_no_override := $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
50my_cppflags_no_override := $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
Dan Albertd3d894d2014-11-14 15:28:49 -080051my_ldflags := $(LOCAL_LDFLAGS)
52my_ldlibs := $(LOCAL_LDLIBS)
53my_asflags := $(LOCAL_ASFLAGS)
54my_cc := $(LOCAL_CC)
Ying Wangc671a7c2015-07-20 18:40:18 -070055my_cc_wrapper := $(CC_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080056my_cxx := $(LOCAL_CXX)
Ramy Medhate5839f92019-08-06 15:54:48 -040057my_cxx_link := $(LOCAL_CXX)
Jiyong Park425d4892017-08-18 12:22:57 +090058my_cxx_ldlibs :=
Ying Wangc671a7c2015-07-20 18:40:18 -070059my_cxx_wrapper := $(CXX_WRAPPER)
Dan Albertd3d894d2014-11-14 15:28:49 -080060my_c_includes := $(LOCAL_C_INCLUDES)
61my_generated_sources := $(LOCAL_GENERATED_SOURCES)
Dan Willemsen1c6dc5b2016-01-06 14:28:36 -080062my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
Ying Wangfaeb6932015-04-07 11:59:34 -070063my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
Dan Willemsenba6a1642016-09-29 12:08:29 -070064my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
Evgenii Stepanove1b96f32017-01-23 16:57:38 -080065my_arflags :=
Dan Albertd3d894d2014-11-14 15:28:49 -080066
Colin Cross23dcf762019-11-11 16:04:34 -080067# Configure the pool to use for clang rules.
68# If LOCAL_CC or LOCAL_CXX is set don't use goma or RBE.
69my_pool :=
70ifeq (,$(strip $(my_cc))$(strip $(my_cxx)))
71 my_pool := $(GOMA_OR_RBE_POOL)
72endif
73
Ryan Campbella435aa52017-10-20 16:19:42 -070074ifneq (,$(strip $(foreach dir,$(COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
75ifeq (,$(strip $(foreach dir,$(COVERAGE_EXCLUDE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
Ryan Campbell81c9d292016-09-12 13:56:50 -070076 my_native_coverage := true
77else
78 my_native_coverage := false
79endif
Ryan Campbellb55ff742017-02-27 09:09:16 -080080else
81 my_native_coverage := false
82endif
Dan Willemsene24da822019-01-10 13:10:17 -080083ifneq ($(NATIVE_COVERAGE),true)
84 my_native_coverage := false
85endif
Ryan Campbell81c9d292016-09-12 13:56:50 -070086
Ivan Lozanob18979a2019-11-26 10:20:43 -080087# Exclude directories from manual binder interface whitelisting.
88# TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
89ifneq (,$(filter $(addsuffix %,$(ALLOWED_MANUAL_INTERFACE_PATHS)),$(LOCAL_PATH)))
90 my_cflags += -DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES
91endif
92
Colin Crossa82fa122016-10-20 12:38:21 -070093my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
94ifdef SANITIZE_HOST
Dan Albertb58fb4a2014-11-14 17:15:00 -080095ifdef LOCAL_IS_HOST_MODULE
96my_allow_undefined_symbols := true
Colin Crossa82fa122016-10-20 12:38:21 -070097endif
Dan Albertb58fb4a2014-11-14 17:15:00 -080098endif
99
Andrew Hsieh140761af02014-04-25 23:47:10 -0700100my_ndk_sysroot :=
101my_ndk_sysroot_include :=
102my_ndk_sysroot_lib :=
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700103my_api_level := 10000
104
Dan Willemsenffa32582017-03-19 13:22:45 -0700105ifneq ($(LOCAL_SDK_VERSION),)
Ying Wang1a081002010-07-13 14:55:47 -0700106 ifdef LOCAL_IS_HOST_MODULE
Ian Rogers76a6dc32012-10-01 16:36:23 -0700107 $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
Ying Wang1a081002010-07-13 14:55:47 -0700108 endif
Nikola Veljkovicf7385622016-04-06 19:20:02 +0200109
Dan Albert02bf1382016-07-21 10:04:12 -0700110 # Make sure we've built the NDK.
Dan Albert248b8322017-12-14 13:52:04 -0800111 my_additional_dependencies += $(SOONG_OUT_DIR)/ndk_base.timestamp
Dan Albert02bf1382016-07-21 10:04:12 -0700112
Dan Albert02bf1382016-07-21 10:04:12 -0700113 my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800114 ifneq (,$(filter arm64 x86_64,$(my_arch)))
Dan Albert02bf1382016-07-21 10:04:12 -0700115 my_min_sdk_version := 21
116 else
Dan Albert105e4fe2017-08-17 16:24:46 -0700117 my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION)
Dan Albert02bf1382016-07-21 10:04:12 -0700118 endif
119
120 # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map
121 # missing API levels to existing ones where necessary, but we're not doing
122 # that for the generated libraries. Clip the API level to the minimum where
123 # appropriate.
Dan Willemsenffa32582017-03-19 13:22:45 -0700124 my_ndk_api := $(LOCAL_SDK_VERSION)
125 ifneq ($(my_ndk_api),current)
126 my_ndk_api := $(call math_max,$(my_ndk_api),$(my_min_sdk_version))
Dan Albert988107d2016-11-08 15:10:09 -0800127 endif
128
Dan Albert988107d2016-11-08 15:10:09 -0800129 my_ndk_hist_api := $(my_ndk_api)
130 ifeq ($(my_ndk_api),current)
Dan Albert988107d2016-11-08 15:10:09 -0800131 # The last API level supported by the old prebuilt NDKs.
132 my_ndk_hist_api := 24
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700133 else
134 my_api_level := $(my_ndk_api)
Dan Albert988107d2016-11-08 15:10:09 -0800135 endif
136
Dan Albert02bf1382016-07-21 10:04:12 -0700137 my_ndk_source_root := \
138 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources
139 my_ndk_sysroot := \
Dan Albert988107d2016-11-08 15:10:09 -0800140 $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_hist_api)/arch-$(my_arch)
Dan Albert02bf1382016-07-21 10:04:12 -0700141 my_built_ndk := $(SOONG_OUT_DIR)/ndk
142 my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE)
143 my_ndk_sysroot_include := \
144 $(my_built_ndk)/sysroot/usr/include \
145 $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \
146 $(my_ndk_sysroot)/usr/include \
Dan Albert445bc2f2015-12-11 12:49:18 -0800147
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800148 # x86_64 is a multilib toolchain, so their libraries are
Dan Albert445bc2f2015-12-11 12:49:18 -0800149 # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib
150 # compiler, so its libraries are in /usr/lib.
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800151 ifneq (,$(filter x86_64,$(my_arch)))
Dan Albert02bf1382016-07-21 10:04:12 -0700152 my_ndk_libdir_name := lib64
Andrew Hsieh140761af02014-04-25 23:47:10 -0700153 else
Dan Albert02bf1382016-07-21 10:04:12 -0700154 my_ndk_libdir_name := lib
Andrew Hsieh140761af02014-04-25 23:47:10 -0700155 endif
Ying Wangcce4c972011-03-03 18:53:53 -0800156
Dan Albert02bf1382016-07-21 10:04:12 -0700157 my_ndk_platform_dir := \
158 $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch)
159 my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name)
160 my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name)
161
Dan Willemsenffa32582017-03-19 13:22:45 -0700162 # The bionic linker now has support for packed relocations and gnu style
163 # hashes (which are much faster!), but shipping to older devices requires
164 # the old style hash. Fortunately, we can build with both and it'll work
165 # anywhere.
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800166 my_ldflags += -Wl,--hash-style=both
Dan Albertd3d894d2014-11-14 15:28:49 -0800167
Dan Willemsenffa32582017-03-19 13:22:45 -0700168 # We don't want to expose the relocation packer to the NDK just yet.
169 LOCAL_PACK_MODULE_RELOCATIONS := false
170
Ying Wangcce4c972011-03-03 18:53:53 -0800171 # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
172 # See ndk/docs/CPLUSPLUS-SUPPORT.html
173 my_ndk_stl_include_path :=
174 my_ndk_stl_shared_lib_fullpath :=
Ying Wangcce4c972011-03-03 18:53:53 -0800175 my_ndk_stl_static_lib :=
Duane Sand1a074872014-11-08 15:25:18 -0800176 my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
Andrew Hsieh73d800e2014-03-04 17:11:52 +0800177 LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800178 ifeq (,$(LOCAL_NDK_STL_VARIANT))
Dan Albert37099682017-12-15 20:01:03 +0000179 LOCAL_NDK_STL_VARIANT := system
Ying Wangcce4c972011-03-03 18:53:53 -0800180 endif
Dan Albert19fbd1c2018-01-04 13:34:21 -0800181 ifneq (1,$(words $(filter none system c++_static c++_shared, $(LOCAL_NDK_STL_VARIANT))))
Ying Wang848020f2012-08-14 10:13:16 -0700182 $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
Ying Wangcce4c972011-03-03 18:53:53 -0800183 endif
Dan Albert19fbd1c2018-01-04 13:34:21 -0800184
Ying Wangcce4c972011-03-03 18:53:53 -0800185 ifeq (system,$(LOCAL_NDK_STL_VARIANT))
186 my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
Dan Albert0e2e71d2015-12-09 14:46:13 -0800187 my_system_shared_libraries += libstdc++
Dan Albert19fbd1c2018-01-04 13:34:21 -0800188 else ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800189 my_ndk_stl_include_path := \
190 $(my_ndk_source_root)/cxx-stl/llvm-libc++/include
191 my_ndk_stl_include_path += \
192 $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/include
Dan Albert09607702016-08-08 17:14:59 -0700193
194 my_libcxx_libdir := \
195 $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)
196
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800197 ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
198 my_ndk_stl_static_lib := \
199 $(my_libcxx_libdir)/libc++_static.a \
200 $(my_libcxx_libdir)/libc++abi.a
Dan Albert09607702016-08-08 17:14:59 -0700201 else
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800202 my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
203 endif
Dan Albert09607702016-08-08 17:14:59 -0700204
Dan Alberte6d958a2018-11-15 11:33:21 -0800205 ifneq ($(my_ndk_api),current)
206 ifeq ($(call math_lt,$(my_ndk_api),21),true)
207 my_ndk_stl_include_path += $(my_ndk_source_root)/android/support/include
208 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libandroid_support.a
209 endif
210 endif
211
Dan Albert3d1d1ea2017-12-15 15:25:06 -0800212 ifneq (,$(filter armeabi armeabi-v7a,$(my_cpu_variant)))
213 my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a
Dan Albert658d1e02016-03-22 17:17:40 -0700214 endif
215
Dan Albert2936a1e2016-09-14 16:08:04 -0700216 my_ldlibs += -ldl
Dan Albert0e2e71d2015-12-09 14:46:13 -0800217 else # LOCAL_NDK_STL_VARIANT must be none
218 # Do nothing.
219 endif
Pirama Arumuga Nainar9305e202018-12-20 13:47:44 -0800220
221 # Clang's coverage/profile runtime needs symbols like 'stderr' that were not
222 # exported from libc prior to API level 23
223 ifneq ($(my_ndk_api),current)
224 ifeq ($(call math_lt, $(my_ndk_api),23),true)
225 my_native_coverage := false
226 endif
227 endif
Dan Willemsenffa32582017-03-19 13:22:45 -0700228endif
229
Pirama Arumuga Nainarb8f898e2019-07-02 23:49:19 -0700230ifeq ($(NATIVE_COVERAGE),true)
231 ifndef LOCAL_IS_HOST_MODULE
232 my_ldflags += -Wl,--wrap,getenv
233
234 ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
235 ifeq ($(LOCAL_SDK_VERSION),)
236 my_whole_static_libraries += libprofile-extras
237 else
238 my_whole_static_libraries += libprofile-extras_ndk
239 endif
240 endif
241 endif
242endif
243
Dan Willemsenffa32582017-03-19 13:22:45 -0700244ifneq ($(LOCAL_USE_VNDK),)
Justin Yun65c680e2018-03-20 07:16:14 +0900245 # Required VNDK version for vendor modules is BOARD_VNDK_VERSION.
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700246 my_api_level := $(BOARD_VNDK_VERSION)
247 ifeq ($(my_api_level),current)
Justin Yun65c680e2018-03-20 07:16:14 +0900248 # Build with current PLATFORM_VNDK_VERSION.
249 # If PLATFORM_VNDK_VERSION has a CODENAME, it will return
250 # __ANDROID_API_FUTURE__.
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700251 my_api_level := $(call codename-or-sdk-to-sdk,$(PLATFORM_VNDK_VERSION))
Inseob Kimf0cec692019-12-03 15:09:44 +0900252 else
253 # Build with current BOARD_VNDK_VERSION.
254 my_api_level := $(call codename-or-sdk-to-sdk,$(BOARD_VNDK_VERSION))
Justin Yun65c680e2018-03-20 07:16:14 +0900255 endif
Peter Collingbournee3606ae2019-07-25 17:43:04 -0700256 my_cflags += -D__ANDROID_VNDK__
Dan Albertc1ca1902016-08-04 14:14:50 -0700257endif
Dan Albert02bf1382016-07-21 10:04:12 -0700258
Dan Albertc1ca1902016-08-04 14:14:50 -0700259ifndef LOCAL_IS_HOST_MODULE
260# For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We
261# no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're
262# linking my_shared_libraries by full path now.
263my_allowed_ldlibs :=
264
265# Sort ldlibs and ldflags between -l and other linker flags
266# We'll do this again later, since there are still changes happening, but that's fine.
267my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
268my_ldlibs := $(filter -l%,$(my_ldlib_flags))
269my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
270my_ldlib_flags :=
271
272# Move other ldlibs back to shared libraries
273my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs)))
274my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
Colin Cross0bd335f2017-09-08 14:41:22 -0700275else # LOCAL_IS_HOST_MODULE
Dan Willemsena3a06fe2017-09-26 20:26:11 -0700276 # Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of
Colin Cross0bd335f2017-09-08 14:41:22 -0700277 # device builds
Dan Willemsenf2646902019-01-25 16:54:37 -0800278 my_ldlibs += -ldl -lpthread -lm
279 ifneq ($(HOST_OS),darwin)
280 my_ldlibs += -lrt
Colin Cross0bd335f2017-09-08 14:41:22 -0700281 endif
Dan Albertc1ca1902016-08-04 14:14:50 -0700282endif
283
Dan Willemsenffa32582017-03-19 13:22:45 -0700284ifneq ($(LOCAL_SDK_VERSION),)
Dan Albertc1ca1902016-08-04 14:14:50 -0700285 my_all_ndk_libraries := \
286 $(NDK_MIGRATED_LIBS) $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES))
287 my_ndk_shared_libraries := \
288 $(filter $(my_all_ndk_libraries),\
289 $(my_shared_libraries) $(my_system_shared_libraries))
290
291 my_shared_libraries := \
292 $(filter-out $(my_all_ndk_libraries),$(my_shared_libraries))
Dan Albert02bf1382016-07-21 10:04:12 -0700293 my_system_shared_libraries := \
Dan Albertc1ca1902016-08-04 14:14:50 -0700294 $(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries))
Ying Wang1a081002010-07-13 14:55:47 -0700295endif
296
Dan Albert95994de2014-08-07 18:29:11 -0700297# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
298# all code is position independent, and then those warnings get promoted to
299# errors.
Alexey Polyudovcbb038c2016-08-01 17:36:39 -0700300ifneq ($(LOCAL_NO_PIC),true)
Dan Willemsenf2646902019-01-25 16:54:37 -0800301 ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
302 my_cflags += -fPIE
303 ifndef BUILD_HOST_static
304 ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
305 my_ldflags += -pie
Colin Crossfeb4a7e2018-09-19 14:45:52 -0700306 endif
Colin Crossfeb4a7e2018-09-19 14:45:52 -0700307 endif
Dan Willemsenf2646902019-01-25 16:54:37 -0800308 else
309 my_cflags += -fPIC
Colin Crossfeb4a7e2018-09-19 14:45:52 -0700310 endif
Alexey Polyudovcbb038c2016-08-01 17:36:39 -0700311endif
Dan Albert4803ce22014-08-06 12:36:46 -0700312
Dan Willemsen7a549852015-08-13 17:51:40 -0700313ifdef LOCAL_IS_HOST_MODULE
Dan Willemsen85ac8d22015-08-18 17:47:06 -0700314my_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 -0700315my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS))
316my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS))
Dan Willemsen8dae49c2017-02-15 15:48:11 -0800317my_header_libraries += $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)OS))
Dan Willemsen7a549852015-08-13 17:51:40 -0700318my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS))
319my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS))
320my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS))
321my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS))
322my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS))
323my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS))
324my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS))
325endif
326
Ying Wang6feb6d52014-04-17 10:03:35 -0700327my_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 -0700328my_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 -0700329my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
330my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
331my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
332my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
333my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
334my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
335my_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 -0800336
Dan Willemsenc29172c2015-12-03 22:58:39 -0800337my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude))
338ifneq ($(my_missing_exclude_files),)
339$(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES)
340$(error $(my_missing_exclude_files))
341endif
Colin Crossa04abc82015-06-30 12:21:59 -0700342my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files))
343
Dan Willemsenc57894c2016-10-28 16:30:48 -0700344# Strip '/' from the beginning of each src file. This helps the ../ detection in case
345# the source file is in the form of /../file
346my_src_files := $(patsubst /%,%,$(my_src_files))
347
Dan Albertdb905e72014-08-18 11:14:38 -0700348my_clang := $(strip $(LOCAL_CLANG))
Ying Wang824344a2014-05-27 13:03:36 -0700349ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
Dan Albertdb905e72014-08-18 11:14:38 -0700350my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
Ying Wang824344a2014-05-27 13:03:36 -0700351endif
352ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
Dan Albertdb905e72014-08-18 11:14:38 -0700353my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
Ying Wang824344a2014-05-27 13:03:36 -0700354endif
Chih-Hung Hsiehd9cd1fa2016-08-02 14:22:06 -0700355ifeq ($(my_clang),false)
Dan Willemsenf0638392018-09-04 22:25:22 -0700356 $(call pretty-error,LOCAL_CLANG false is no longer supported)
Dan Willemsen77288172015-09-09 15:45:21 -0700357endif
358
Dan Albert76bfcd42017-02-03 16:16:11 -0800359ifeq ($(LOCAL_C_STD),)
360 my_c_std_version := $(DEFAULT_C_STD_VERSION)
361else ifeq ($(LOCAL_C_STD),experimental)
362 my_c_std_version := $(EXPERIMENTAL_C_STD_VERSION)
363else
364 my_c_std_version := $(LOCAL_C_STD)
365endif
366
367ifeq ($(LOCAL_CPP_STD),)
368 my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION)
369else ifeq ($(LOCAL_CPP_STD),experimental)
370 my_cpp_std_version := $(EXPERIMENTAL_CPP_STD_VERSION)
371else
372 my_cpp_std_version := $(LOCAL_CPP_STD)
373endif
Dan Albertda637392015-10-26 11:09:24 -0700374
Colin Crosse56e3562016-10-17 15:34:29 -0700375my_c_std_conlyflags :=
376my_cpp_std_cppflags :=
377ifneq (,$(my_c_std_version))
378 my_c_std_conlyflags := -std=$(my_c_std_version)
379endif
Dan Albertc7d307d2015-07-29 15:13:57 -0700380
Colin Crosse56e3562016-10-17 15:34:29 -0700381ifneq (,$(my_cpp_std_version))
382 my_cpp_std_cppflags := -std=$(my_cpp_std_version)
383endif
Tim Murray06659bc2014-08-13 11:53:07 -0700384
Yi Kong42e18962018-06-06 16:42:22 -0700385# Extra cflags for projects under external/ directory
Yi Kong0047dbe2018-06-12 15:28:26 -0700386ifneq ($(filter external/%,$(LOCAL_PATH)),)
Yi Kong42e18962018-06-06 16:42:22 -0700387 my_cflags += $(CLANG_EXTERNAL_CFLAGS)
388endif
Yi Kong42e18962018-06-06 16:42:22 -0700389
Colin Crossf4f2fbe2014-02-12 21:15:12 -0800390# arch-specific static libraries go first so that generic ones can depend on them
Ying Wang6feb6d52014-04-17 10:03:35 -0700391my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
392my_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 -0800393my_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 -0800394
Ying Wang75e8fcb2014-10-07 13:03:29 -0700395include $(BUILD_SYSTEM)/cxx_stl_setup.mk
Ying Wangd90de322014-05-23 16:42:37 -0700396
Nicolas Geoffrayb7c9f322015-09-25 13:54:09 +0100397ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),)
398 my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)
399else
Alexey Polyudovccdc3112016-08-01 17:41:49 -0700400 my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER)
Nicolas Geoffrayb7c9f322015-09-25 13:54:09 +0100401endif
Evgenii Stepanov8f5e67a2015-07-10 18:06:51 -0700402
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700403include $(BUILD_SYSTEM)/config_sanitizers.mk
Evgeniy Stepanov6cc9c062012-03-30 12:15:12 +0400404
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700405ifneq ($(filter ../%,$(my_src_files)),)
406my_soong_problems += dotdot_srcs
407endif
408ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),)
409my_soong_problems += dotdot_incs
410endif
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700411
Jing Yu2dcc8062009-09-21 16:31:50 -0700412####################################################
413## Add FDO flags if FDO is turned on and supported
Dehao Chen295a6d22014-09-19 10:18:12 -0700414## Please note that we will do option filtering during FDO build.
415## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
416##################################################################
Ying Wang45d01432014-10-28 14:50:59 -0700417my_fdo_build :=
418ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
419 ifeq ($(BUILD_FDO_INSTRUMENT),true)
420 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
421 my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
422 my_fdo_build := true
423 else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
424 my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
425 my_fdo_build := true
synergydev4a605762013-08-05 02:44:37 -0700426 endif
Shinichiro Hamaji09295a82015-09-24 17:51:20 +0900427 # Disable ccache (or other compiler wrapper) except gomacc, which
428 # can handle -fprofile-use properly.
Colin Cross23dcf762019-11-11 16:04:34 -0800429 my_cc_wrapper := $(filter $(GOMA_CC) $(RBE_WRAPPER),$(my_cc_wrapper))
430 my_cxx_wrapper := $(filter $(GOMA_CC) $(RBE_WRAPPER),$(my_cxx_wrapper))
Jing Yu2dcc8062009-09-21 16:31:50 -0700431endif
432
The Android Open Source Project88b60792009-03-03 19:28:42 -0800433###########################################################
Jim Huang20d1ba62010-10-14 16:15:56 +0800434## Explicitly declare assembly-only __ASSEMBLY__ macro for
435## assembly source
436###########################################################
Ying Wang6ef65192014-01-15 16:02:16 -0800437my_asflags += -D__ASSEMBLY__
Jim Huang20d1ba62010-10-14 16:15:56 +0800438
Dan Willemsenffa32582017-03-19 13:22:45 -0700439###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800440# TODO: support a mix of standard extensions so that this isn't necessary
441LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
442ifeq ($(LOCAL_CPP_EXTENSION),)
443 LOCAL_CPP_EXTENSION := .cpp
444endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800445
446# Certain modules like libdl have to have symbols resolved at runtime and blow
447# up if --no-undefined is passed to the linker.
448ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
Colin Crossa82fa122016-10-20 12:38:21 -0700449 ifeq ($(my_allow_undefined_symbols),)
450 ifneq ($(HOST_OS),darwin)
451 my_ldflags += -Wl,--no-undefined
452 endif
453 else
454 ifdef LOCAL_IS_HOST_MODULE
455 ifeq ($(HOST_OS),darwin)
456 # darwin defaults to treating undefined symbols as errors
457 my_ldflags += -Wl,-undefined,dynamic_lookup
458 endif
459 endif
460 endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800461endif
462
Ying Wangfcdabd42011-04-25 14:22:41 -0700463ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
464$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
465else
466$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
467endif
468
The Android Open Source Project88b60792009-03-03 19:28:42 -0800469###########################################################
470## Define arm-vs-thumb-mode flags.
471###########################################################
472LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
Ying Wangfaeb6932015-04-07 11:59:34 -0700473ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800474normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
475
Dave Bort95282482009-04-23 18:44:55 -0700476# Read the values from something like TARGET_arm_CFLAGS or
477# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
478# actually used (although they are usually empty).
Ying Wang6ef65192014-01-15 16:02:16 -0800479normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
Evgeniy Stepanovf50f4c52012-04-05 11:44:37 +0400480
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800481else
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800482normal_objects_mode :=
Chih-Wei Huang0d09e582010-07-09 10:07:52 +0800483normal_objects_cflags :=
484endif
The Android Open Source Project88b60792009-03-03 19:28:42 -0800485
486###########################################################
487## Define per-module debugging flags. Users can turn on
488## debugging for a particular module by setting DEBUG_MODULE_ModuleName
489## to a non-empty value in their environment or buildspec.mk,
490## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
491## debug flags that they want to use.
492###########################################################
493ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
494 debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
495else
496 debug_cflags :=
497endif
498
Tim Murraya7aa8002012-10-29 16:06:00 -0700499####################################################
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800500## Keep track of src -> obj mapping
501####################################################
502
503my_tracked_gen_files :=
504my_tracked_src_files :=
505
506###########################################################
507## Stuff source generated from one-off tools
508###########################################################
509$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
510
511my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
512
Dan Willemsen7f016152016-02-29 17:52:39 -0800513$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/%
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800514 @echo "Copy: $@"
515 $(copy-file-to-target)
516
517my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
518
519# Generated sources that will actually produce object files.
520# Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES,
521# since other compiled sources may depend on them, and we set up
522# the dependencies.
Dan Willemsen444c3232016-02-04 14:18:48 -0800523my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800524
525ALL_GENERATED_SOURCES += $(my_generated_sources)
526
527####################################################
Tim Murraya7aa8002012-10-29 16:06:00 -0700528## Compile RenderScript with reflected C++
529####################################################
530
Jeff Vander Stoepc44aa3b2019-07-12 08:33:31 -0700531renderscript_sources := $(filter %.rscript %.fs,$(my_src_files))
Tim Murraya7aa8002012-10-29 16:06:00 -0700532
533ifneq (,$(renderscript_sources))
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700534my_soong_problems += rs
Tim Murraya7aa8002012-10-29 16:06:00 -0700535
536renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
537RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
538renderscript_intermediate := $(intermediates)/renderscript
539
Noah Presler4796a8c2015-08-13 17:04:10 -0700540renderscript_target_api :=
541
542ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
543renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
544else
545ifneq (,$(LOCAL_SDK_VERSION))
546# Set target-api for LOCAL_SDK_VERSIONs other than current.
Michael Wright0fb087f2015-11-06 15:20:51 +0000547ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900548renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
Noah Presler4796a8c2015-08-13 17:04:10 -0700549endif
550endif # LOCAL_SDK_VERSION is set
551endif # LOCAL_RENDERSCRIPT_TARGET_API is set
552
553
Tim Murraya7aa8002012-10-29 16:06:00 -0700554ifeq ($(LOCAL_RENDERSCRIPT_CC),)
555LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
556endif
557
558# Turn on all warnings and warnings as errors for RS compiles.
559# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
560renderscript_flags := -Wall -Werror
561renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
Ying Wangacaada12014-09-10 16:11:41 -0700562# -m32 or -m64
563renderscript_flags += -m$(my_32_64_bit_suffix)
Tim Murrayf0020c62014-09-10 15:11:01 -0700564
Ying Wang6ef65192014-01-15 16:02:16 -0800565renderscript_includes := \
Tim Murraya7aa8002012-10-29 16:06:00 -0700566 $(TOPDIR)external/clang/lib/Headers \
Jean-Luc Brouilleteba44932017-01-08 17:40:21 -0800567 $(TOPDIR)frameworks/rs/script_api/include \
Tim Murraya7aa8002012-10-29 16:06:00 -0700568 $(LOCAL_RENDERSCRIPT_INCLUDES)
569
570ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
Ying Wang6ef65192014-01-15 16:02:16 -0800571renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
Tim Murraya7aa8002012-10-29 16:06:00 -0700572endif
573
Ying Wangb9319562015-04-03 16:15:28 -0700574bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
Jeff Vander Stoepc44aa3b2019-07-12 08:33:31 -0700575 $(patsubst %.fs,%.d, $(patsubst %.rscript,%.d, $(notdir $(renderscript_sources)))))
Ying Wangb9319562015-04-03 16:15:28 -0700576
Ying Wang6ef65192014-01-15 16:02:16 -0800577$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
Tim Murraya7aa8002012-10-29 16:06:00 -0700578$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
579$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
580$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
581$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
Colin Crosse2f541b2018-05-16 09:53:40 -0700582$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(patsubst current,0,$(renderscript_target_api))
Ying Wangb9319562015-04-03 16:15:28 -0700583$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
Tim Murraya7aa8002012-10-29 16:06:00 -0700584$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
585 $(transform-renderscripts-to-cpp-and-bc)
586
Dan Willemsen461d8442016-11-10 18:19:36 -0800587# include the dependency files (.d) generated by llvm-rs-cc.
588$(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp))
Tim Murraya7aa8002012-10-29 16:06:00 -0700589
590LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
591
592rs_generated_cpps := $(addprefix \
Jeff Vander Stoepc44aa3b2019-07-12 08:33:31 -0700593 $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rscript,%.cpp, \
Tim Murraya7aa8002012-10-29 16:06:00 -0700594 $(notdir $(renderscript_sources)))))
595
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800596$(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps))
597
Stephen Hines8ff92522014-06-06 12:51:47 -0700598# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
Tim Murraya7aa8002012-10-29 16:06:00 -0700599$(rs_generated_cpps) : $(RenderScript_file_stamp)
Ying Wang81ab8332014-05-28 16:17:09 -0700600 @echo "Updated RS generated cpp file $@."
Ying Wange25b3982015-02-26 18:47:21 -0800601 $(hide) touch $@
Tim Murraya7aa8002012-10-29 16:06:00 -0700602
Ying Wang6ef65192014-01-15 16:02:16 -0800603my_c_includes += $(renderscript_intermediate)
604my_generated_sources += $(rs_generated_cpps)
Tim Murraya7aa8002012-10-29 16:06:00 -0700605
606endif
607
608
The Android Open Source Project88b60792009-03-03 19:28:42 -0800609###########################################################
Ying Wangfaeb6932015-04-07 11:59:34 -0700610## Compile the .proto files to .cc (or .c) and then to .o
Ying Wanga5fc87a2010-11-02 18:43:16 -0700611###########################################################
Joe Onoratobfc78112017-10-07 23:44:05 -0400612ifeq ($(strip $(LOCAL_PROTOC_OPTIMIZE_TYPE)),)
613 LOCAL_PROTOC_OPTIMIZE_TYPE := lite
614endif
Ying Wangb8e01852014-01-23 15:09:04 -0800615proto_sources := $(filter %.proto,$(my_src_files))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700616ifneq ($(proto_sources),)
Ying Wang05f9f352016-05-05 20:02:08 -0700617proto_gen_dir := $(generated_sources_dir)/proto
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900618proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
Ying Wangfaeb6932015-04-07 11:59:34 -0700619
Ying Wang05f9f352016-05-05 20:02:08 -0700620my_rename_cpp_ext :=
Yu Shan655f17c2019-01-25 17:11:02 -0800621ifneq (,$(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 -0700622my_proto_source_suffix := .c
623my_proto_c_includes := external/nanopb-c
Ying Wang05f9f352016-05-05 20:02:08 -0700624my_protoc_flags := --nanopb_out=$(proto_gen_dir) \
Yu Shan10be65d2018-08-03 23:48:10 +0000625 --plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-nanopb
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900626my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options)
Ying Wangfaeb6932015-04-07 11:59:34 -0700627else
Ying Wang05f9f352016-05-05 20:02:08 -0700628my_proto_source_suffix := $(LOCAL_CPP_EXTENSION)
629ifneq ($(my_proto_source_suffix),.cc)
630# aprotoc is hardcoded to write out only .cc file.
631# We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc.
632my_rename_cpp_ext := true
633endif
Ying Wangfaeb6932015-04-07 11:59:34 -0700634my_proto_c_includes := external/protobuf/src
635my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
Joe Onoratobfc78112017-10-07 23:44:05 -0400636my_protoc_flags := --cpp_out=$(if $(filter lite lite-static,$(LOCAL_PROTOC_OPTIMIZE_TYPE)),lite:,)$(proto_gen_dir)
Shinichiro Hamajia3184dc2016-04-05 17:34:51 +0900637my_protoc_deps :=
Ying Wangfaeb6932015-04-07 11:59:34 -0700638endif
Ying Wang05f9f352016-05-05 20:02:08 -0700639my_proto_c_includes += $(proto_gen_dir)
Ying Wangfaeb6932015-04-07 11:59:34 -0700640
Ying Wang05f9f352016-05-05 20:02:08 -0700641proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \
Ying Wangfaeb6932015-04-07 11:59:34 -0700642 $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
Ying Wanga5fc87a2010-11-02 18:43:16 -0700643
Ying Wangead89442014-02-25 11:18:40 -0800644# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
Ying Wang05f9f352016-05-05 20:02:08 -0700645ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
646$(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP)
647$(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags)
648$(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext)
649$(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700650 $(transform-proto-to-cc)
651
Ying Wang05f9f352016-05-05 20:02:08 -0700652$(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
Ying Wangfaeb6932015-04-07 11:59:34 -0700653endif
Ying Wang05f9f352016-05-05 20:02:08 -0700654# Ideally we can generate the source directly into $(intermediates).
655# But many Android.mks assume the .pb.hs are in $(generated_sources_dir).
656# As a workaround, we make a copy in the $(intermediates).
657proto_intermediate_dir := $(intermediates)/proto
658proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\
659 $(proto_generated_cpps))
660$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/%
661 @echo "Copy: $@"
662 $(copy-file-to-target)
663 $(hide) cp $(basename $<).h $(basename $@).h
664$(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps))
665
666my_generated_sources += $(proto_intermediate_cpps)
Ying Wanga5fc87a2010-11-02 18:43:16 -0700667
Ying Wangfaeb6932015-04-07 11:59:34 -0700668my_c_includes += $(my_proto_c_includes)
669# Auto-export the generated proto source dir.
670my_export_c_include_dirs += $(my_proto_c_includes)
671
672ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc)
Ying Wang8a0d53e2015-04-08 09:54:34 -0700673 my_static_libraries += libprotobuf-c-nano-enable_malloc
Ying Wangfaeb6932015-04-07 11:59:34 -0700674else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c)
Ying Wang8a0d53e2015-04-08 09:54:34 -0700675 my_static_libraries += libprotobuf-c-nano
Yu Shan655f17c2019-01-25 17:11:02 -0800676else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc-16bit)
677 my_static_libraries += libprotobuf-c-nano-enable_malloc-16bit
678else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-16bit)
679 my_static_libraries += libprotobuf-c-nano-16bit
680else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc-32bit)
681 my_static_libraries += libprotobuf-c-nano-enable_malloc-32bit
682else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-32bit)
683 my_static_libraries += libprotobuf-c-nano-32bit
Ying Wangfaeb6932015-04-07 11:59:34 -0700684else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
Dan Albertc3031c72014-11-11 10:42:17 -0800685 ifdef LOCAL_SDK_VERSION
Dan Alberta187fb52015-09-08 10:47:03 -0700686 my_static_libraries += libprotobuf-cpp-full-ndk
Dan Albertc3031c72014-11-11 10:42:17 -0800687 else
688 my_shared_libraries += libprotobuf-cpp-full
689 endif
Yabin Cui72a11562016-06-07 19:21:12 -0700690else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static)
691 my_static_libraries += libprotobuf-cpp-lite
Ying Wanga5fc87a2010-11-02 18:43:16 -0700692else
Dan Albertc3031c72014-11-11 10:42:17 -0800693 ifdef LOCAL_SDK_VERSION
Dan Alberta187fb52015-09-08 10:47:03 -0700694 my_static_libraries += libprotobuf-cpp-lite-ndk
Dan Albertc3031c72014-11-11 10:42:17 -0800695 else
696 my_shared_libraries += libprotobuf-cpp-lite
697 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -0700698endif
Ying Wangead89442014-02-25 11:18:40 -0800699endif # $(proto_sources) non-empty
Ying Wanga5fc87a2010-11-02 18:43:16 -0700700
Ying Wanga5fc87a2010-11-02 18:43:16 -0700701###########################################################
Christopher Wiley2df75d12015-10-14 17:27:24 -0700702## AIDL: Compile .aidl files to .cpp and .h files
703###########################################################
704aidl_src := $(strip $(filter %.aidl,$(my_src_files)))
705aidl_gen_cpp :=
706ifneq ($(aidl_src),)
707
Christopher Wiley257796c2016-01-19 08:58:35 -0800708# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
Christopher Wiley2df75d12015-10-14 17:27:24 -0700709aidl_gen_cpp_root := $(intermediates)/aidl-generated/src
710aidl_gen_include_root := $(intermediates)/aidl-generated/include
711
Christopher Wiley257796c2016-01-19 08:58:35 -0800712# Multi-architecture builds have distinct intermediates directories.
713# Thus we'll actually generate source for each architecture.
714$(foreach s,$(aidl_src),\
715 $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
Christopher Wiley087f3272016-01-19 09:26:10 -0800716$(foreach cpp,$(aidl_gen_cpp), \
Dan Willemsenfb842812016-11-13 09:42:19 -0800717 $(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp)))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800718$(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp))
Christopher Wiley2df75d12015-10-14 17:27:24 -0700719
Christopher Wiley2df75d12015-10-14 17:27:24 -0700720$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
721$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root)
722$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
723
Christopher Wileyc7e936f2015-11-19 07:06:01 -0800724# Add generated headers to include paths.
Christopher Wiley2df75d12015-10-14 17:27:24 -0700725my_c_includes += $(aidl_gen_include_root)
Christopher Wileyc7e936f2015-11-19 07:06:01 -0800726my_export_c_include_dirs += $(aidl_gen_include_root)
Christopher Wiley2df75d12015-10-14 17:27:24 -0700727# Pick up the generated C++ files later for transformation to .o files.
728my_generated_sources += $(aidl_gen_cpp)
729
730endif # $(aidl_src) non-empty
731
732###########################################################
Keun Soo Yim3d484752016-02-19 11:06:58 -0800733## Compile the .vts files to .cc (or .c) and then to .o
734###########################################################
735
736vts_src := $(strip $(filter %.vts,$(my_src_files)))
737vts_gen_cpp :=
738ifneq ($(vts_src),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700739my_soong_problems += vts
Keun Soo Yim3d484752016-02-19 11:06:58 -0800740
741# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
742vts_gen_cpp_root := $(intermediates)/vts-generated/src
743vts_gen_include_root := $(intermediates)/vts-generated/include
744
745# Multi-architecture builds have distinct intermediates directories.
746# Thus we'll actually generate source for each architecture.
747$(foreach s,$(vts_src),\
748 $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp)))
Keun Soo Yim3d484752016-02-19 11:06:58 -0800749$(call track-src-file-gen,$(vts_src),$(vts_gen_cpp))
750
751$(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
752$(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root)
Keun Soo Yim3c0ffa32016-09-08 18:30:28 -0700753$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) $(addprefix -m,$(LOCAL_VTS_MODE))
Keun Soo Yim3d484752016-02-19 11:06:58 -0800754
755# Add generated headers to include paths.
756my_c_includes += $(vts_gen_include_root)
757my_export_c_include_dirs += $(vts_gen_include_root)
758# Pick up the generated C++ files later for transformation to .o files.
759my_generated_sources += $(vts_gen_cpp)
760
761endif # $(vts_src) non-empty
762
763###########################################################
Ying Wangf0ebe162016-01-11 16:28:45 -0800764## YACC: Compile .y/.yy files to .c/.cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800765###########################################################
766
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000767y_yacc_sources := $(filter %.y,$(my_src_files))
Ying Wangf0ebe162016-01-11 16:28:45 -0800768y_yacc_cs := $(addprefix \
769 $(intermediates)/,$(y_yacc_sources:.y=.c))
770ifneq ($(y_yacc_cs),)
771$(y_yacc_cs): $(intermediates)/%.c: \
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800772 $(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) $(M4) \
Ying Wangf0ebe162016-01-11 16:28:45 -0800773 $(my_additional_dependencies)
774 $(call transform-y-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800775$(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs))
Ying Wangf0ebe162016-01-11 16:28:45 -0800776
777my_generated_sources += $(y_yacc_cs)
778endif
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000779
780yy_yacc_sources := $(filter %.yy,$(my_src_files))
781yy_yacc_cpps := $(addprefix \
782 $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
Ying Wangf0ebe162016-01-11 16:28:45 -0800783ifneq ($(yy_yacc_cpps),)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000784$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800785 $(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) $(M4) \
Ying Wangf0ebe162016-01-11 16:28:45 -0800786 $(my_additional_dependencies)
787 $(call transform-y-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800788$(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps))
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000789
Ying Wangf0ebe162016-01-11 16:28:45 -0800790my_generated_sources += $(yy_yacc_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800791endif
792
793###########################################################
Ying Wangf0ebe162016-01-11 16:28:45 -0800794## LEX: Compile .l/.ll files to .c/.cpp and then to .o.
The Android Open Source Project88b60792009-03-03 19:28:42 -0800795###########################################################
796
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000797l_lex_sources := $(filter %.l,$(my_src_files))
Ying Wangf0ebe162016-01-11 16:28:45 -0800798l_lex_cs := $(addprefix \
799 $(intermediates)/,$(l_lex_sources:.l=.c))
800ifneq ($(l_lex_cs),)
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800801$(l_lex_cs): $(LEX) $(M4)
Ying Wangf0ebe162016-01-11 16:28:45 -0800802$(l_lex_cs): $(intermediates)/%.c: \
803 $(TOPDIR)$(LOCAL_PATH)/%.l
804 $(transform-l-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800805$(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs))
Ying Wangf0ebe162016-01-11 16:28:45 -0800806
807my_generated_sources += $(l_lex_cs)
808endif
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000809
810ll_lex_sources := $(filter %.ll,$(my_src_files))
811ll_lex_cpps := $(addprefix \
812 $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
Ying Wangf0ebe162016-01-11 16:28:45 -0800813ifneq ($(ll_lex_cpps),)
Dan Willemsen38dc09d2020-01-08 22:31:12 -0800814$(ll_lex_cpps): $(LEX) $(M4)
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000815$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
816 $(TOPDIR)$(LOCAL_PATH)/%.ll
Ying Wangf0ebe162016-01-11 16:28:45 -0800817 $(transform-l-to-c-or-cpp)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800818$(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps))
Nicolas Geoffray9484e2e2014-03-03 15:57:06 +0000819
Ying Wangf0ebe162016-01-11 16:28:45 -0800820my_generated_sources += $(ll_lex_cpps)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800821endif
822
823###########################################################
824## C++: Compile .cpp files to .o.
825###########################################################
826
Dan Willemsen46267cb2019-01-25 14:35:58 -0800827ifneq ($(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)),)
828$(call pretty-error,Files ending in $(LOCAL_CPP_EXTENSION).arm are deprecated. See $(CHANGES_URL)#file_arm)
829endif
Ying Wangfb22a422015-03-10 18:03:11 -0700830
831dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
832dotdot_objects :=
833$(foreach s,$(dotdot_sources),\
834 $(eval $(call compile-dotdot-cpp-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -0700835 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -0800836 dotdot_objects,\
837 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800838$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
Ying Wangfb22a422015-03-10 18:03:11 -0700839
840cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
Dan Willemsen46267cb2019-01-25 14:35:58 -0800841cpp_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
842$(call track-src-file-obj,$(cpp_normal_sources),$(cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800843
Dan Willemsen46267cb2019-01-25 14:35:58 -0800844$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
845$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800846
847ifneq ($(strip $(cpp_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800848$(cpp_objects): .KATI_NINJA_POOL := $(my_pool)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800849$(cpp_objects): $(intermediates)/%.o: \
Ying Wangdfbe79b2012-03-22 11:26:22 -0700850 $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000851 $(my_additional_dependencies) $(CLANG_CXX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800852 $(transform-$(PRIVATE_HOST)cpp-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900853$(call include-depfiles-for-objs, $(cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800854endif
855
Dan Willemsen46267cb2019-01-25 14:35:58 -0800856cpp_objects += $(dotdot_objects)
Ying Wangfb22a422015-03-10 18:03:11 -0700857
The Android Open Source Project88b60792009-03-03 19:28:42 -0800858###########################################################
859## C++: Compile generated .cpp files to .o.
860###########################################################
861
Ying Wangec6d6262014-01-16 16:21:03 -0800862gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800863gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800864$(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800865
866ifneq ($(strip $(gen_cpp_objects)),)
867# Compile all generated files as thumb.
Colin Cross23dcf762019-11-11 16:04:34 -0800868$(gen_cpp_objects): .KATI_NINJA_POOL := $(my_pool)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800869$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
870$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400871$(gen_cpp_objects): $(intermediates)/%.o: \
Ying Wang05f9f352016-05-05 20:02:08 -0700872 $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000873 $(my_additional_dependencies) $(CLANG_CXX)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800874 $(transform-$(PRIVATE_HOST)cpp-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900875$(call include-depfiles-for-objs, $(gen_cpp_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800876endif
877
878###########################################################
879## S: Compile generated .S and .s files to .o.
880###########################################################
881
Ying Wangec6d6262014-01-16 16:21:03 -0800882gen_S_sources := $(filter %.S,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800883gen_S_objects := $(gen_S_sources:%.S=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800884$(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800885
886ifneq ($(strip $(gen_S_sources)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800887$(gen_S_objects): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400888$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000889 $(my_additional_dependencies) $(CLANG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800890 $(transform-$(PRIVATE_HOST)s-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900891$(call include-depfiles-for-objs, $(gen_S_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800892endif
893
Ying Wangec6d6262014-01-16 16:21:03 -0800894gen_s_sources := $(filter %.s,$(my_generated_sources))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800895gen_s_objects := $(gen_s_sources:%.s=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800896$(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800897
898ifneq ($(strip $(gen_s_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800899$(gen_s_objects): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +0400900$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000901 $(my_additional_dependencies) $(CLANG)
Dan Willemsen461d8442016-11-10 18:19:36 -0800902 $(transform-$(PRIVATE_HOST)s-to-o)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800903endif
904
905gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
Dan Willemsen45d38c02016-01-15 16:38:46 -0800906$(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800907
908###########################################################
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000909## o: Include generated .o files in output.
910###########################################################
911
Ying Wangec6d6262014-01-16 16:21:03 -0800912gen_o_objects := $(filter %.o,$(my_generated_sources))
Torne (Richard Coles)aace2022013-02-21 14:01:35 +0000913
914###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -0800915## C: Compile .c files to .o.
916###########################################################
917
Dan Willemsen46267cb2019-01-25 14:35:58 -0800918ifneq ($(filter %.c.arm,$(my_src_files)),)
919$(call pretty-error,Files ending in .c.arm are deprecated. See $(CHANGES_URL)#file_arm)
920endif
Ying Wangfb22a422015-03-10 18:03:11 -0700921
922dotdot_sources := $(filter ../%.c, $(my_src_files))
923dotdot_objects :=
924$(foreach s, $(dotdot_sources),\
925 $(eval $(call compile-dotdot-c-file,$(s),\
Ying Wang05f9f352016-05-05 20:02:08 -0700926 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -0800927 dotdot_objects,\
928 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800929$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
Ying Wangfb22a422015-03-10 18:03:11 -0700930
931c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
Dan Willemsen46267cb2019-01-25 14:35:58 -0800932c_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
933$(call track-src-file-obj,$(c_normal_sources),$(c_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800934
Dan Willemsen46267cb2019-01-25 14:35:58 -0800935$(dotdot_objects) $(c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
936$(dotdot_objects) $(c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800937
938ifneq ($(strip $(c_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800939$(c_objects): .KATI_NINJA_POOL := $(my_pool)
Ying Wang05f9f352016-05-05 20:02:08 -0700940$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000941 $(my_additional_dependencies) $(CLANG)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800942 $(transform-$(PRIVATE_HOST)c-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900943$(call include-depfiles-for-objs, $(c_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800944endif
945
Dan Willemsen46267cb2019-01-25 14:35:58 -0800946c_objects += $(dotdot_objects)
Ying Wangfb22a422015-03-10 18:03:11 -0700947
The Android Open Source Project88b60792009-03-03 19:28:42 -0800948###########################################################
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700949## C: Compile generated .c files to .o.
950###########################################################
951
Ying Wangec6d6262014-01-16 16:21:03 -0800952gen_c_sources := $(filter %.c,$(my_generated_sources))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700953gen_c_objects := $(gen_c_sources:%.c=%.o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -0800954$(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700955
956ifneq ($(strip $(gen_c_objects)),)
957# Compile all generated files as thumb.
Colin Cross23dcf762019-11-11 16:04:34 -0800958$(gen_c_objects): .KATI_NINJA_POOL := $(my_pool)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700959$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
960$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
Ying Wang05f9f352016-05-05 20:02:08 -0700961$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000962 $(my_additional_dependencies) $(CLANG)
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700963 $(transform-$(PRIVATE_HOST)c-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900964$(call include-depfiles-for-objs, $(gen_c_objects))
Jack Paleviche7b3e2c2009-05-04 14:32:44 -0700965endif
966
967###########################################################
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200968## ObjC: Compile .m files to .o
969###########################################################
970
Ying Wangb8e01852014-01-23 15:09:04 -0800971objc_sources := $(filter %.m,$(my_src_files))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200972objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
Dan Willemsen62f2e562016-02-01 18:55:23 -0800973$(call track-src-file-obj,$(objc_sources),$(objc_objects))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200974
975ifneq ($(strip $(objc_objects)),)
Dan Willemsenfc92fb22016-08-26 13:27:13 -0700976my_soong_problems += objc
Colin Cross23dcf762019-11-11 16:04:34 -0800977$(objc_objects): .KATI_NINJA_POOL := $(my_pool)
Ying Wang05f9f352016-05-05 20:02:08 -0700978$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000979 $(my_additional_dependencies) $(CLANG)
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200980 $(transform-$(PRIVATE_HOST)m-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900981$(call include-depfiles-for-objs, $(objc_objects))
David 'Digit' Turner5dbb5292009-05-14 16:00:09 +0200982endif
983
984###########################################################
Scott James Remnantdd86e5a2015-09-17 15:40:49 -0700985## ObjC++: Compile .mm files to .o
986###########################################################
987
988objcpp_sources := $(filter %.mm,$(my_src_files))
989objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o))
Dan Willemsen62f2e562016-02-01 18:55:23 -0800990$(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects))
Scott James Remnantdd86e5a2015-09-17 15:40:49 -0700991
992ifneq ($(strip $(objcpp_objects)),)
Colin Cross23dcf762019-11-11 16:04:34 -0800993$(objcpp_objects): .KATI_NINJA_POOL := $(my_pool)
Ying Wang05f9f352016-05-05 20:02:08 -0700994$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +0000995 $(my_additional_dependencies) $(CLANG_CXX)
Scott James Remnantdd86e5a2015-09-17 15:40:49 -0700996 $(transform-$(PRIVATE_HOST)mm-to-o)
Shinichiro Hamaji4037c422016-03-03 18:12:52 +0900997$(call include-depfiles-for-objs, $(objcpp_objects))
Scott James Remnantdd86e5a2015-09-17 15:40:49 -0700998endif
999
1000###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001001## AS: Compile .S files to .o.
1002###########################################################
1003
Ying Wangb8e01852014-01-23 15:09:04 -08001004asm_sources_S := $(filter %.S,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -07001005dotdot_sources := $(filter ../%,$(asm_sources_S))
1006asm_sources_S := $(filter-out ../%,$(asm_sources_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001007asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001008$(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001009
Ying Wangfb22a422015-03-10 18:03:11 -07001010dotdot_objects_S :=
1011$(foreach s,$(dotdot_sources),\
1012 $(eval $(call compile-dotdot-s-file,$(s),\
1013 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -08001014 dotdot_objects_S,\
1015 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001016$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S))
Ying Wangfb22a422015-03-10 18:03:11 -07001017
The Android Open Source Project88b60792009-03-03 19:28:42 -08001018ifneq ($(strip $(asm_objects_S)),)
Colin Cross23dcf762019-11-11 16:04:34 -08001019$(asm_objects_S): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001020$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001021 $(my_additional_dependencies) $(CLANG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001022 $(transform-$(PRIVATE_HOST)s-to-o)
Shinichiro Hamaji72904772016-03-16 06:40:04 +09001023$(call include-depfiles-for-objs, $(asm_objects_S))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001024endif
1025
Ying Wangb8e01852014-01-23 15:09:04 -08001026asm_sources_s := $(filter %.s,$(my_src_files))
Ying Wangfb22a422015-03-10 18:03:11 -07001027dotdot_sources := $(filter ../%,$(asm_sources_s))
1028asm_sources_s := $(filter-out ../%,$(asm_sources_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001029asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001030$(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001031
Ying Wangfb22a422015-03-10 18:03:11 -07001032dotdot_objects_s :=
1033$(foreach s,$(dotdot_sources),\
1034 $(eval $(call compile-dotdot-s-file-no-deps,$(s),\
1035 $(my_additional_dependencies),\
Colin Cross23dcf762019-11-11 16:04:34 -08001036 dotdot_objects_s,\
1037 $(my_pool))))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001038$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s))
Ying Wangfb22a422015-03-10 18:03:11 -07001039
The Android Open Source Project88b60792009-03-03 19:28:42 -08001040ifneq ($(strip $(asm_objects_s)),)
Colin Cross23dcf762019-11-11 16:04:34 -08001041$(asm_objects_s): .KATI_NINJA_POOL := $(my_pool)
Evgeniy Stepanovb71e2df2012-03-20 18:00:16 +04001042$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001043 $(my_additional_dependencies) $(CLANG)
Dan Willemsen461d8442016-11-10 18:19:36 -08001044 $(transform-$(PRIVATE_HOST)s-to-o)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001045endif
1046
Ying Wangfb22a422015-03-10 18:03:11 -07001047asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
Dan Willemsen45d38c02016-01-15 16:38:46 -08001048$(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001049
1050
Ying Wangfe1e5c32015-03-09 18:57:40 -07001051# .asm for x86/x86_64 needs to be compiled with yasm.
Ying Wang7b913ce2014-06-05 19:05:47 -07001052asm_sources_asm := $(filter %.asm,$(my_src_files))
1053ifneq ($(strip $(asm_sources_asm)),)
1054asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
1055$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
Dan Willemsenc5b7c4f2019-06-12 05:59:53 +00001056 $(my_additional_dependencies) $(YASM)
Ying Wang7b913ce2014-06-05 19:05:47 -07001057 $(transform-asm-to-o)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001058$(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm))
Ying Wang7b913ce2014-06-05 19:05:47 -07001059
1060asm_objects += $(asm_objects_asm)
1061endif
Ying Wang7b913ce2014-06-05 19:05:47 -07001062
Vishwath Mohan96a130b2017-11-17 11:19:36 -08001063###################################################################
1064## When compiling a CFI enabled target, use the .cfi variant of any
1065## static dependencies (where they exist).
1066##################################################################
1067define use_soong_cfi_static_libraries
1068 $(foreach l,$(1),$(if $(filter $(l),$(SOONG_CFI_STATIC_LIBRARIES)),\
1069 $(l).cfi,$(l)))
1070endef
1071
1072ifneq ($(filter cfi,$(my_sanitize)),)
1073 my_whole_static_libraries := $(call use_soong_cfi_static_libraries,\
1074 $(my_whole_static_libraries))
1075 my_static_libraries := $(call use_soong_cfi_static_libraries,\
1076 $(my_static_libraries))
1077endif
1078
Evgenii Stepanov8841a7f2018-07-27 11:54:32 -07001079ifneq ($(LOCAL_USE_VNDK),)
1080 my_soong_hwasan_static_libraries := $(SOONG_HWASAN_VENDOR_STATIC_LIBRARIES)
1081else
1082 my_soong_hwasan_static_libraries = $(SOONG_HWASAN_STATIC_LIBRARIES)
1083endif
1084
1085define use_soong_hwasan_static_libraries
1086 $(foreach l,$(1),$(if $(filter $(l),$(my_soong_hwasan_static_libraries)),\
1087 $(l).hwasan,$(l)))
1088endef
1089
1090ifneq ($(filter hwaddress,$(my_sanitize)),)
1091 my_whole_static_libraries := $(call use_soong_hwasan_static_libraries,\
1092 $(my_whole_static_libraries))
1093 my_static_libraries := $(call use_soong_hwasan_static_libraries,\
1094 $(my_static_libraries))
1095endif
1096
Jiyong Parkc8f57d92017-04-18 20:15:14 +09001097###########################################################
1098## When compiling against the VNDK, use LL-NDK libraries
1099###########################################################
1100ifneq ($(LOCAL_USE_VNDK),)
Justin Yun2bfe0a12020-01-20 18:57:01 +09001101 #####################################################
1102 ## Soong modules may be built three times, once for
1103 ## /system, once for /vendor and once for /product.
1104 ## If we're using the VNDK, switch all soong
1105 ## libraries over to the /vendor or /product variant.
1106 #####################################################
1107 ifeq ($(LOCAL_USE_VNDK_PRODUCT),true)
1108 my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
1109 $(if $(SPLIT_PRODUCT.STATIC_LIBRARIES.$(l)),$(l).product,$(l)))
1110 my_static_libraries := $(foreach l,$(my_static_libraries),\
1111 $(if $(SPLIT_PRODUCT.STATIC_LIBRARIES.$(l)),$(l).product,$(l)))
1112 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
1113 $(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
1114 my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
1115 $(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
1116 my_header_libraries := $(foreach l,$(my_header_libraries),\
1117 $(if $(SPLIT_PRODUCT.HEADER_LIBRARIES.$(l)),$(l).product,$(l)))
1118 else
1119 my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
1120 $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
1121 my_static_libraries := $(foreach l,$(my_static_libraries),\
1122 $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
1123 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
1124 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
1125 my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
1126 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
1127 my_header_libraries := $(foreach l,$(my_header_libraries),\
1128 $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l)))
1129 endif
Jiyong Parkc8f57d92017-04-18 20:15:14 +09001130endif
Jeff Davidson680f0712015-01-08 18:25:30 -08001131
Jiyong Parkc3f13562018-03-19 18:12:39 +09001132# Platform can use vendor public libraries. If a required shared lib is one of
1133# the vendor public libraries, the lib is switched to the stub version of the lib.
1134ifeq ($(LOCAL_USE_VNDK),)
Colin Cross8fb525d2018-09-06 16:25:22 -07001135 my_shared_libraries := $(foreach l,$(my_shared_libraries),\
1136 $(if $(filter $(l),$(VENDOR_PUBLIC_LIBRARIES)),$(l).vendorpublic,$(l)))
Jiyong Parkc3f13562018-03-19 18:12:39 +09001137endif
1138
Colin Crosse0c5e442020-04-07 16:50:32 +00001139###########################################################
1140## When compiling against the NDK, use SDK variants of Soong libraries
1141###########################################################
1142
1143ifneq ($(LOCAL_SDK_VERSION),)
1144 my_whole_static_libraries := $(call use_soong_sdk_libraries,$(my_whole_static_libraries))
1145 my_static_libraries := $(call use_soong_sdk_libraries,$(my_static_libraries))
1146 my_shared_libraries := $(call use_soong_sdk_libraries,$(my_shared_libraries))
1147 my_system_shared_libraries := $(call use_soong_sdk_libraries,$(my_system_shared_libraries))
1148 my_header_libraries := $(call use_soong_sdk_libraries,$(my_header_libraries))
1149endif
1150
Jeff Davidson680f0712015-01-08 18:25:30 -08001151##########################################################
1152## Set up installed module dependency
1153## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
1154## they may cusomize their install path with LOCAL_MODULE_PATH
1155##########################################################
1156# Get the list of INSTALLED libraries as module names.
Dan Willemsenffa32582017-03-19 13:22:45 -07001157ifneq ($(LOCAL_SDK_VERSION),)
Jeff Davidson680f0712015-01-08 18:25:30 -08001158 installed_shared_library_module_names := \
1159 $(my_shared_libraries)
1160else
1161 installed_shared_library_module_names := \
1162 $(my_shared_libraries) $(my_system_shared_libraries)
1163endif
1164
1165# The real dependency will be added after all Android.mks are loaded and the install paths
1166# of the shared libraries are determined.
1167ifdef LOCAL_INSTALLED_MODULE
1168ifdef installed_shared_library_module_names
1169$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
Dimitry Ivanovcdf39272017-06-26 13:13:44 -07001170 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
Jeff Davidson680f0712015-01-08 18:25:30 -08001171endif
1172endif
1173
1174
Ying Wang5f074802011-11-08 09:31:21 -08001175####################################################
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001176## Verify that NDK-built libraries only link against
1177## other NDK-built libraries
1178####################################################
1179
Dan Albert975e3032017-12-19 11:26:05 -08001180include $(BUILD_SYSTEM)/allowed_ndk_types.mk
1181
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001182ifdef LOCAL_SDK_VERSION
Dan Albert4297c392017-12-19 11:27:39 -08001183my_link_type := native:ndk:$(my_ndk_stl_family):$(my_ndk_stl_link_type)
Dan Albert975e3032017-12-19 11:26:05 -08001184my_warn_types := $(my_warn_ndk_types)
1185my_allowed_types := $(my_allowed_ndk_types)
Dan Willemsen9d2b3282017-04-07 20:58:43 -07001186else ifdef LOCAL_USE_VNDK
Jiyong Parka3fb1582017-08-16 18:28:12 +09001187 _name := $(patsubst %.vendor,%,$(LOCAL_MODULE))
Justin Yun2bfe0a12020-01-20 18:57:01 +09001188 _name := $(patsubst %.product,%,$(LOCAL_MODULE))
Jiyong Parka3fb1582017-08-16 18:28:12 +09001189 ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),)
1190 ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),)
1191 my_link_type := native:vndk
1192 else
1193 my_link_type := native:vndk_private
1194 endif
1195 my_warn_types :=
1196 my_allowed_types := native:vndk native:vndk_private
Justin Yun2bfe0a12020-01-20 18:57:01 +09001197 else ifeq ($(LOCAL_USE_VNDK_PRODUCT),true)
1198 # Modules installed to /product cannot directly depend on modules marked
1199 # with vendor_available: false
1200 my_link_type := native:product
1201 my_warn_types :=
1202 my_allowed_types := native:product native:vndk native:platform_vndk
Jiyong Parka3fb1582017-08-16 18:28:12 +09001203 else
1204 # Modules installed to /vendor cannot directly depend on modules marked
1205 # with vendor_available: false
1206 my_link_type := native:vendor
1207 my_warn_types :=
Vic Yang51512c52018-11-12 20:16:26 -08001208 my_allowed_types := native:vendor native:vndk native:platform_vndk
Jiyong Parka3fb1582017-08-16 18:28:12 +09001209 endif
Jiyong Parka52b6e92018-09-12 10:03:37 +09001210else ifneq ($(filter $(TARGET_RECOVERY_OUT)/%,$(call get_non_asan_path,$(LOCAL_MODULE_PATH))),)
Jiyong Park5dc34752018-08-28 12:32:45 +09001211my_link_type := native:recovery
1212my_warn_types :=
1213# TODO(b/113303515) remove native:platform and my_allowed_ndk_types
Vic Yang51512c52018-11-12 20:16:26 -08001214my_allowed_types := native:recovery native:platform native:platform_vndk $(my_allowed_ndk_types)
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001215else
Dan Willemsenb47d4e92017-04-08 00:31:31 -07001216my_link_type := native:platform
Dan Albert975e3032017-12-19 11:26:05 -08001217my_warn_types := $(my_warn_ndk_types)
Vic Yang51512c52018-11-12 20:16:26 -08001218my_allowed_types := $(my_allowed_ndk_types) native:platform native:platform_vndk
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001219endif
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001220
Dan Willemsenb47d4e92017-04-08 00:31:31 -07001221my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries))
1222ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
1223my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries))
1224endif
1225
1226my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
1227my_common :=
1228include $(BUILD_SYSTEM)/link_type.mk
Dan Willemsenb097fbe2016-06-07 14:25:14 -07001229
The Android Open Source Project88b60792009-03-03 19:28:42 -08001230###########################################################
1231## Common object handling.
1232###########################################################
1233
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001234my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files))
1235ifneq ($(my_unused_src_files),)
Dan Willemsen9efeb1e2016-06-28 10:22:08 -07001236 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files))
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001237endif
1238
The Android Open Source Project88b60792009-03-03 19:28:42 -08001239# some rules depend on asm_objects being first. If your code depends on
1240# being first, it's reasonable to require it to be assembly
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001241normal_objects := \
Ying Wangdfbe79b2012-03-22 11:26:22 -07001242 $(asm_objects) \
1243 $(cpp_objects) \
1244 $(gen_cpp_objects) \
1245 $(gen_asm_objects) \
1246 $(c_objects) \
1247 $(gen_c_objects) \
1248 $(objc_objects) \
Ying Wang05f9f352016-05-05 20:02:08 -07001249 $(objcpp_objects)
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001250
1251new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f)))
1252new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f)))
1253
1254ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects)))
1255$(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old)
1256$(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects))))
1257$(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects))))
1258endif
1259
1260ifeq ($(BINARY_OBJECTS_ORDER),soong)
1261normal_objects := $(new_order_normal_objects)
1262endif
1263
1264normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001265
1266all_objects := $(normal_objects) $(gen_o_objects)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001267
Dan Willemsen11ee3412019-01-10 13:21:07 -08001268LOCAL_INTERMEDIATE_TARGETS += $(all_objects)
1269
Dan Willemsen3bb168f2016-01-19 20:07:08 -08001270# Cleanup file tracking
1271$(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=))
1272my_tracked_gen_files :=
1273$(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=))
1274my_tracked_src_files :=
1275
Colin Cross2d206702014-02-13 13:41:52 -08001276my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001277
Jiyong Parkb43a52d2017-07-13 15:51:07 +09001278# The platform JNI header is for platform modules only.
1279ifeq ($(LOCAL_SDK_VERSION)$(LOCAL_USE_VNDK),)
Ying Wang6ef65192014-01-15 16:02:16 -08001280 my_c_includes += $(JNI_H_INCLUDE)
Ying Wangbce4b752010-07-22 15:51:56 -07001281endif
1282
Dan Willemsenc9a657c2019-11-07 13:53:57 -08001283my_c_includes := $(foreach inc,$(my_c_includes),$(call clean-path,$(inc)))
1284
Dan Willemsen0cb422f2019-11-25 17:51:18 -08001285my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes)) $(filter ../%,$(my_c_includes)))
Dan Willemsen062e30b2016-05-24 13:06:07 -07001286ifneq ($(my_outside_includes),)
Dan Willemsen0cb422f2019-11-25 17:51:18 -08001287 ifeq ($(BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS),true)
1288 $(call pretty-warning,C_INCLUDES must be under the source or output directories: $(my_outside_includes))
1289 else
1290 $(call pretty-error,C_INCLUDES must be under the source or output directories: $(my_outside_includes))
1291 endif
Dan Willemsen062e30b2016-05-24 13:06:07 -07001292endif
1293
Torne (Richard Coles)a5afbe82013-08-29 15:36:34 +01001294# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
1295# use normal_objects here to avoid creating circular dependencies. This assumes
1296# that custom build rules which generate .o files don't consume other generated
1297# sources as input (or if they do they take care of that dependency themselves).
Ying Wangec6d6262014-01-16 16:21:03 -08001298$(normal_objects) : | $(my_generated_sources)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001299ALL_C_CPP_ETC_OBJECTS += $(all_objects)
1300
The Android Open Source Project88b60792009-03-03 19:28:42 -08001301
1302###########################################################
1303# Standard library handling.
The Android Open Source Project88b60792009-03-03 19:28:42 -08001304###########################################################
The Android Open Source Project88b60792009-03-03 19:28:42 -08001305
1306###########################################################
1307# The list of libraries that this module will link against are in
1308# these variables. Each is a list of bare module names like "libc libm".
1309#
1310# LOCAL_SHARED_LIBRARIES
1311# LOCAL_STATIC_LIBRARIES
1312# LOCAL_WHOLE_STATIC_LIBRARIES
1313#
1314# We need to convert the bare names into the dependencies that
1315# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
1316# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
1317# libraries, so that simply building this module doesn't force
1318# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
1319# should depend on the INSTALLED versions of the libraries so
1320# that they get installed when this module does.
1321###########################################################
1322# NOTE:
1323# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
1324# module without leaving anything out, which is useful for turning
1325# a collection of .a files into a .so file. Linking against a
1326# normal STATIC_LIBRARY will only pull in code/symbols that are
1327# referenced by the module. (see gcc/ld's --whole-archive option)
1328###########################################################
1329
1330# Get the list of BUILT libraries, which are under
1331# various intermediates directories.
1332so_suffix := $($(my_prefix)SHLIB_SUFFIX)
1333a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
1334
Dan Willemsenffa32582017-03-19 13:22:45 -07001335ifneq ($(LOCAL_SDK_VERSION),)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001336built_shared_libraries := \
Dan Willemsen8cf6b652018-09-05 11:01:12 -07001337 $(foreach lib,$(my_shared_libraries), \
1338 $(call intermediates-dir-for, \
1339 SHARED_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(so_suffix))
Ying Wangc01f2dc2015-12-15 10:00:19 -08001340built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001341
Ying Wangd8d37212014-03-21 16:17:04 -07001342# Add the NDK libraries to the built module dependency
Ying Wangcce4c972011-03-03 18:53:53 -08001343my_system_shared_libraries_fullpath := \
1344 $(my_ndk_stl_shared_lib_fullpath) \
Andrew Hsieh140761af02014-04-25 23:47:10 -07001345 $(addprefix $(my_ndk_sysroot_lib)/, \
Ying Wangd8d37212014-03-21 16:17:04 -07001346 $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
Ying Wang1a081002010-07-13 14:55:47 -07001347
Dan Albertc1ca1902016-08-04 14:14:50 -07001348# We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of
1349# whether the libs are generated or prebuilt, so we simply can't split into two
1350# lists and use addprefix.
1351my_ndk_shared_libraries_fullpath := \
1352 $(foreach _lib,$(my_ndk_shared_libraries),\
1353 $(if $(filter $(NDK_MIGRATED_LIBS),$(_lib)),\
1354 $(my_built_ndk_libs)/$(_lib)$(so_suffix),\
1355 $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix)))
Dan Albert02bf1382016-07-21 10:04:12 -07001356
1357built_shared_libraries += \
Dan Albertc1ca1902016-08-04 14:14:50 -07001358 $(my_ndk_shared_libraries_fullpath) \
Dan Albert02bf1382016-07-21 10:04:12 -07001359 $(my_system_shared_libraries_fullpath) \
1360
Dan Willemsenb4416302019-06-12 17:25:23 +00001361built_shared_library_deps += \
1362 $(my_ndk_shared_libraries_fullpath) \
1363 $(my_system_shared_libraries_fullpath) \
1364
Ying Wang1a081002010-07-13 14:55:47 -07001365else
Ying Wang1a081002010-07-13 14:55:47 -07001366built_shared_libraries := \
Dan Willemsen8cf6b652018-09-05 11:01:12 -07001367 $(foreach lib,$(installed_shared_library_module_names), \
1368 $(call intermediates-dir-for, \
1369 SHARED_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(so_suffix))
Ying Wangc01f2dc2015-12-15 10:00:19 -08001370built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +09001371my_system_shared_libraries_fullpath :=
Ying Wang1a081002010-07-13 14:55:47 -07001372endif
1373
The Android Open Source Project88b60792009-03-03 19:28:42 -08001374built_static_libraries := \
Ying Wang6ef65192014-01-15 16:02:16 -08001375 $(foreach lib,$(my_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001376 $(call intermediates-dir-for, \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001377 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 -08001378
Ying Wang848020f2012-08-14 10:13:16 -07001379ifdef LOCAL_SDK_VERSION
Ying Wangcce4c972011-03-03 18:53:53 -08001380built_static_libraries += $(my_ndk_stl_static_lib)
1381endif
1382
The Android Open Source Project88b60792009-03-03 19:28:42 -08001383built_whole_libraries := \
Colin Cross90353fe2014-02-04 14:53:25 -08001384 $(foreach lib,$(my_whole_static_libraries), \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001385 $(call intermediates-dir-for, \
Alexey Polyudovccdc3112016-08-01 17:41:49 -07001386 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 -08001387
The Android Open Source Project88b60792009-03-03 19:28:42 -08001388# We don't care about installed static libraries, since the
1389# libraries have already been linked into the module at that point.
1390# We do, however, care about the NOTICE files for any static
Steve Blockd14d3b42012-03-01 11:34:41 +00001391# libraries that we use. (see notice_files.mk)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001392installed_static_library_notice_file_targets := \
Colin Cross90353fe2014-02-04 14:53:25 -08001393 $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
Jaewoong Junge8cb1952018-11-08 16:53:02 -08001394 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 -08001395
Colin Cross579668b2018-08-14 13:13:47 -07001396$(notice_target): | $(installed_static_library_notice_file_targets)
1397$(LOCAL_INSTALLED_MODULE): | $(notice_target)
1398
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001399# Default is -fno-rtti.
Doug Kwane3c3c6d2011-06-07 10:55:48 -07001400ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
1401LOCAL_RTTI_FLAG := -fno-rtti
1402endif
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001403
The Android Open Source Project88b60792009-03-03 19:28:42 -08001404###########################################################
1405# Rule-specific variable definitions
1406###########################################################
Logan Chiene6f65432013-12-10 19:07:41 +08001407
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001408my_cflags += $(LOCAL_CLANG_CFLAGS)
Stephen Hines15680292014-11-26 00:53:46 -08001409my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
Dan Albertd2fa96d2014-11-28 14:00:12 -08001410my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
Chih-Hung Hsieh9aa69a62014-09-04 17:15:47 -07001411my_asflags += $(LOCAL_CLANG_ASFLAGS)
1412my_ldflags += $(LOCAL_CLANG_LDFLAGS)
Chih-Hung Hsieh619fdb82014-09-26 17:13:48 -07001413my_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 -08001414my_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 -07001415my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
1416my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
1417my_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 -07001418my_cflags := $(call convert-to-clang-flags,$(my_cflags))
1419my_cppflags := $(call convert-to-clang-flags,$(my_cppflags))
1420my_asflags := $(call convert-to-clang-flags,$(my_asflags))
1421my_ldflags := $(call convert-to-clang-flags,$(my_ldflags))
Logan Chiene6f65432013-12-10 19:07:41 +08001422
Ying Wang45d01432014-10-28 14:50:59 -07001423ifeq ($(my_fdo_build), true)
1424 my_cflags := $(patsubst -Os,-O2,$(my_cflags))
1425 fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
1426 my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
Dehao Chen295a6d22014-09-19 10:18:12 -07001427endif
1428
Dan Albertdf3fd1d2015-08-12 14:54:16 -07001429# No one should ever use this flag. On GCC it's mere presence will disable all
1430# warnings, even those that are specified after it (contrary to typical warning
1431# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
1432# warnings that are *always* bugs.
1433my_illegal_flags := -w
1434my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags))
1435my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
1436my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
1437
Dan Albert5ae31dd2016-01-29 16:51:51 -08001438# We can enforce some rules more strictly in the code we own. my_strict
1439# indicates if this is code that we can be stricter with. If we have rules that
1440# we want to apply to *our* code (but maybe can't for vendor/device specific
1441# things), we could extend this to be a ternary value.
1442my_strict := true
1443ifneq ($(filter external/%,$(LOCAL_PATH)),)
1444 my_strict := false
1445endif
1446
1447# Can be used to make some annotations stricter for code we can fix (such as
1448# when we mark functions as deprecated).
1449ifeq ($(my_strict),true)
1450 my_cflags += -DANDROID_STRICT
1451endif
1452
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -08001453# Check if -Werror or -Wno-error is used in C compiler flags.
Colin Cross8fb525d2018-09-06 16:25:22 -07001454# Header libraries do not need cflags.
Colin Cross0d1f54e2019-11-12 15:53:04 -08001455my_all_cflags := $(my_cflags) $(my_cppflags) $(my_cflags_no_override)
Colin Cross8fb525d2018-09-06 16:25:22 -07001456ifneq (HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS))
1457 # Prebuilt modules do not need cflags.
1458 ifeq (,$(LOCAL_PREBUILT_MODULE_FILE))
Colin Cross8fb525d2018-09-06 16:25:22 -07001459 # Issue warning if -Wno-error is used.
1460 ifneq (,$(filter -Wno-error,$(my_all_cflags)))
1461 $(eval MODULES_USING_WNO_ERROR := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
1462 else
1463 # Issue warning if -Werror is not used. Add it.
1464 ifeq (,$(filter -Werror,$(my_all_cflags)))
1465 # Add -Wall -Werror unless the project is in the WARNING_ALLOWED project list.
1466 ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH))))
1467 my_cflags := -Wall -Werror $(my_cflags)
1468 else
1469 $(eval MODULES_ADDED_WALL := $(MODULES_ADDED_WALL) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
1470 my_cflags := -Wall $(my_cflags)
Chih-Hung Hsieh1876acd2017-11-06 10:47:24 -08001471 endif
1472 endif
1473 endif
Chih-Hung Hsiehbab04882016-10-11 15:38:39 -07001474 endif
1475endif
1476
Colin Cross0d1f54e2019-11-12 15:53:04 -08001477ifneq (,$(filter -Weverything,$(my_all_cflags)))
1478 ifeq (,$(ANDROID_TEMPORARILY_ALLOW_WEVERYTHING))
1479 $(call pretty-error, -Weverything is not allowed in Android.mk files.\
1480 Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.)
1481 endif
1482endif
1483
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001484# Disable clang-tidy if it is not found.
1485ifeq ($(PATH_TO_CLANG_TIDY),)
1486 my_tidy_enabled := false
1487else
1488 # If LOCAL_TIDY is not defined, use global WITH_TIDY
1489 my_tidy_enabled := $(LOCAL_TIDY)
1490 ifeq ($(my_tidy_enabled),)
1491 my_tidy_enabled := $(WITH_TIDY)
1492 endif
1493endif
1494
1495# my_tidy_checks is empty if clang-tidy is disabled.
1496my_tidy_checks :=
1497my_tidy_flags :=
1498ifneq (,$(filter 1 true,$(my_tidy_enabled)))
Dan Willemsenf0638392018-09-04 22:25:22 -07001499 tidy_only: $(cpp_objects) $(c_objects) $(gen_c_objects) $(gen_cpp_objects)
1500 # Set up global default checks
1501 my_tidy_checks := $(WITH_TIDY_CHECKS)
1502 ifeq ($(my_tidy_checks),)
1503 my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH))
1504 endif
1505 # Append local clang-tidy checks.
1506 ifneq ($(LOCAL_TIDY_CHECKS),)
1507 my_tidy_checks := $(my_tidy_checks),$(LOCAL_TIDY_CHECKS)
1508 endif
Chih-Hung Hsieh1d9f04f2018-09-21 10:30:31 -07001509 my_tidy_flags := $(strip $(WITH_TIDY_FLAGS) $(LOCAL_TIDY_FLAGS))
Dan Willemsenf0638392018-09-04 22:25:22 -07001510 # If tidy flags are not specified, default to check all header files.
1511 ifeq ($(my_tidy_flags),)
1512 my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH))
1513 endif
1514 # If clang-tidy is not enabled globally, add the -quiet flag.
1515 ifeq (,$(filter 1 true,$(WITH_TIDY)))
1516 my_tidy_flags += -quiet -extra-arg-before=-fno-caret-diagnostics
1517 endif
George Burgess IV5ab07d42017-05-03 18:10:47 -07001518
Dan Willemsenf0638392018-09-04 22:25:22 -07001519 ifneq ($(my_tidy_checks),)
1520 # We might be using the static analyzer through clang-tidy.
1521 # https://bugs.llvm.org/show_bug.cgi?id=32914
1522 my_tidy_flags += -extra-arg-before=-D__clang_analyzer__
George Burgess IV432899a2018-05-14 15:46:43 -07001523
Dan Willemsenf0638392018-09-04 22:25:22 -07001524 # A recent change in clang-tidy (r328258) enabled destructor inlining,
1525 # which appears to cause a number of false positives. Until that's
1526 # resolved, this turns off the effects of r328258.
1527 # https://bugs.llvm.org/show_bug.cgi?id=37459
1528 my_tidy_flags += -extra-arg-before=-Xclang
1529 my_tidy_flags += -extra-arg-before=-analyzer-config
1530 my_tidy_flags += -extra-arg-before=-Xclang
1531 my_tidy_flags += -extra-arg-before=c++-temp-dtor-inlining=false
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001532 endif
1533endif
1534
Chih-Hung Hsiehba646252016-08-16 16:27:30 -07001535my_tidy_checks := $(subst $(space),,$(my_tidy_checks))
1536
Chih-Hung Hsiehbe5dd202018-08-26 20:37:49 -07001537# Add dependency of clang-tidy and clang-tidy.sh
1538ifneq ($(my_tidy_checks),)
George Burgess IV09e5d9b2019-04-04 16:21:53 -07001539 $(cpp_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
1540 $(c_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
1541 $(gen_cpp_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
1542 $(gen_c_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
Chih-Hung Hsiehbe5dd202018-08-26 20:37:49 -07001543endif
1544
Dan Willemsen6731b492016-06-07 16:55:57 -07001545# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
1546my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
1547my_ldlibs := $(filter -l%,$(my_ldlib_flags))
1548my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
1549
1550# One last verification check for ldlibs
Dan Willemsen6731b492016-06-07 16:55:57 -07001551my_allowed_ldlibs :=
Dan Willemsen4dbb3542017-09-26 00:14:01 -07001552ifndef LOCAL_IS_HOST_MODULE
1553 ifneq ($(LOCAL_SDK_VERSION),)
1554 my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES))
1555 endif
1556else
1557 my_allowed_ldlibs := $($(my_prefix)AVAILABLE_LIBRARIES)
Dan Willemsen6731b492016-06-07 16:55:57 -07001558endif
1559
1560my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs))
1561ifneq ($(my_bad_ldlibs),)
1562 $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs))
1563endif
Dan Willemsen6731b492016-06-07 16:55:57 -07001564
Dan Willemsenc9aa6fc2016-09-13 10:44:44 -07001565# my_cxx_ldlibs may contain linker flags need to wrap certain libraries
1566# (start-group/end-group), so append after the check above.
1567my_ldlibs += $(my_cxx_ldlibs)
1568
Dan Willemsene24da822019-01-10 13:10:17 -08001569###########################################################
1570## Define PRIVATE_ variables from global vars
1571###########################################################
1572ifndef LOCAL_IS_HOST_MODULE
1573ifdef LOCAL_USE_VNDK
1574my_target_global_c_includes := \
1575 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES)
1576my_target_global_c_system_includes := \
1577 $(TARGET_OUT_HEADERS) \
1578 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES)
1579else ifdef LOCAL_SDK_VERSION
1580my_target_global_c_includes :=
1581my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
1582else ifdef BOARD_VNDK_VERSION
1583my_target_global_c_includes := $(SRC_HEADERS) \
1584 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
1585 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
1586my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
1587 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
1588 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
1589else
1590my_target_global_c_includes := $(SRC_HEADERS) \
1591 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
1592 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
1593my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) $(TARGET_OUT_HEADERS) \
1594 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
1595 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
1596endif
1597
1598my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
1599my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
1600my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
1601ifeq ($(my_use_clang_lld),true)
1602 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
1603 include $(BUILD_SYSTEM)/pack_dyn_relocs_setup.mk
Pirama Arumuga Nainarbf2af952019-07-30 22:32:20 -07001604 ifeq ($(my_pack_module_relocations),true)
1605 my_target_global_ldflags += -Wl,--pack-dyn-relocs=android+relr -Wl,--use-android-relr-tags
1606 else
Dan Willemsene24da822019-01-10 13:10:17 -08001607 my_target_global_ldflags += -Wl,--pack-dyn-relocs=none
1608 endif
1609else
1610 my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
1611endif # my_use_clang_lld
1612
Peter Collingbournee3606ae2019-07-25 17:43:04 -07001613my_target_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)TRIPLE)
1614ifndef LOCAL_IS_HOST_MODULE
1615 my_target_triple_flag := -target $(my_target_triple)$(my_api_level)
1616else
1617 my_target_triple_flag := -target $(my_target_triple)
1618endif
1619my_asflags += $(my_target_triple_flag)
1620my_cflags += $(my_target_triple_flag)
1621my_ldflags += $(my_target_triple_flag)
1622
Dan Willemsene24da822019-01-10 13:10:17 -08001623$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
1624$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
1625$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
1626$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
1627$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
1628$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
1629
1630else # LOCAL_IS_HOST_MODULE
1631
1632my_host_global_c_includes := $(SRC_HEADERS) \
1633 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
1634my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
1635 $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
1636
1637my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
1638my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
1639my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
1640ifeq ($(my_use_clang_lld),true)
1641 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
1642else
1643 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
1644endif # my_use_clang_lld
1645
1646$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes)
1647$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes)
1648$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
1649$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
1650$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
1651$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
1652endif # LOCAL_IS_HOST_MODULE
1653
1654# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
1655# build with NATIVE_COVERAGE=true in your enviornment.
1656ifeq ($(NATIVE_COVERAGE),true)
1657 ifeq ($(my_native_coverage),true)
1658 # Note that clang coverage doesn't play nicely with acov out of the box.
1659 # Clang apparently generates .gcno files that aren't compatible with
1660 # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov
1661 # with `--gcov-tool /usr/bin/gcov-4.6`.
1662 #
1663 # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
1664 my_cflags += --coverage -O0
1665 my_ldflags += --coverage
1666 endif
1667
1668 my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
1669
1670 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
1671 $(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib)
1672endif
1673
Dan Willemsen18ffd582019-07-31 10:31:20 -07001674####################################################
1675## Import includes
1676####################################################
1677imported_includes := $(strip \
1678 $(if $(LOCAL_USE_VNDK),\
1679 $(call intermediates-dir-for,HEADER_LIBRARIES,device_kernel_headers,$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
1680 $(foreach l, $(installed_shared_library_module_names), \
1681 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
1682 $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
1683 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
1684 $(foreach l, $(my_header_libraries), \
1685 $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
1686
1687$(foreach dep,$(imported_includes),\
1688 $(eval EXPORTS.$$(dep).USERS := $$(EXPORTS.$$(dep).USERS) $$(all_objects)))
1689
Dan Willemsene24da822019-01-10 13:10:17 -08001690###########################################################
1691## Define PRIVATE_ variables used by multiple module types
1692###########################################################
1693$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
1694 $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
1695
1696ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
1697 LOCAL_NO_STATIC_ANALYZER := true
1698endif
1699
1700ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
1701 my_syntax_arch := host
1702else
1703 my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
1704endif
1705
1706ifeq ($(strip $(my_cc)),)
1707 my_cc := $(my_cc_wrapper) $(CLANG)
1708endif
1709
1710SYNTAX_TOOLS_PREFIX := \
1711 $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/libexec
1712
1713ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
1714 my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \
1715 $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer
1716endif
1717
1718$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
1719
1720ifeq ($(strip $(my_cxx)),)
1721 my_cxx := $(my_cxx_wrapper) $(CLANG_CXX)
1722endif
1723
Ramy Medhate5839f92019-08-06 15:54:48 -04001724ifeq ($(strip $(my_cxx_link)),)
1725 my_cxx_link := $(CLANG_CXX)
1726endif
1727
Dan Willemsene24da822019-01-10 13:10:17 -08001728ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
1729 my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
1730 $(SYNTAX_TOOLS_PREFIX)/c++-analyzer
Ramy Medhate5839f92019-08-06 15:54:48 -04001731 my_cxx_link := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
1732 $(SYNTAX_TOOLS_PREFIX)/c++-analyzer
Dan Willemsene24da822019-01-10 13:10:17 -08001733endif
1734
1735$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
1736$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
Ramy Medhate5839f92019-08-06 15:54:48 -04001737$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX_LINK := $(my_cxx_link)
Dan Willemsene24da822019-01-10 13:10:17 -08001738
The Android Open Source Project88b60792009-03-03 19:28:42 -08001739$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
Ying Wang6ef65192014-01-15 16:02:16 -08001740$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
Stephen Hines15680292014-11-26 00:53:46 -08001741$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001742$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
1743$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
Dan Albertd1600412015-06-10 16:33:43 -07001744$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
1745$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
Doug Kwan9a8ecf92011-05-10 21:50:58 -07001746$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001747$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
Ying Wang6ef65192014-01-15 16:02:16 -08001748$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
Dan Willemsen18ffd582019-07-31 10:31:20 -07001749$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORTED_INCLUDES := $(imported_includes)
Ying Wang6ef65192014-01-15 16:02:16 -08001750$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
Dan Albertb05f2ca2014-09-12 14:46:57 -07001751$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
Chih-Hung Hsieha9a55c72016-03-31 16:30:23 -07001752$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
1753$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
Evgenii Stepanove1b96f32017-01-23 16:57:38 -08001754$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001755
1756# this is really the way to get the files onto the command line instead
1757# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
1758$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
1759$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
1760$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
Ying Wang4aaa1a12016-03-22 18:23:13 -07001761$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001762
1763###########################################################
1764# Define library dependencies.
1765###########################################################
1766# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
1767all_libraries := \
Ying Wangc01f2dc2015-12-15 10:00:19 -08001768 $(built_shared_library_deps) \
Shinichiro Hamaji0e7587a2015-10-09 14:36:04 +09001769 $(my_system_shared_libraries_fullpath) \
The Android Open Source Project88b60792009-03-03 19:28:42 -08001770 $(built_static_libraries) \
1771 $(built_whole_libraries)
1772
Ying Wang5f074802011-11-08 09:31:21 -08001773###########################################################
1774# Export includes
1775###########################################################
Dan Willemsen18ffd582019-07-31 10:31:20 -07001776
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001777# Headers exported by whole static libraries are also exported by this library.
Dan Willemsena7808ac2016-03-04 12:40:25 -08001778export_include_deps := $(strip \
1779 $(foreach l,$(my_whole_static_libraries), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001780 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001781# Re-export requested headers from shared libraries.
1782export_include_deps += $(strip \
1783 $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001784 $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Christopher Wileyff1c3f22016-04-11 12:40:36 -07001785# Re-export requested headers from static libraries.
1786export_include_deps += $(strip \
1787 $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001788 $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Dan Willemsen8dae49c2017-02-15 15:48:11 -08001789# Re-export requested headers from header libraries.
1790export_include_deps += $(strip \
1791 $(foreach l,$(LOCAL_EXPORT_HEADER_LIBRARY_HEADERS), \
Dan Willemsen18ffd582019-07-31 10:31:20 -07001792 $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
Colin Cross6b9bddd2015-11-30 17:33:26 -08001793
Dan Willemsen18ffd582019-07-31 10:31:20 -07001794ifneq ($(strip $(my_export_c_include_dirs)$(export_include_deps)),)
1795 EXPORTS_LIST := $(EXPORTS_LIST) $(intermediates)
Dan Willemsenc9a657c2019-11-07 13:53:57 -08001796 EXPORTS.$(intermediates).FLAGS := $(foreach d,$(my_export_c_include_dirs),-I $(call clean-path,$(d)))
Dan Willemsen18ffd582019-07-31 10:31:20 -07001797 EXPORTS.$(intermediates).REEXPORT := $(export_include_deps)
1798 EXPORTS.$(intermediates).DEPS := $(my_export_c_include_deps) $(my_generated_sources) $(LOCAL_EXPORT_C_INCLUDE_DEPS)
1799endif
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001800
Dan Willemsen0be69072016-12-13 18:28:33 -08001801ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs)))
1802my_soong_problems += non_local__export_c_include_dirs
1803endif
1804
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001805SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
1806 $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems)
1807SOONG_CONV.$(LOCAL_MODULE).DEPS := \
1808 $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \
Dan Willemsen0bf506f2017-04-25 15:42:14 -07001809 $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY),\
1810 $(my_static_libraries) \
1811 $(my_whole_static_libraries) \
1812 $(my_shared_libraries) \
1813 $(my_system_shared_libraries))
Colin Cross3277ba32017-12-06 14:37:06 -08001814SOONG_CONV.$(LOCAL_MODULE).TYPE := native
Dan Willemsenfc92fb22016-08-26 13:27:13 -07001815SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
Ryan Campbell81c9d292016-09-12 13:56:50 -07001816
1817###########################################################
1818# Coverage packaging.
1819###########################################################
1820ifeq ($(my_native_coverage),true)
Ryan Campbell5a6ea362017-02-28 16:20:23 -08001821my_gcno_objects := \
1822 $(cpp_objects) \
1823 $(gen_cpp_objects) \
1824 $(c_objects) \
1825 $(gen_c_objects) \
1826 $(objc_objects) \
1827 $(objcpp_objects)
1828
1829LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(my_gcno_objects))
1830$(foreach f,$(my_gcno_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno))))
Ryan Campbell81c9d292016-09-12 13:56:50 -07001831endif