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),) 16 my_embed_jni := true 17endif 18ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),) 19 my_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_SYSTEM_EXT)/% \ 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 38 my_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)) 53 my_add_jni := true 54endif 55# Or it explicitly requires both 56ifeq ($(my_module_multilib),both) 57 my_add_jni := true 58endif 59ifeq ($(my_add_jni),true) 60 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH)) 61 ifndef my_prebuilt_jni_libs 62 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS) 63 endif 64 include $(BUILD_SYSTEM)/install_jni_libs_internal.mk 65 jni_shared_libraries += $(my_jni_shared_libraries) 66 jni_shared_libraries_abis += $(my_jni_shared_libraries_abi) 67 jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\ 68 $(my_jni_shared_libraries)) 69 embedded_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. 73 jni_shared_libraries += $(rs_compatibility_jni_libs) 74 jni_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 81 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 82 my_add_jni := 83 # The module is built for TARGET_2ND_ARCH 84 ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX)) 85 my_add_jni := true 86 endif 87 # Or it explicitly requires both 88 ifeq ($(my_module_multilib),both) 89 my_add_jni := true 90 endif 91 ifeq ($(my_add_jni),true) 92 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH)) 93 ifndef my_prebuilt_jni_libs 94 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS) 95 endif 96 include $(BUILD_SYSTEM)/install_jni_libs_internal.mk 97 jni_shared_libraries += $(my_jni_shared_libraries) 98 jni_shared_libraries_abis += $(my_jni_shared_libraries_abi) 99 jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\ 100 $(my_jni_shared_libraries)) 101 embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs) 102 endif # 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