From c18ebafcb964253db596eb1d3b7f7b90f2777678 Mon Sep 17 00:00:00 2001 From: Jaewoong Jung Date: Thu, 18 Feb 2021 15:06:08 -0800 Subject: [PATCH] Remove unwanted JNI libs outside inflating action. Take the unwanted JNI lib removal action out of JNI uncompression function so that they work independently when building prebuilt apks. Fixes: 180475879 Test: Manually with a test apk. Change-Id: I7392d0bf4ca7db76f27e883df08f7cb256162440 --- core/app_prebuilt_internal.mk | 1 + core/definitions.mk | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/app_prebuilt_internal.mk b/core/app_prebuilt_internal.mk index 576799692f..cb1b4538a3 100644 --- a/core/app_prebuilt_internal.mk +++ b/core/app_prebuilt_internal.mk @@ -237,6 +237,7 @@ endif $(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR) $(transform-prebuilt-to-target) $(uncompress-prebuilt-embedded-jni-libs) + $(remove-unwanted-prebuilt-embedded-jni-libs) ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) $(uncompress-dexs) endif # LOCAL_UNCOMPRESS_DEX diff --git a/core/definitions.mk b/core/definitions.mk index 5f0bf551d4..8d32a9980c 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2396,14 +2396,19 @@ endef # define uncompress-prebuilt-embedded-jni-libs if (zipinfo $@ 'lib/*.so' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \ - $(ZIP2ZIP) -i $@ -o $@.tmp -0 'lib/**/*.so' \ - $(if $(PRIVATE_EMBEDDED_JNI_LIBS), \ - -x 'lib/**/*.so' \ - $(addprefix -X ,$(PRIVATE_EMBEDDED_JNI_LIBS))) && \ - mv -f $@.tmp $@ ; \ + $(ZIP2ZIP) -i $@ -o $@.tmp -0 'lib/**/*.so' && mv -f $@.tmp $@ ; \ fi endef +# Remove unwanted shared JNI libraries embedded in an apk. +# +define remove-unwanted-prebuilt-embedded-jni-libs + $(if $(PRIVATE_EMBEDDED_JNI_LIBS), \ + $(ZIP2ZIP) -i $@ -o $@.tmp \ + -x 'lib/**/*.so' $(addprefix -X ,$(PRIVATE_EMBEDDED_JNI_LIBS)) && \ + mv -f $@.tmp $@) +endef + # TODO(joeo): If we can ever upgrade to post 3.81 make and get the # new prebuilt rules to work, we should change this to copy the # resources to the out directory and then copy the resources.