AOSP常用命令

这里介绍的命令主要是build/envsetup.sh中定义的一些命令:


envsetup.sh.png

这些命令对应的都是envsetup.sh里面的一些函数

1.gettop:获取工作目录的绝对路径
当我们所处的目录层级较深是想切换到其他目录是可以使用这个目录,比如我们想切换到frameworks目录下可以使用cd $(gettop)/frameworks

  1. croot:直接切换到工作目录的根目录下
function croot()
{
    local T=$(gettop)
    if [ "$T" ]; then
        if [ "$1" ]; then
            \cd $(gettop)/$1
        else
            \cd $(gettop)
        fi
    else
        echo "Couldn't locate the top of the tree.  Try setting TOP."
    fi
}
  1. mm:编译当前目录下的模块
function mm()
{
    local T=$(gettop)
    # If we're sitting in the root of the build tree, just do a
    # normal build.
    if [ -f build/soong/soong_ui.bash ]; then
        _wrap_build $T/build/soong/soong_ui.bash --make-mode $@
    else
        # Find the closest Android.mk file.
        local M=$(findmakefile)
        .....
}
function findmakefile()
{
    local TOPFILE=build/make/core/envsetup.mk
    local HERE=$PWD
    local T=
    while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
        T=`PWD= /bin/pwd`
        if [ -f "$T/Android.mk" -o -f "$T/Android.bp" ]; then
            echo $T/Android.mk
            \cd $HERE
            return
        fi
        \cd ..
    done
    \cd $HERE
}

mm中主要是通过findmakefile查找Android.mk,然后根据配置进行编译

  1. cgrep:执行grep命令,但只匹配c/c++文件
function cgrep()
{
    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) \
        -exec grep --color -n "$@" {} +
}
  1. jgrep:执行grep命令,但只匹配java文件

  2. resgrep:执行grep命令,但只匹配res文件

  3. godir:去某一个目录,第一次执行会将AOSP的所有目录路径保存到filelist文件中
    如我想直接进入到ActivityManagerService.java的目录下,可以使用这个命令

$ godir ActivityManagerService.java
$ pwd
/Volumes/M1/aosp/android9.0/frameworks/base/services/core/java/com/android/server/am
$
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Tcp/IP通信也是不安全的,在传输的时候也可能出现漏洞 查看正在运行的进程 adb shell ps -A |g...
    远远飘着云阅读 5,320评论 0 0
  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 4,802评论 0 5
  • (一)基本命令 命令格式: 命令 参数 1.ls 显示文件名,等同于dos下dir命令 命令格式:ls [opti...
    飞羽孟德阅读 2,113评论 0 3
  • 一、文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件)ls -a 列出当前目录文件(包括隐含文件)l...
    路痴千行阅读 2,679评论 0 5
  • 进入带空格的文件或者文件夹 Linux文件权限详解 文件和目录权限概述 在linux中的每一个文件或目录都包含有访...
    annkee阅读 2,843评论 0 4

友情链接更多精彩内容