Search code examples
androidandroid-source

android build system get the source code path base on package name


I want to get package source code base on package name, eg xxx.apk

I know it could filter by grep LOCAL_PACKAGE_NAME. but the AOSP source was too large.

Is it any build system command could list all package name and path?

Regards


Solution

  • TLDR

    . build/envsetup.sh
    
    # Show list of modules for the selected configuration.
    lunch
    m modules
    
    # Grep for your module.
    mgrep <module>
    

    Explanation

    After calling . build/envsetup.sh you can use mgrep to only grep build configuration files.

    Be aware, that Android currently uses two build configuration types in parallel. The old makefile type files (Android.mk) will contain LOCAL_PACKAGE_NAME. However, the new Soong module files (Android.bp) have a different syntax. You better grep for the module name and not for LOCAL_PACKAGE_NAME.

    You can use m modules to get a list of all modules known to the build system. This command requires you to run lunch first. Also the list returned by m modules will only contain the modules that are selected by the lunch configuration.