1# Decides how to install the jni libraries needed by an apk. 2# Input variables: 3# my_module_multilib, LOCAL_2ND_ARCH_VAR_PREFIX (from package.mk or prebuilt.mk) 4# rs_compatibility_jni_libs (from java.mk) 5# my_module_path (from base_rules.mk) 6# partition_tag (from base_rules.mk) 7# my_prebuilt_src_file (from prebuilt_internal.mk) 8# 9# Output variables: 10# jni_shared_libraries, jni_shared_libraries_abi, jni_shared_libraries_with_abis if we are going to embed the libraries into the apk; 11# embedded_prebuilt_jni_libs, prebuilt jni libs embedded in prebuilt apk. 12# 13 14my_embed_jni := 15ifneq ($(TARGET_BUILD_APPS),) 16my_embed_jni := true 17endif 18ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),) 19my_embed_jni := true 20endif 21 22# If the APK is not installed in one of the following partitions, force its libraries 23# to be embedded inside the APK instead of installed to /<partition>/lib[64]/. 24supported_partition_patterns := \ 25 $(TARGET_OUT)/% \ 26 $(TARGET_OUT_VENDOR)/% \ 27 $(TARGET_OUT_OEM)/% \ 28 $(TARGET_OUT_PRODUCT)/% \ 29 $(TARGET_OUT_PRODUCT_SERVICES)/% \ 30 31ifeq ($(filter $(supported_partition_patterns),$(my_module_path)),) 32 my_embed_jni := true 33endif 34 35# If we're installing this APP as a compressed module, we include all JNI libraries 36# in the compressed artifact, rather than as separate files on the partition in question. 37ifdef LOCAL_COMPRESSED_MODULE 38my_embed_jni := true 39endif 40 41jni_shared_libraries := 42jni_shared_libraries_abis := 43# jni_shared_libraries_with_abis is a list of <abi>:<path-to-the-built-jni-lib> 44jni_shared_libraries_with_abis := 45embedded_prebuilt_jni_libs := 46 47####################################### 48# For TARGET_ARCH 49my_2nd_arch_prefix := 50my_add_jni := 51# The module is built for TARGET_ARCH 52ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX)) 53my_add_jni := true 54endif 55# Or it explicitly requires both 56ifeq ($(my_module_multilib),both) 57my_add_jni := true 58endif 59ifeq ($(my_add_jni),true) 60my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH)) 61ifndef my_prebuilt_jni_libs 62my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS) 63endif 64include $(BUILD_SYSTEM)/install_jni_libs_internal.mk 65jni_shared_libraries += $(my_jni_shared_libraries) 66jni_shared_libraries_abis += $(my_jni_shared_libraries_abi) 67jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\ 68 $(my_jni_shared_libraries)) 69embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs) 70 71# Include RS dynamically-generated libraries as well 72# TODO: Add multilib support once RS supports generating multilib libraries. 73jni_shared_libraries += $(rs_compatibility_jni_libs) 74jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\ 75 $(rs_compatibility_jni_libs)) 76endif # my_add_jni 77 78####################################### 79# For TARGET_2ND_ARCH 80ifdef TARGET_2ND_ARCH 81my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 82my_add_jni := 83# The module is built for TARGET_2ND_ARCH 84ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX)) 85my_add_jni := true 86endif 87# Or it explicitly requires both 88ifeq ($(my_module_multilib),both) 89my_add_jni := true 90endif 91ifeq ($(my_add_jni),true) 92my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH)) 93ifndef my_prebuilt_jni_libs 94my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS) 95endif 96include $(BUILD_SYSTEM)/install_jni_libs_internal.mk 97jni_shared_libraries += $(my_jni_shared_libraries) 98jni_shared_libraries_abis += $(my_jni_shared_libraries_abi) 99jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\ 100 $(my_jni_shared_libraries)) 101embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs) 102endif # my_add_jni 103endif # TARGET_2ND_ARCH 104 105jni_shared_libraries := $(strip $(jni_shared_libraries)) 106jni_shared_libraries_abis := $(sort $(jni_shared_libraries_abis)) 107jni_shared_libraries_with_abis := $(strip $(jni_shared_libraries_with_abis)) 108embedded_prebuilt_jni_libs := $(strip $(embedded_prebuilt_jni_libs)) 109