Home | History | Annotate | Download | only in core
      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 
     14 my_embed_jni :=
     15 ifneq ($(TARGET_BUILD_APPS),)
     16 my_embed_jni := true
     17 endif
     18 ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),)
     19 my_embed_jni := true
     20 endif
     21 ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),)
     22 # If this app isn't to be installed to system partitions.
     23 my_embed_jni := true
     24 endif
     25 # If we're installing this APP as a compressed module, we include all JNI libraries
     26 # in the compressed artifact, rather than as separate files on the partition in question.
     27 ifdef LOCAL_COMPRESSED_MODULE
     28 my_embed_jni := true
     29 endif
     30 
     31 jni_shared_libraries :=
     32 jni_shared_libraries_abis :=
     33 # jni_shared_libraries_with_abis is a list of <abi>:<path-to-the-built-jni-lib>
     34 jni_shared_libraries_with_abis :=
     35 embedded_prebuilt_jni_libs :=
     36 
     37 #######################################
     38 # For TARGET_ARCH
     39 my_2nd_arch_prefix :=
     40 my_add_jni :=
     41 # The module is built for TARGET_ARCH
     42 ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX))
     43 my_add_jni := true
     44 endif
     45 # Or it explicitly requires both
     46 ifeq ($(my_module_multilib),both)
     47 my_add_jni := true
     48 endif
     49 ifeq ($(my_add_jni),true)
     50 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH))
     51 ifndef my_prebuilt_jni_libs
     52 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)
     53 endif
     54 include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
     55 jni_shared_libraries += $(my_jni_shared_libraries)
     56 jni_shared_libraries_abis += $(my_jni_shared_libraries_abi)
     57 jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
     58     $(my_jni_shared_libraries))
     59 embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs)
     60 
     61 # Include RS dynamically-generated libraries as well
     62 # TODO: Add multilib support once RS supports generating multilib libraries.
     63 jni_shared_libraries += $(rs_compatibility_jni_libs)
     64 jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
     65     $(rs_compatibility_jni_libs))
     66 endif  # my_add_jni
     67 
     68 #######################################
     69 # For TARGET_2ND_ARCH
     70 ifdef TARGET_2ND_ARCH
     71 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
     72 my_add_jni :=
     73 # The module is built for TARGET_2ND_ARCH
     74 ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX))
     75 my_add_jni := true
     76 endif
     77 # Or it explicitly requires both
     78 ifeq ($(my_module_multilib),both)
     79 my_add_jni := true
     80 endif
     81 ifeq ($(my_add_jni),true)
     82 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH))
     83 ifndef my_prebuilt_jni_libs
     84 my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)
     85 endif
     86 include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
     87 jni_shared_libraries += $(my_jni_shared_libraries)
     88 jni_shared_libraries_abis += $(my_jni_shared_libraries_abi)
     89 jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
     90     $(my_jni_shared_libraries))
     91 embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs)
     92 endif  # my_add_jni
     93 endif  # TARGET_2ND_ARCH
     94 
     95 jni_shared_libraries := $(strip $(jni_shared_libraries))
     96 jni_shared_libraries_abis := $(sort $(jni_shared_libraries_abis))
     97 jni_shared_libraries_with_abis := $(strip $(jni_shared_libraries_with_abis))
     98 embedded_prebuilt_jni_libs := $(strip $(embedded_prebuilt_jni_libs))
     99