From ad0d7710fe54d136da867ca370a73d7718a2aeb8 Mon Sep 17 00:00:00 2001 From: Kiyoung Kim Date: Wed, 31 Aug 2022 14:02:36 +0900 Subject: [PATCH] Replace dependencies from the Makefile to API imported modules There are some module definitions in the Makefile, which needs to be built with API imported module. This change replaces existing dependencies from the Makefile, to append suffix on the reference, so it can be linked to API imported modules. Bug: 243736650 Test: 'ALLOW_MISSING_DEPENDENCIES=true m halutil' succeeded. Change-Id: I12baa36e41c0c69228be5f0d08fb4c18eb8a22b1 --- core/base_rules.mk | 18 ++++++++++++++++++ core/binary.mk | 22 ++++++++++++++++++++++ core/cc_prebuilt_internal.mk | 21 +++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/core/base_rules.mk b/core/base_rules.mk index 9bb6c4718a..adf3668411 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -1035,6 +1035,24 @@ ALL_MODULES.$(my_register_name).SUPPORTED_VARIANTS := \ $(ALL_MODULES.$(my_register_name).SUPPORTED_VARIANTS) \ $(filter-out $(ALL_MODULES.$(my_register_name).SUPPORTED_VARIANTS),$(my_supported_variant)) +########################################################################## +## When compiling against API imported module, use API import stub +## libraries. +########################################################################## +ifneq ($(LOCAL_USE_VNDK),) + ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) + apiimport_postfix := .apiimport + ifeq ($(LOCAL_USE_VNDK_PRODUCT),true) + apiimport_postfix := .apiimport.product + else + apiimport_postfix := .apiimport.vendor + endif + + my_required_modules := $(foreach l,$(my_required_modules), \ + $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l))) + endif +endif + ########################################################################## ## When compiling against the VNDK, add the .vendor or .product suffix to ## required modules. diff --git a/core/binary.mk b/core/binary.mk index 3f32fa90b6..1ad9be8744 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -1145,6 +1145,28 @@ ifneq ($(filter hwaddress,$(my_sanitize)),) $(my_static_libraries),hwasan) endif +################################################################### +## When compiling against API imported module, use API import stub +## libraries. +################################################################## + +apiimport_postfix := .apiimport + +ifneq ($(LOCAL_USE_VNDK),) + ifeq ($(LOCAL_USE_VNDK_PRODUCT),true) + apiimport_postfix := .apiimport.product + else + apiimport_postfix := .apiimport.vendor + endif +endif + +my_shared_libraries := $(foreach l,$(my_shared_libraries), \ + $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l))) +my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries), \ + $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l))) +my_header_libraries := $(foreach l,$(my_header_libraries), \ + $(if $(filter $(l), $(API_IMPORTED_HEADER_LIBRARIES)), $(l)$(apiimport_postfix), $(l))) + ########################################################### ## When compiling against the VNDK, use LL-NDK libraries ########################################################### diff --git a/core/cc_prebuilt_internal.mk b/core/cc_prebuilt_internal.mk index e8e01d865f..2de4115fb4 100644 --- a/core/cc_prebuilt_internal.mk +++ b/core/cc_prebuilt_internal.mk @@ -139,6 +139,27 @@ my_shared_libraries := $(strip \ # my_shared_libraries). include $(BUILD_SYSTEM)/cxx_stl_setup.mk +# When compiling against API imported module, use API import stub libraries. +apiimport_postfix := .apiimport + +ifneq ($(LOCAL_USE_VNDK),) + ifeq ($(LOCAL_USE_VNDK_PRODUCT),true) + apiimport_postfix := .apiimport.product + else + apiimport_postfix := .apiimport.vendor + endif +endif + +ifdef my_shared_libraries +my_shared_libraries := $(foreach l,$(my_shared_libraries), \ + $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l))) +endif #my_shared_libraries + +ifdef my_system_shared_libraries +my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries), \ + $(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l))) +endif #my_system_shared_libraries + ifdef my_shared_libraries ifdef LOCAL_USE_VNDK ifeq ($(LOCAL_USE_VNDK_PRODUCT),true)