Support split /system and /vendor modules from Soong

Soong modules may be split into both /system and /vendor variants.
Ensure that Make libraries link against the correct version based on
whether LOCAL_USE_VNDK is set.

Bug: 36426473
Bug: 36079834
Test: build-aosp_arm64.ninja files are the same before/after
Test: attempt building with BOARD_VNDK_VERSION:=current
(cherry picked from commit 9d2b3280e8)
Merged-In: I229bc290373743406275f3ca16081eae04c27987
Change-Id: I229bc290373743406275f3ca16081eae04c27987
This commit is contained in:
Dan Willemsen 2017-04-07 20:58:43 -07:00 committed by Steven Moreland
parent 5643689385
commit 58760e47aa
5 changed files with 63 additions and 10 deletions

View file

@ -414,6 +414,9 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/vendor/lib*)
# Soong module variant change, remove obsolete intermediates
$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************

View file

@ -518,10 +518,31 @@ my_asflags += -D__ASSEMBLY__
## When compiling against the VNDK, use LL-NDK libraries
###########################################################
ifneq ($(LOCAL_USE_VNDK),)
my_shared_libraries := $(foreach lib,$(my_shared_libraries),\
$(if $(filter $(LLNDK_LIBRARIES),$(lib)),$(lib).llndk,$(lib)))
my_system_shared_libraries := $(foreach lib,$(my_system_shared_libraries),\
$(if $(filter $(LLNDK_LIBRARIES),$(lib)),$(lib).llndk,$(lib)))
####################################################
## Soong modules may be built twice, once for /system
## and once for /vendor. If we're using the VNDK,
## switch all soong libraries over to the /vendor
## variant.
####################################################
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
# Soong-built libraries should always use the .vendor variant
my_whole_static_libraries := $(addsuffix .vendor,$(my_whole_static_libraries))
my_static_libraries := $(addsuffix .vendor,$(my_static_libraries))
my_shared_libraries := $(addsuffix .vendor,$(my_shared_libraries))
my_system_shared_libraries := $(addsuffix .vendor,$(my_system_shared_libraries))
my_header_libraries := $(addsuffix .vendor,$(my_header_libraries))
else
my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
$(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_static_libraries := $(foreach l,$(my_static_libraries),\
$(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_header_libraries := $(foreach l,$(my_header_libraries),\
$(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l)))
endif
endif
###########################################################
@ -1381,6 +1402,10 @@ ifdef LOCAL_SDK_VERSION
$(my_link_type): PRIVATE_LINK_TYPE := native:ndk
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk
else ifdef LOCAL_USE_VNDK
$(my_link_type): PRIVATE_LINK_TYPE := native:vendor
$(my_link_type): PRIVATE_WARN_TYPES :=
$(my_link_type): PRIVATE_ALLOWED_TYPES := native:vendor
else
$(my_link_type): PRIVATE_LINK_TYPE := native:platform
$(my_link_type): PRIVATE_WARN_TYPES :=

View file

@ -44,12 +44,16 @@ ifeq ($(LOCAL_NO_CRT),true)
my_target_crtbegin_dynamic_o :=
my_target_crtbegin_static_o :=
my_target_crtend_o :=
else ifdef LOCAL_USE_VNDK
my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.vendor.o
my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.vendor.o
my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.vendor.o
else
my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
endif
ifneq ($(LOCAL_SDK_VERSION)$(LOCAL_USE_VNDK),)
ifneq ($(LOCAL_SDK_VERSION),)
my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o)
my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o)
my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o)

View file

@ -79,9 +79,13 @@ else
endif
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
ifeq ($(prebuilt_module_is_a_library),true)
SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE)
endif
ifeq ($(prebuilt_module_is_a_library),true)
SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE)
endif
ifdef LOCAL_USE_VNDK
SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(patsubst %.vendor,%,$(LOCAL_MODULE)) := 1
endif
endif
# Don't install static libraries by default.
@ -145,7 +149,13 @@ endif
export_cflags :=
my_link_type := $(intermediates)/link_type
$(my_link_type): PRIVATE_LINK_TYPE := native:$(if $(LOCAL_SDK_VERSION),ndk,platform)
ifdef LOCAL_SDK_VERSION
$(my_link_type): PRIVATE_LINK_TYPE := native:ndk
else ifdef LOCAL_USE_VNDK
$(my_link_type): PRIVATE_LINK_TYPE := native:vendor
else
$(my_link_type): PRIVATE_LINK_TYPE := native:platform
endif
$(eval $(call link-type-partitions,$(my_link_type)))
$(my_link_type):
@echo Check module type: $@
@ -162,6 +172,14 @@ ifdef LOCAL_SHARED_LIBRARIES
my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
# Extra shared libraries introduced by LOCAL_CXX_STL.
include $(BUILD_SYSTEM)/cxx_stl_setup.mk
ifdef LOCAL_USE_VNDK
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
my_shared_libraries := $(addsuffix .vendor,$(my_shared_libraries))
else
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
endif
endif
$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
$(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))

View file

@ -48,11 +48,14 @@ my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,
ifeq ($(LOCAL_NO_CRT),true)
my_target_crtbegin_so_o :=
my_target_crtend_so_o :=
else ifdef LOCAL_USE_VNDK
my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.vendor.o
my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.vendor.o
else
my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
endif
ifneq ($(LOCAL_SDK_VERSION)$(LOCAL_USE_VNDK),)
ifneq ($(LOCAL_SDK_VERSION),)
my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o)
my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o)
endif