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: |
| 3 | # LOCAL_JNI_SHARED_LIBRARIES |
| 4 | # LOCAL_INSTALLED_MODULE |
| 5 | # rs_compatibility_jni_libs (from java.mk) |
| 6 | # my_module_path (from base_rules.mk) |
| 7 | # partition_tag (from base_rules.mk) |
| 8 | # |
| 9 | # Output variables: |
| 10 | # jni_shared_libraries, jni_shared_libraries_abi, if we are going to embed the libraries into the apk. |
| 11 | # |
| 12 | |
| 13 | jni_shared_libraries := \ |
| 14 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 15 | $(addsuffix .so, \ |
| 16 | $(LOCAL_JNI_SHARED_LIBRARIES))) |
| 17 | |
| 18 | # Include RS dynamically-generated libraries as well |
| 19 | # Keep this ifneq, as the += otherwise adds spaces that need to be stripped. |
| 20 | ifneq ($(rs_compatibility_jni_libs),) |
| 21 | jni_shared_libraries += $(rs_compatibility_jni_libs) |
| 22 | endif |
| 23 | |
| 24 | my_embed_jni := |
| 25 | ifneq ($(TARGET_BUILD_APPS),) |
| 26 | my_embed_jni := true |
| 27 | endif |
| 28 | ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),) |
| 29 | my_embed_jni := true |
| 30 | endif |
| 31 | ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),) |
| 32 | # If this app isn't to be installed to system partitions. |
| 33 | my_embed_jni := true |
| 34 | endif |
| 35 | |
| 36 | ifdef my_embed_jni |
| 37 | # App explicitly requires the prebuilt NDK stl shared libraies. |
| 38 | # The NDK stl shared libraries should never go to the system image. |
| 39 | ifneq ($(filter $(LOCAL_NDK_STL_VARIANT), stlport_shared c++_shared),) |
| 40 | ifndef LOCAL_SDK_VERSION |
| 41 | $(error LOCAL_SDK_VERSION must be defined with LOCAL_NDK_STL_VARIANT, \ |
| 42 | LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME)) |
| 43 | endif |
| 44 | endif |
| 45 | ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT)) |
| 46 | jni_shared_libraries += \ |
| 47 | $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so |
| 48 | else ifeq (c++_shared,$(LOCAL_NDK_STL_VARIANT)) |
| 49 | jni_shared_libraries += \ |
| 50 | $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so |
| 51 | endif |
| 52 | |
| 53 | # Set the abi directory used by the local JNI shared libraries. |
| 54 | # (Doesn't change how the local shared libraries are compiled, just |
| 55 | # sets where they are stored in the apk.) |
| 56 | ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),) |
| 57 | jni_shared_libraries_abi := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI) |
| 58 | else |
| 59 | jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI) |
| 60 | endif |
| 61 | |
| 62 | else # not my_embed_jni |
| 63 | |
| 64 | jni_shared_libraries := $(strip $(jni_shared_libraries)) |
| 65 | ifneq ($(jni_shared_libraries),) |
| 66 | # The jni libaries will be installed to the system.img. |
| 67 | my_jni_filenames := $(notdir $(jni_shared_libraries)) |
| 68 | # Make sure the JNI libraries get installed |
| 69 | $(LOCAL_INSTALLED_MODULE) : | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET$(partition_tag)_OUT_SHARED_LIBRARIES)/, $(my_jni_filenames)) |
| 70 | |
| 71 | # Create symlink in the app specific lib path |
| 72 | ifdef LOCAL_POST_INSTALL_CMD |
| 73 | my_leading_separator := ; |
| 74 | else |
| 75 | my_leading_separator := |
| 76 | endif |
| 77 | my_app_lib_path := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET$(partition_tag)_OUT_SHARED_LIBRARIES)/$(basename $(LOCAL_INSTALLED_MODULE_STEM)) |
| 78 | $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD += \ |
| 79 | $(my_leading_separator)mkdir -p $(my_app_lib_path) \ |
| 80 | $(foreach lib, $(my_jni_filenames), ;ln -sf ../$(lib) $(my_app_lib_path)/$(lib)) |
| 81 | |
| 82 | # Clear jni_shared_libraries to not embed it into the apk. |
| 83 | jni_shared_libraries := |
| 84 | endif # $(jni_shared_libraries) not empty |
| 85 | endif # my_embed_jni |