android 常见的AOSP命令

在build/envsetup.sh定义了一些函数供我们直接使用

Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch:   lunch <product_name>-<build_variant>
- tapas:   tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
- croot:   Changes directory to the top of the tree.
- m:       Makes from the top of the tree.
- mm:      Builds all of the modules in the current directory, but not their dependencies.
- mmm:     Builds all of the modules in the supplied directories, but not their dependencies.
           To limit the modules being built use the syntax: mmm dir/:target1,target2.
- mma:     Builds all of the modules in the current directory, and their dependencies.
- mmma:    Builds all of the modules in the supplied directories, and their dependencies.
- cgrep:   Greps on all local C/C++ files.
- ggrep:   Greps on all local Gradle files.
- jgrep:   Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- mangrep: Greps on all local AndroidManifest.xml files.
- sepgrep: Greps on all local sepolicy files.
- sgrep:   Greps on all local source files.
- godir:   Go to the directory containing a file.

//......

在AOSP对应的源码目录下执行下面脚本

. build/envsetup.sh

执行完毕之后,就可以使用相应的命令了

gettop 获取WORKING_DIRECTORY目录的完整路径
croot 回到WORKING_DIRECTORY目录
mm 编译当前目录下的模块,比如在package/Calculator目录下执行mm就是编译Calculator.apk
cgrep 执行grep命令,但只匹配C/C++的源文件
jgrep 执行grep命令,但只匹配java源文件
resgrep 执行grep命令,但只匹配路径名为res下的xml资源文件
godir 去某个文件所在的目录

欢迎关注微信公众号:DroidMind
精品内容独家发布平台


呈现与博客不一样的技术干货

### 编译 Android 13 AOSP 源码 #### 准备工作环境 为了顺利编译 Android 13 的 AOSP 源码,建议在一个干净的 Ubuntu 20.04 LTS 环境中操作。确保已经安装了必要的依赖包和工具链[^3]。 ```bash sudo apt-get update && sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 libncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig ``` #### 安装 Repo 工具并初始化仓库 Repo 是 Google 开发的一个 Python 脚本,用于管理多个 Git 项目。通过它可以从 GitHub 或其他托管服务获取整个 Android 源树。 ```bash mkdir ~/bin PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo ``` 创建一个新的文件夹来保存源代码: ```bash mkdir ~/aosp cd ~/aosp repo init -u https://android.googlesource.com/platform/manifest -b android-13.0.0_rXX # XX代表具体的修订版本号 repo sync --no-tags --no-clone-bundle ``` #### 配置构建环境变量 进入源码根目录设置环境变量以便后续命令能够正常执行: ```bash source build/envsetup.sh lunch aosp_arm-eng ``` `lunch` 命令会配置一系列默认参数,其中 `eng` 表示开发者模式,适合调试;而 `userdebug` 则介于两者之间,更接近生产环境但仍保留一些日志输出功能[^1]。 #### 执行实际编译流程 当一切准备就绪后就可以启动编译过程了。这一步可能耗时较长取决于机器性能以及网络状况等因素影响。 ```bash m -j$(nproc) ``` 上述指令利用多线程加速编译速度(`-j`)选项指定了使用的 CPU 核心数,通常设为当前系统的最大核心数量可以加快进度[^4]。 #### 获取编译成果 一旦编译顺利完成,最终生成的镜像文件将会位于 `out/target/product/<device>/` 文件夹内,具体路径视所选设备型号不同有所变化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值