I've been struggling for sometime with copies of unnecessary libraries into the build when I don't need them.
I have within vendor/<company>/libs the file Android.mk and library.so.
The Android.mk is defined like:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PREBUILT_LIBS := superlibrary.so
include $(BUILD_MULTI_PREBUILT)
Within vendor/<company>/apps I have Android.mk and application.apk.
Android.mk is defined like:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := application
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_REQUIRED_MODULES := superlibrary
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
So, application is tagged as optional. I then add the application within my product (PRODUCT_PACKAGES) and after the build I can see:
- system/app/application.apk
- system/lib/superlibrary.so
But, when I don't add 'application' into the PRODUCT_PACKAGES, the application is not installed, but superlibrary.so will be always in the system/lib.
What is missing in my Android.mk for the library that is copying the file unconditionally to the system lib? I would like to copy it only when the 'application' is installed.
Looking for different ways, I see a lot of "PRODUCT_COPY_FILES" copying the libraries instead of using the mechanism above. Is the way I'm using deprecated?
Any help will be very welcome.
Thanks,
Tiago
The issue is that prebuilts default to LOCAL_MODULE_TAGS=user, which
causes them to be included in all builds regardless of whether they're
specified in PRODUCT_PACKAGES. This is a legacy behavior fromyears
ago.
In theory, all you need to do is add LOCAL_MODULE_TAGS := optional for
your prebuilt. In reality, I'm not sure that BUILD_MULTI_PREBUILT
supports it in froyo.
Looking ahead, starting with Gingerbread, we've decided to "stop the
bleeding": any new module that uses LOCAL_MODULE_TAGS := user
(implicitly or explicitly) and isn't on a whitelist will cause the
build to fail. This is how we (Google) are making sure that none of
our new modules use that mis-feature, without spending the time to
evaluate the existing ~1000 modules which are known to be OK. We're
also cutting off 2 other mechanisms that could cause an Android.mk to
cause files to be copied to the target without involving product
makefiles (modifying ALL_PREBUILT, and modifying PRODUCT_COPY_FILES).
JBQ
> --
> You received this message because you are subscribed to the "Android Building" mailing list.
> To post to this group, send email to android-...@googlegroups.com
> To unsubscribe from this group, send email to
> android-buildi...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-building?hl=en
>
--
Jean-Baptiste M. "JBQ" Queru
Software Engineer, Android Open-Source Project, Google.
Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.