Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 1 | # Decides how to install the jni libraries needed by an apk. |
| 2 | # Input variables: |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 3 | # my_module_multilib, LOCAL_2ND_ARCH_VAR_PREFIX (from package.mk or prebuilt.mk) |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 4 | # rs_compatibility_jni_libs (from java.mk) |
| 5 | # my_module_path (from base_rules.mk) |
| 6 | # partition_tag (from base_rules.mk) |
Ying Wang | 7cf9f28 | 2014-04-18 20:13:41 -0700 | [diff] [blame] | 7 | # my_prebuilt_src_file (from prebuilt_internal.mk) |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 8 | # |
| 9 | # Output variables: |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 10 | # jni_shared_libraries, jni_shared_libraries_abi, jni_shared_libraries_with_abis if we are going to embed the libraries into the apk; |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 11 | # embedded_prebuilt_jni_libs, prebuilt jni libs embedded in prebuilt apk. |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 12 | # |
| 13 | |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 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 |
Jiyong Park | a6b038f | 2017-05-16 19:53:36 +0900 | [diff] [blame] | 21 | ifeq ($(PRODUCT_FULL_TREBLE),true) |
Jiyong Park | 1cb8dea | 2017-04-19 18:06:45 +0900 | [diff] [blame] | 22 | ifeq ($(filter $(TARGET_OUT)/%, $(my_module_path)),) |
| 23 | # If this app isn't to be installed to the system partition, and the device |
| 24 | # is fully treble-ized then jni libs are embedded, Otherwise, access to the |
| 25 | # directory where the lib is installed to (usually /vendor/lib) needs to be |
| 26 | # allowed for system processes, which is a Treble violation. |
| 27 | my_embed_jni := true |
| 28 | endif |
| 29 | else |
| 30 | ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),) |
| 31 | # If this app isn't to be installed to system, vendor, or oem partitions. |
| 32 | my_embed_jni := true |
| 33 | endif |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 34 | endif |
Narayan Kamath | 7c20510 | 2017-08-07 12:31:17 +0100 | [diff] [blame^] | 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. |
| 37 | ifdef LOCAL_COMPRESSED_MODULE |
| 38 | my_embed_jni := true |
| 39 | endif |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 40 | |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 41 | jni_shared_libraries := |
| 42 | jni_shared_libraries_abis := |
| 43 | # jni_shared_libraries_with_abis is a list of <abi>:<path-to-the-built-jni-lib> |
| 44 | jni_shared_libraries_with_abis := |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 45 | embedded_prebuilt_jni_libs := |
Ying Wang | 7cf9f28 | 2014-04-18 20:13:41 -0700 | [diff] [blame] | 46 | |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 47 | ####################################### |
| 48 | # For TARGET_ARCH |
| 49 | my_2nd_arch_prefix := |
| 50 | my_add_jni := |
| 51 | # The module is built for TARGET_ARCH |
| 52 | ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX)) |
| 53 | my_add_jni := true |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 54 | endif |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 55 | # Or it explicitly requires both |
| 56 | ifeq ($(my_module_multilib),both) |
| 57 | my_add_jni := true |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 58 | endif |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 59 | ifeq ($(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) |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 63 | endif |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 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)) |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 69 | embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs) |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 70 | |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 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) |
Ying Wang | a626d3b | 2014-06-30 11:17:16 -0700 | [diff] [blame] | 74 | jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\ |
| 75 | $(rs_compatibility_jni_libs)) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 76 | endif # my_add_jni |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 77 | |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 78 | ####################################### |
| 79 | # For TARGET_2ND_ARCH |
| 80 | ifdef 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)) |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 101 | embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 102 | endif # my_add_jni |
| 103 | endif # TARGET_2ND_ARCH |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 104 | |
| 105 | jni_shared_libraries := $(strip $(jni_shared_libraries)) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 106 | jni_shared_libraries_abis := $(sort $(jni_shared_libraries_abis)) |
| 107 | jni_shared_libraries_with_abis := $(strip $(jni_shared_libraries_with_abis)) |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 108 | embedded_prebuilt_jni_libs := $(strip $(embedded_prebuilt_jni_libs)) |