Add LOCAL_JNI_SHARED_LIBRARIES_ABI build variable.
LOCAL_JNI_SHARED_LIBRARIES_ABI allows individual APKs to specify
specify the path where JNI shared libraries are stored in the APK. This
is useful if you want to build an APK that supports a generic version of
an ABI (e.g. armeabi) from a device configuration where
TARGET_CPU_ABI is set to a more specific version of an ABI (e.g.
armeabi-v7a.)
Note that specifying the LOCAL_JNI_SHARED_LIBRARIES_ABI does not
affect how the local JNI shared libraries are built. It just controls
where the local JNI shared libraries are placed within the APK.
Defaults to TARGET_CPU_ABI.
Change-Id: I1cbb293e0c953688945fc147c7fc367421cf860b
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index c37b43e..8edb4c3 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -79,6 +79,7 @@
LOCAL_STRIP_MODULE:=
LOCAL_POST_PROCESS_COMMAND:=true
LOCAL_JNI_SHARED_LIBRARIES:=
+LOCAL_JNI_SHARED_LIBRARIES_ABI:=
LOCAL_JAR_MANIFEST:=
LOCAL_INSTRUMENTATION_FOR:=
LOCAL_INSTRUMENTATION_FOR_PACKAGE_NAME:=
diff --git a/core/definitions.mk b/core/definitions.mk
index f554490..0b868b0 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1408,8 +1408,8 @@
define add-jni-shared-libs-to-package
$(hide) rm -rf $(dir $@)lib
-$(hide) mkdir -p $(dir $@)lib/$(TARGET_CPU_ABI)
-$(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/$(TARGET_CPU_ABI)
+$(hide) mkdir -p $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)
+$(hide) cp $(PRIVATE_JNI_SHARED_LIBRARIES) $(dir $@)lib/$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)
$(hide) (cd $(dir $@) && zip -r $(notdir $@) lib)
$(hide) rm -rf $(dir $@)lib
endef
diff --git a/core/package.mk b/core/package.mk
index cdeefb4..bffda93 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -278,6 +278,16 @@
$(addsuffix $(so_suffix), \
$(LOCAL_JNI_SHARED_LIBRARIES)))
+# Set the abi directory used by the local JNI shared libraries.
+# (Doesn't change how the local shared libraries are compiled, just
+# sets where they are stored in the apk.)
+
+ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),)
+ jni_shared_libraries_abi := $(TARGET_CPU_ABI)
+else
+ jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI)
+endif
+
# Pick a key to sign the package with. If this package hasn't specified
# an explicit certificate, use the default.
# Secure release builds will have their packages signed after the fact,
@@ -311,6 +321,7 @@
# Define the rule to build the actual package.
$(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN)
$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries)
+$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi)
ifneq ($(TARGET_BUILD_APPS),)
# Include all resources for unbundled apps.
$(LOCAL_BUILT_MODULE): PRODUCT_AAPT_CONFIG :=