Merge "Define vendor-hwasan-snapshot target"

This commit is contained in:
Treehugger Robot 2022-12-02 00:20:03 +00:00 committed by Gerrit Code Review
commit f16593490f

View file

@ -27,6 +27,56 @@ vendor-fake-snapshot: $(SOONG_VENDOR_FAKE_SNAPSHOT_ZIP)
$(call dist-for-goals, vendor-fake-snapshot, $(SOONG_VENDOR_FAKE_SNAPSHOT_ZIP):fake/$(notdir $(SOONG_VENDOR_FAKE_SNAPSHOT_ZIP)))
# Capture prebuilt vendor static libraries of hwasan variant.
# To build the hwasan variant `SANITIZE_TARGET=hwaddress` must be set.
# vendor-hwasan-snapshot goal zips hwasan static libs listed in
# PRODUCT_VSDK_HWASAN_STATIC_PATHS which has a list of pairs of
# 'module name':'source directory path'
ifeq ($(SANITIZE_TARGET),hwaddress)
vsdk_hwasan_static_zip := $(PRODUCT_OUT)/vsdk-hwasan-snapshot.zip
vsdk_hwasan_static_dir := $(PRODUCT_OUT)/vsdk-hwasan-snapshot
vsdk_hwasan_variants := \
android \
vendor.$(PLATFORM_VNDK_VERSION) \
$(TARGET_ARCH) \
$(TARGET_ARCH_VARIANT) \
$(TARGET_CPU_VARIANT) \
static \
hwasan
vsdk_hwasan_variant_name := $(subst _generic_,_,$(subst $(space),_,$(vsdk_hwasan_variants)))
define get_vendor_hwasan_static_path
$(SOONG_OUT_DIR)/.intermediates/$(call word-colon,2,$(1))/$(call word-colon,1,$(1))/$(vsdk_hwasan_variant_name)/$(call word-colon,1,$(1)).a
endef
$(vsdk_hwasan_static_zip): PRIVATE_MAKEFILE := $(current_makefile)
$(vsdk_hwasan_static_zip): PRIVATE_HWASAN_DIR := $(vsdk_hwasan_static_dir)
$(vsdk_hwasan_static_zip): $(SOONG_ZIP) $(foreach p, $(PRODUCT_VSDK_HWASAN_STATIC_PATHS), $(call get_vendor_hwasan_static_path,$(p)))
$(if $(PRODUCT_VSDK_HWASAN_STATIC_PATHS),,\
$(call echo-error,$(PRIVATE_MAKEFILE),\
"CANNOT generate Vendor HWASAN snapshot. PRODUCT_VSDK_HWASAN_STATIC_PATHS is not defined.") &&\
exit 1)
@rm -rf $(PRIVATE_HWASAN_DIR)
@mkdir -p $(PRIVATE_HWASAN_DIR)
$(foreach p, $(PRODUCT_VSDK_HWASAN_STATIC_PATHS), \
cp -f $(call get_vendor_hwasan_static_path,$(p)) $(PRIVATE_HWASAN_DIR) &&) true
$(SOONG_ZIP) -o $@ -C $(PRIVATE_HWASAN_DIR) -D $(PRIVATE_HWASAN_DIR)
.PHONY: vendor-hwasan-snapshot
vendor-hwasan-snapshot: $(vsdk_hwasan_static_zip)
$(call dist-for-goals, vendor-hwasan-snapshot, $(vsdk_hwasan_static_zip))
else # Not for the HWASAN build
.PHONY: vendor-hwasan-snapshot
vendor-hwasan-snapshot: PRIVATE_MAKEFILE := $(current_makefile)
vendor-hwasan-snapshot:
$(call echo-error,$(PRIVATE_MAKEFILE),\
"CANNOT generate Vendor HWASAN snapshot. SANITIZE_TARGET must be set to 'hwaddress'.")
exit 1
endif # SANITIZE_TARGET
else # BOARD_VNDK_VERSION is NOT set to 'current'
.PHONY: vendor-snapshot
@ -43,4 +93,10 @@ vendor-fake-snapshot:
"CANNOT generate Vendor snapshot. BOARD_VNDK_VERSION must be set to 'current'.")
exit 1
.PHONY: vendor-hwasan-snapshot
vendor-hwasan-snapshot: PRIVATE_MAKEFILE := $(current_makefile)
$(call echo-error,$(PRIVATE_MAKEFILE),\
"CANNOT generate Vendor HWASAN snapshot. BOARD_VNDK_VERSION must be set to 'current'.")
exit 1
endif # BOARD_VNDK_VERSION