Add a make rule to the main make of AOSP

穿精又带淫゛_ 提交于 2019-12-08 11:14:45

问题


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's mk file in device/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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!