Create partition-specific symlink for jnilib install

Context
- Currently, unembedded JNI libraries are being installed from a symlink based on an android_app's partition.
- Unembedded JNI library may exist in a different partition from that of the app module, thus create a symlink based on the partition of each jni libraries.
- Scope of this change is limited to bp modules, and does not affect mk modules.

Implementation
- Use the JNI library name:partition mapping from LOCAL_SOONG_JNI_LIBS_PARTITION_<target> to create a symlink.

Bug: 154162945
Test: m
Change-Id: Ie9396e0eb1c5bfc5855a2a84db395a2b9008b17b
This commit is contained in:
Jihoon Kang 2022-09-01 23:24:47 +00:00
parent 2a9b910bf4
commit d203e12f20
2 changed files with 30 additions and 7 deletions

View file

@ -5,6 +5,7 @@
# my_prebuilt_jni_libs
# my_installed_module_stem (from configure_module_stem.mk)
# partition_tag (from base_rules.mk)
# partition_lib_pairs
# my_prebuilt_src_file (from prebuilt_internal.mk)
#
# Output variables:
@ -66,13 +67,32 @@ else ifneq ($(my_jni_shared_libraries),) # not my_embed_jni
ifeq ($(filter address,$(SANITIZE_TARGET)),)
my_symlink_target_dir := $(patsubst $(PRODUCT_OUT)%,%,\
$(my_shared_library_path))
$(foreach lib,$(my_jni_filenames),\
$(call symlink-file, \
$(my_shared_library_path)/$(lib), \
$(my_symlink_target_dir)/$(lib), \
$(my_app_lib_path)/$(lib)) \
$(eval $$(LOCAL_INSTALLED_MODULE) : $$(my_app_lib_path)/$$(lib)) \
$(eval ALL_MODULES.$(my_register_name).INSTALLED += $$(my_app_lib_path)/$$(lib)))
ifdef partition_lib_pairs
# Support cross-partition jni lib dependency for bp modules
# API domain check is done in Soong
$(foreach pl_pair,$(partition_lib_pairs),\
$(eval lib_name := $(call word-colon, 1, $(pl_pair)))\
$(eval lib_partition := $(call word-colon, 2, $(pl_pair)))\
$(eval shared_library_path := $(call get_non_asan_path,\
$($(my_2nd_arch_prefix)TARGET_OUT$(lib_partition)_SHARED_LIBRARIES)))\
$(call symlink-file,\
$(shared_library_path)/$(lib_name).so,\
$(my_symlink_target_dir)/$(lib_name).so,\
$(my_app_lib_path)/$(lib_name).so)\
$(eval $$(LOCAL_INSTALLED_MODULE) : $$(my_app_lib_path)/$$(lib_name).so)\
$(eval ALL_MODULES.$(my_register_name).INSTALLED += $$(my_app_lib_path)/$$(lib_name).so))
else
# Cross-partition jni lib dependency currently not supported for mk modules
$(foreach lib,$(my_jni_filenames),\
$(call symlink-file, \
$(my_shared_library_path)/$(lib), \
$(my_symlink_target_dir)/$(lib), \
$(my_app_lib_path)/$(lib)) \
$(eval $$(LOCAL_INSTALLED_MODULE) : $$(my_app_lib_path)/$$(lib)) \
$(eval ALL_MODULES.$(my_register_name).INSTALLED += $$(my_app_lib_path)/$$(lib)))
endif # partition_lib_pairs
endif
# Clear jni_shared_libraries to not embed it into the apk.

View file

@ -165,12 +165,14 @@ my_prebuilt_jni_libs :=
ifdef LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)
my_2nd_arch_prefix :=
LOCAL_JNI_SHARED_LIBRARIES := $(LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH))
partition_lib_pairs := $(LOCAL_SOONG_JNI_LIBS_PARTITION_$(TARGET_ARCH))
include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
endif
ifdef TARGET_2ND_ARCH
ifdef LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)
my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
LOCAL_JNI_SHARED_LIBRARIES := $(LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH))
partition_lib_pairs := $(LOCAL_SOONG_JNI_LIBS_PARTITION_$(TARGET_2ND_ARCH))
include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
endif
endif
@ -178,6 +180,7 @@ LOCAL_SHARED_JNI_LIBRARIES :=
my_embed_jni :=
my_prebuilt_jni_libs :=
my_2nd_arch_prefix :=
partition_lib_pairs :=
PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
ifndef LOCAL_CERTIFICATE