From 4873e65c8d251a717e5d93025484b35f03ed2fb5 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Wed, 8 Jan 2020 14:39:10 -0800 Subject: [PATCH] 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 --- core/clear_vars.mk | 1 + core/soong_cc_prebuilt.mk | 40 +++++++++++++++++++----------------- tools/check_identical_lib.sh | 8 +++++--- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 6c3b24900..303f18ec2 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -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:= diff --git a/core/soong_cc_prebuilt.mk b/core/soong_cc_prebuilt.mk index 2d5089d0e..0cc055c41 100644 --- a/core/soong_cc_prebuilt.mk +++ b/core/soong_cc_prebuilt.mk @@ -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 diff --git a/tools/check_identical_lib.sh b/tools/check_identical_lib.sh index 01007c088..c3aa41a72 100755 --- a/tools/check_identical_lib.sh +++ b/tools/check_identical_lib.sh @@ -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