blob: 2e82db739117e7862a97676931ebcccc5600c9df [file] [log] [blame]
Dan Willemsenbab0fa62016-11-18 14:05:39 -08001ifneq (,$(strip $(LOCAL_COPY_HEADERS)))
The Android Open Source Project88b60792009-03-03 19:28:42 -08002###########################################################
3## Copy headers to the install tree
4###########################################################
Dan Willemsen3bf15e72016-07-25 16:03:53 -07005$(call record-module-type,COPY_HEADERS)
The Android Open Source Project88b60792009-03-03 19:28:42 -08006ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
Dan Willemsen13cb1652019-12-26 16:27:36 -08007 $(call pretty-error,LOCAL_COPY_HEADERS may not be used with host modules)
The Android Open Source Project88b60792009-03-03 19:28:42 -08008endif
9
Dan Willemsenbab0fa62016-11-18 14:05:39 -080010# Modules linking against the SDK do not have the include path to use
11# COPY_HEADERS, so prevent them from exporting any either.
12ifdef LOCAL_SDK_VERSION
Dan Willemsen13cb1652019-12-26 16:27:36 -080013 $(call pretty-error,Modules using LOCAL_SDK_VERSION may not use LOCAL_COPY_HEADERS)
Dan Willemsenbab0fa62016-11-18 14:05:39 -080014endif
15
Kiyoung Kim454265c2024-02-05 10:22:04 +090016include $(BUILD_SYSTEM)/local_vendor_product.mk
Dan Willemsenbab0fa62016-11-18 14:05:39 -080017
Kiyoung Kim454265c2024-02-05 10:22:04 +090018# Modules in vendor or product may use LOCAL_COPY_HEADERS.
19# Platform libraries will not have the include path present.
20ifeq ($(call module-in-vendor-or-product),)
21 $(call pretty-error,Only modules in vendor or product may use LOCAL_COPY_HEADERS)
Dan Willemsenbab0fa62016-11-18 14:05:39 -080022endif
Dan Willemsenbab0fa62016-11-18 14:05:39 -080023
Dan Willemsen13cb1652019-12-26 16:27:36 -080024# Clean up LOCAL_COPY_HEADERS_TO, since soong_ui will be comparing cleaned
25# paths to figure out which headers are obsolete and should be removed.
26LOCAL_COPY_HEADERS_TO := $(call clean-path,$(LOCAL_COPY_HEADERS_TO))
27ifneq ($(filter /% .. ../%,$(LOCAL_COPY_HEADERS_TO)),)
28 $(call pretty-error,LOCAL_COPY_HEADERS_TO may not start with / or ../ : $(LOCAL_COPY_HEADERS_TO))
29endif
30ifeq ($(LOCAL_COPY_HEADERS_TO),.)
31 LOCAL_COPY_HEADERS_TO :=
32endif
33
The Android Open Source Project88b60792009-03-03 19:28:42 -080034# Create a rule to copy each header, and make the
35# all_copied_headers phony target depend on each
36# destination header. copy-one-header defines the
37# actual rule.
38#
39$(foreach header,$(LOCAL_COPY_HEADERS), \
40 $(eval _chFrom := $(LOCAL_PATH)/$(header)) \
41 $(eval _chTo := \
Colin Crossa6c4ebd2013-10-22 12:24:21 -070042 $(if $(LOCAL_COPY_HEADERS_TO),\
Dan Willemsen6e51ef62016-11-22 16:17:38 -080043 $(TARGET_OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
44 $(TARGET_OUT_HEADERS)/$(notdir $(header)))) \
Dan Willemsen6f60f022016-02-23 13:40:07 -080045 $(eval ALL_COPIED_HEADERS.$(_chTo).MAKEFILE += $(LOCAL_MODULE_MAKEFILE)) \
46 $(eval ALL_COPIED_HEADERS.$(_chTo).SRC += $(_chFrom)) \
47 $(if $(filter $(_chTo),$(ALL_COPIED_HEADERS)),, \
48 $(eval ALL_COPIED_HEADERS += $(_chTo))) \
The Android Open Source Project88b60792009-03-03 19:28:42 -080049 )
50_chFrom :=
51_chTo :=
Dan Willemsenbab0fa62016-11-18 14:05:39 -080052
Wei Li0762f5f2024-06-17 14:32:45 -070053$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=COPY_HEADERS))
Dan Willemsenbab0fa62016-11-18 14:05:39 -080054endif # LOCAL_COPY_HEADERS