As the title is self-explanatory, I'd want to replace some files in system/bin/
and system/lib/
right before when the system.img
is being generated.
To be more exact, I've got some prebuilt .so
files which shuold be copied over the existing ones. For example libart.so
. Please note that replacing art/
(source code of art) with the modified art source code is not an option.
To do this, which mk
file should I investigate and put my replacing code into?
You may follow the same structure as the one proposed in this other question , but use this macro:
PRODUCT_COPY_FILES += \
device/common/my_bin.bin:cache/my_bin.bin \
device/common/my_so.so:system/art/my_so.so
This works as follows:
cache
or system
, it would be generated with the files contained in those folders. system.img
is generated, our file will be contained. Also, the order in which this files are copied, matters. For instance if you are copying a file that already exists, hence, you want it replaced. (As your libart.so
), you would need YOUR call to that copy to be done before the default one.
For this, I recommend doing:
source build/envsetup.sh
lunch <<device>>
mgrep libart.so
-> This does a grep through mk
files, so you can see where the default copy is done. $(info whatever)
calls in desired mk
files to trace where is a good spot to add your PRODUCT_COPY_FILES
. It's not easy to answer where to add it. I have never modified libart.so
myself, but I have copied many files this way and it works like a charm.
I hope it works for your case as well.
A quick dirty way to this:
make snod
Other way is using Android.mk. Create a new dir in device tree eg libart-prebuilt
. Put here your lib, then create an Android.mk file with content
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libart-prebuilt
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
LOCAL_MODULE_STEM := libart
LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX)
LOCAL_SRC_FILES := libart.so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
include $(BUILD_PREBUILT)
Now just add libart-prebuilt
to PRODUCT_PACKAGES
in your device.mk
另外,还有一个选项可以使用.mk文件中的PREBUILT_SHARED_LIBRARY
选项将二进制.so库作为产品包添加: 在Android AOSP或BUILD_PREBUILT
https://stackoverflow.com/a/25682674/1028256中 包含预构建的共享库
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.