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.