From 3797466fbd31cc3ca5a1eddea64e7fdf0921ea67 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 1 May 2015 14:02:26 -0700 Subject: 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//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 --- core/definitions.mk | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'core/definitions.mk') diff --git a/core/definitions.mk b/core/definitions.mk index fc18ee3..f674d9f 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2097,8 +2097,7 @@ $(hide) mkdir -p $(addprefix $(dir $@)lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI)) $(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\ $(call _add-jni-shared-libs-to-package-per-abi,$(abi),\ $(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES))))) -$(hide) (cd $(dir $@) && zip -r \ - $(if $(filter true, $(PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES)),-0,) $(notdir $@) lib) +$(hide) (cd $(dir $@) && zip -r -0 $(notdir $@) lib) $(hide) rm -rf $(dir $@)lib endef @@ -2144,21 +2143,22 @@ endef define align-package $(hide) mv $@ $@.unaligned $(hide) $(ZIPALIGN) \ - -f \ - $(if $(filter true, $(PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES)),-p,) \ + -f -p \ 4 \ $@.unaligned $@.aligned $(hide) mv $@.aligned $@ endef +# Uncompress shared libraries embedded in an apk. +# define uncompress-shared-libs -$(hide) rm -rf $(dir $@)/tmpworkdir -$(hide) mv $@ $@.compressed -$(hide) mkdir $(dir $@)/tmpworkdir -$(hide) unzip $@.compressed 'lib/*.so' -d $(dir $@)/tmpworkdir -$(hide) ( cd $(dir $@)/tmpworkdir && zip -D -r -0 ../$(notdir $@).compressed lib ) -$(hide) mv $@.compressed $@ -$(hide) rm -rf $(dir $@)/tmpworkdir +$(hide) if unzip -l $@ $(PRIVATE_EMBEDDED_JNI_LIBS) >/dev/null ; then \ + rm -rf $(dir $@)uncompressedlibs && mkdir $(dir $@)uncompressedlibs; \ + unzip $@ $(PRIVATE_EMBEDDED_JNI_LIBS) -d $(dir $@)uncompressedlibs && \ + zip -d $@ 'lib/*.so' && \ + ( cd $(dir $@)uncompressedlibs && zip -D -r -0 ../$(notdir $@) lib ) && \ + rm -rf $(dir $@)uncompressedlibs; \ + fi endef define install-dex-debug -- cgit v1.1