platform_build/core/copy_headers.mk
Dan Willemsen 6f60f020d7 Warn more clearly when there are duplicate copied headers
When more than one makefile tries to copy a header to the same
destination, the warning is not clear, and hard to track down and assign
blame:

build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/bullhead/obj/include/qcom/display/copybit.h'

With this change, the same behavior is kept, but the warning message is
more descriptive, and contains the offending Android.mk files:

build/core/Makefile:54: Duplicate header copy: out/target/product/bullhead/obj/include/qcom/display/copybit.h
build/core/Makefile:54: Defined in: hardware/qcom/display/msm8994/libcopybit/Android.mk hardware/qcom/display/msm8994/libcopybit/Android.mk

In this case, a $(CLEAR_VARS) is missing, so the same Android.mk file is
copying the same headers twice.

Bug: 27302058
Change-Id: Icf8f580ae71a78741db21c1d8f3213424459e637
2016-02-23 13:40:07 -08:00

27 lines
967 B
Makefile

###########################################################
## Copy headers to the install tree
###########################################################
ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
my_prefix := HOST_
else
my_prefix := TARGET_
endif
# Create a rule to copy each header, and make the
# all_copied_headers phony target depend on each
# destination header. copy-one-header defines the
# actual rule.
#
$(foreach header,$(LOCAL_COPY_HEADERS), \
$(eval _chFrom := $(LOCAL_PATH)/$(header)) \
$(eval _chTo := \
$(if $(LOCAL_COPY_HEADERS_TO),\
$($(my_prefix)OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
$($(my_prefix)OUT_HEADERS)/$(notdir $(header)))) \
$(eval ALL_COPIED_HEADERS.$(_chTo).MAKEFILE += $(LOCAL_MODULE_MAKEFILE)) \
$(eval ALL_COPIED_HEADERS.$(_chTo).SRC += $(_chFrom)) \
$(if $(filter $(_chTo),$(ALL_COPIED_HEADERS)),, \
$(eval ALL_COPIED_HEADERS += $(_chTo))) \
)
_chFrom :=
_chTo :=