问题
I've added a new C++ subproject at frameworks/base/cmds/myproject
and it has its own Android.mk
file. When I run make myproject
, it'll compile well and no problem.
However I want to add make myproject
to the main make
. I mean, when someone runs make
at the root of AOSP, my project to be included as well. What should I do?
回答1:
You need your Android.mk
file to be called. There are various ways to do so, depending on your needs.
If you want your myproyect
to be compiled for several of the devices you have under device/
, then look for a common mk
file. For example this is how Qualcomm does it, you can copy it for AOSP.
- Edit/create
device/common/common.mk
- Make calls to that
device/common/common.mk
from every device you want to. (This is how QCM does it:$(call inherit-product, device/qcom/common/common.mk)
If you want it just for a specific device:
- Let's take for granted you want to compile for
mini_emulator_x86-userdebug
, which has it'smk
file indevice/generic/mini-emulator-x86
. - Edit
mini_emulator_x86.mk
Edit or add
PRODUCT_PACKAGES
as follows:PRODUCT_PACKAGES += \ myproyect
Watch out for correct indentation.
This way, when you do source build/envsetup.sh
and lunch mini_emulator_x86-user
and then make
, your myproyect.mk
will be reached.
In order to test it:
- Edit your
myproject.mk
file by adding something like this:$(warning MyProject MK has been called
- Call
lunch mini_emulator_x86-user
. make | grep MyProject
and you don't need to wait for the whole compilation, if this outputs something in the first seconds, you're good to go.
For additional reference you may take a look at how Qualcomm organizes their device
folder, with common
and base
mk files. Take a look at their open source code here
来源:https://stackoverflow.com/questions/44491663/add-a-make-rule-to-the-main-make-of-aosp