platform_build/core/install_jni_libs.mk
Ying Wang 3797466fbd Don't extract jni from prebuilt apks.
- We don't need LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES now, for we always
  page-align jni shared libraries and store them umcompressed.
- For prebuilt apks, we don't extract jni any more; Instead we always run
  uncompress-shared-libs on them.
- For apks built from source, we still install the jni separately, because
  that way multiple apks can share the same jni and it saves space.

With this change, for most prebuilt apks, we don't need to specify
LOCAL_PREBUILT_JNI_LIBS ("@lib/<abi>/foo.so") any more, for the build
system automatically replaces the embedded jni with uncompressed files;
But if a prebuilt is a fat apk (i.e. containing jni not needed by the
current product architecture), you still need LOCAL_PREBUILT_JNI_LIBS to
specify what jni to keep. Otherwise all embedded jni will be replaced with
uncompressed files, that wastes space.

Bug: 8076853
Change-Id: Icf07e0998ac3602e6e05e80fed836fbafca33e01
2015-05-01 16:09:58 -07:00

93 lines
3.4 KiB
Makefile

# Decides how to install the jni libraries needed by an apk.
# Input variables:
# my_module_multilib, LOCAL_2ND_ARCH_VAR_PREFIX (from package.mk or prebuilt.mk)
# rs_compatibility_jni_libs (from java.mk)
# my_module_path (from base_rules.mk)
# partition_tag (from base_rules.mk)
# my_prebuilt_src_file (from prebuilt_internal.mk)
#
# Output variables:
# jni_shared_libraries, jni_shared_libraries_abi, jni_shared_libraries_with_abis if we are going to embed the libraries into the apk;
# embedded_prebuilt_jni_libs, prebuilt jni libs embedded in prebuilt apk.
#
my_embed_jni :=
ifneq ($(TARGET_BUILD_APPS),)
my_embed_jni := true
endif
ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),)
my_embed_jni := true
endif
ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),)
# If this app isn't to be installed to system partitions.
my_embed_jni := true
endif
jni_shared_libraries :=
jni_shared_libraries_abis :=
# jni_shared_libraries_with_abis is a list of <abi>:<path-to-the-built-jni-lib>
jni_shared_libraries_with_abis :=
embedded_prebuilt_jni_libs :=
#######################################
# For TARGET_ARCH
my_2nd_arch_prefix :=
my_add_jni :=
# The module is built for TARGET_ARCH
ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX))
my_add_jni := true
endif
# Or it explicitly requires both
ifeq ($(my_module_multilib),both)
my_add_jni := true
endif
ifeq ($(my_add_jni),true)
my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH))
ifndef my_prebuilt_jni_libs
my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)
endif
include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
jni_shared_libraries += $(my_jni_shared_libraries)
jni_shared_libraries_abis += $(my_jni_shared_libraries_abi)
jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
$(my_jni_shared_libraries))
embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs)
# Include RS dynamically-generated libraries as well
# TODO: Add multilib support once RS supports generating multilib libraries.
jni_shared_libraries += $(rs_compatibility_jni_libs)
jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
$(rs_compatibility_jni_libs))
endif # my_add_jni
#######################################
# For TARGET_2ND_ARCH
ifdef TARGET_2ND_ARCH
my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
my_add_jni :=
# The module is built for TARGET_2ND_ARCH
ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX))
my_add_jni := true
endif
# Or it explicitly requires both
ifeq ($(my_module_multilib),both)
my_add_jni := true
endif
ifeq ($(my_add_jni),true)
my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH))
ifndef my_prebuilt_jni_libs
my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)
endif
include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
jni_shared_libraries += $(my_jni_shared_libraries)
jni_shared_libraries_abis += $(my_jni_shared_libraries_abi)
jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
$(my_jni_shared_libraries))
embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs)
endif # my_add_jni
endif # TARGET_2ND_ARCH
jni_shared_libraries := $(strip $(jni_shared_libraries))
jni_shared_libraries_abis := $(sort $(jni_shared_libraries_abis))
jni_shared_libraries_with_abis := $(strip $(jni_shared_libraries_with_abis))
embedded_prebuilt_jni_libs := $(strip $(embedded_prebuilt_jni_libs))