Always check VNDK variant identicalness

Previously, we only check VNDK core and vendor variants are identical
when a VNDK library is not declared to have different variants AND the
target has TARGET_VNDK_USE_CORE_VARIANT set.  Therefore, it is fairly
easily to break a TARGET_VNDK_USE_CORE_VARIANT target as it needs to be
tested explicitly.

This change uses the new LOCAL_CHECK_SAME_VNDK_VARIANTS and expands the
check to run regardless of TARGET_VNDK_USE_CORE_VARIANT.  Also adds
support for VNDK-in-product.

Bug: 145157349
Test: Build success for targets with and without
      TARGET_VNDK_USE_CORE_VARIANT.
Test: With the corresponding change in build/make, remove libbinder
      from build/soong/cc/config/vndk.go and check build fails even
      when TARGET_VNDK_USE_CORE_VARIANT is not set.

Change-Id: Iec708b971072e6580f77a03e243b30b89b3b054d
This commit is contained in:
Vic Yang 2020-01-08 14:39:10 -08:00
parent 2cfd952682
commit 4873e65c8d
3 changed files with 27 additions and 22 deletions

View file

@ -29,6 +29,7 @@ LOCAL_BUILT_MODULE_STEM:=
LOCAL_CC:=
LOCAL_CERTIFICATE:=
LOCAL_CFLAGS:=
LOCAL_CHECK_SAME_VNDK_VARIANTS:=
LOCAL_CHECKED_MODULE:=
LOCAL_C_INCLUDES:=
LOCAL_CLANG:=

View file

@ -104,33 +104,35 @@ ifdef LOCAL_INSTALLED_MODULE
endif
endif
ifeq ($(LOCAL_VNDK_DEPEND_ON_CORE_VARIANT),true)
# Add $(LOCAL_BUILT_MODULE) as a dependency to no_vendor_variant_vndk_check so
# that the vendor variant will be built and checked against the core variant.
no_vendor_variant_vndk_check: $(LOCAL_BUILT_MODULE)
my_check_same_vndk_variants :=
ifeq ($(LOCAL_CHECK_SAME_VNDK_VARIANTS),true)
ifneq ($(filter hwaddress, $(SANITIZE_TARGET)),hwaddress)
my_check_same_vndk_variants := true
endif
endif
my_core_register_name := $(subst .vendor,,$(my_register_name))
ifeq ($(my_check_same_vndk_variants),true)
same_vndk_variants_stamp := $(intermediates)/same_vndk_variants.timestamp
my_core_register_name := $(subst .vendor,,$(subst .product,,$(my_register_name)))
my_core_variant_files := $(call module-target-built-files,$(my_core_register_name))
my_core_shared_lib := $(sort $(filter %.so,$(my_core_variant_files)))
$(LOCAL_BUILT_MODULE): PRIVATE_CORE_VARIANT := $(my_core_shared_lib)
# The built vendor variant library needs to depend on the built core variant
# so that we can perform identity check against the core variant.
$(LOCAL_BUILT_MODULE): $(my_core_shared_lib)
$(same_vndk_variants_stamp): PRIVATE_CORE_VARIANT := $(my_core_shared_lib)
$(same_vndk_variants_stamp): PRIVATE_VENDOR_VARIANT := $(LOCAL_PREBUILT_MODULE_FILE)
$(same_vndk_variants_stamp): PRIVATE_TOOLS_PREFIX := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)TOOLS_PREFIX)
$(same_vndk_variants_stamp): $(my_core_shared_lib) $(LOCAL_PREBUILT_MODULE_FILE)
$(call verify-vndk-libs-identical,\
$(PRIVATE_CORE_VARIANT),\
$(PRIVATE_VENDOR_VARIANT)\
$(PRIVATE_TOOLS_PREFIX))
$(LOCAL_BUILT_MODULE): $(same_vndk_variants_stamp)
endif
ifeq ($(LOCAL_VNDK_DEPEND_ON_CORE_VARIANT),true)
$(LOCAL_BUILT_MODULE): PRIVATE_TOOLS_PREFIX := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)TOOLS_PREFIX)
$(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE) $(LIBRARY_IDENTITY_CHECK_SCRIPT)
$(call verify-vndk-libs-identical,\
$(PRIVATE_CORE_VARIANT),\
$<,\
$(PRIVATE_TOOLS_PREFIX))
$(copy-file-to-target)
else
$(LOCAL_BUILT_MODULE): $(LOCAL_PREBUILT_MODULE_FILE)
$(transform-prebuilt-to-target)
endif
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
$(hide) chmod +x $@
endif

View file

@ -5,11 +5,13 @@ STRIP_PATH="${1}"
CORE="${2}"
VENDOR="${3}"
stripped_core="${CORE}.vndk_lib_check.stripped"
stripped_vendor="${VENDOR}.vndk_lib_check.stripped"
TMPDIR="$(mktemp -d ${CORE}.vndk_lib_check.XXXXXXXX)"
stripped_core="${TMPDIR}/core"
stripped_vendor="${TMPDIR}/vendor"
function cleanup() {
rm -f ${stripped_core} ${stripped_vendor}
rm -f "${stripped_core}" "${stripped_vendor}"
rmdir "${TMPDIR}"
}
trap cleanup EXIT