Android 常见编译命令
Android 10 根文件系统和编译系统(三):Android 常见编译命令
https://blog.csdn.net/ldswfun/article/details/119787881
配套系列教学视频链接:
Android 10.0 AOSP源码编译:https://edu.csdn.net/course/detail/35479
Android 10.0 根文件系统和编译系统:https://edu.csdn.net/course/detail/35480
说明
系统:AOSP Android10.0
设备:Android模拟器
前言
本章节重点介绍Android源码中进行编译时,所需要用到各种编译命令。
一, 代码编译
编译指令
解释
hmm
帮助命令
m
在源码树的根目录执行编译
mm
编译当前路径下所有模块,但不包含依赖
mmm [module_path]
编译指定路径下所有模块,但不包含依赖
mma
编译当前路径下所有模块,且包含依赖
mmma [module_path]
编译指定路径下所有模块,且包含依赖
make [module_name]
无参数,则表示编译整个Android代码,否则就是编译特定模块
建议:首次编译时采用make/mma/mmma编译;当依赖模块已经编译过的情况,则使用mmm/mm编译
二, 模块的编译指令
模块
make 命令
mmm命令
init
make init
mmm system/core/init
zygtoe
make app_process
mmm frameworks/base/cmds/app_process
system_server
make services
mmm frameworks/base/services
Java framework
make framework
mmm frameworks/base
framework资源
make framework-res
mmm frameworks/base/core/res
jni framework
make libandroid_runtime
mmm frameworks/base/core/jni
Binder
make libbinder
mmm frameworks/native/libs/binder
Settings
make Settings
mmm packages/apps/Settings
三,清除命令
编译指令
解释
make installclean
删除out/target/product/产品/中的所有img文件, system,vendor,data,相关文件, 保留中间文件
如:out/target/product/产品/obj/等
make clean
彻底删除,相当于rm –rf out/, make clobber有一样的效果
make clean-模块
清楚单个特定模块, 时间比较慢,最好多线程编译, 也可以直接用 rm删除
如删除某个内置apk:
rm -rf out/target/product/产品/obj/APPS/app的名字
rm –rf out/target/product/产品/system/app/app 名字
四,搜索命令
搜索命令
解释
cgrep [keyword]
所有C/C++文件执行搜索操作
jgrep [keyword]
所有Java文件执行搜索操作
ggrep [keyword]
所有Gradle文件执行搜索操作
mgrep [keyword]
所有Android.mk文件执行搜索操作
sepgrep [keyword]
所有sepolicy文件执行搜索操作
resgrep [keyword]
所有本地res/*.xml文件执行搜索操作
五, 编译配置命令
搜索命令
解释
check_product [product]
检查产品是否有效
get_abs_build_var [build_var]
获取系统中的编译变量的值
printconfig
打印当前选择的产品配置
add_lunch_combo [product]
将某个产品加入到用户选项中
六,镜像的编译指令
模块
make 命令
boot.img
make bootimage
system.img
make systemimage
或者make snod(更快的直接生成system.img, 不管out/target/product/xx/system是否有变化)
ramdisk.img
make ramdisk
userdata.img
make userdataimage
super.img
make superimage
或者make supernod(更快的直接生成super.img, 不管文件是否有变化)
总结
Android命令比较多,基本都是通过build/envsetup.sh这个脚本中产生, 感兴趣的朋友,可以直接去读取脚本内容。
————————————————
版权声明:本文为CSDN博主「旗浩QH」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ldswfun/article/details/119787881
http://aospxref.com/android-14.0.0_r2/xref/build/make/help.sh
#!/bin/bash
# locate some directories
cd "$(dirname $0)"
SCRIPT_DIR="${PWD}"
cd ../..
TOP="${PWD}"
message='The basic Android build process is:
cd '"${TOP}"'
source build/envsetup.sh # Add "lunch" (and other utilities and variables)
# to the shell environment.
lunch [<product>-<variant>] # Choose the device to target.
m [<goals>] # Execute the configured build.
Usage of "m" imitates usage of the program "make".
See '"${SCRIPT_DIR}"'/Usage.txt for more info about build usage and concepts.
The parallelism of the build can be set with a -jN argument to "m". If you
don'\''t provide a -j argument, the build system automatically selects a parallel
task count that it thinks is optimal for your system.
Common goals are:
clean (aka clobber) equivalent to rm -rf out/
checkbuild Build every module defined in the source tree
droid Default target
sync Build everything in the default target except the images,
for use with adb sync.
nothing Do not build anything, just parse and validate the build structure
java Build all the java code in the source tree
native Build all the native code in the source tree
host Build all the host code (not to be run on a device) in the source tree
target Build all the target code (to be run on the device) in the source tree
(java|native)-(host|target)
(host|target)-(java|native)
Build the intersection of the two given arguments
snod Quickly rebuild the system image from built packages
Stands for "System, NO Dependencies"
vnod Quickly rebuild the vendor image from built packages
Stands for "Vendor, NO Dependencies"
pnod Quickly rebuild the product image from built packages
Stands for "Product, NO Dependencies"
senod Quickly rebuild the system_ext image from built packages
Stands for "SystemExt, NO Dependencies"
onod Quickly rebuild the odm image from built packages
Stands for "Odm, NO Dependencies"
vdnod Quickly rebuild the vendor_dlkm image from built packages
Stands for "VendorDlkm, NO Dependencies"
odnod Quickly rebuild the odm_dlkm image from built packages
Stands for "OdmDlkm, NO Dependencies"
sdnod Quickly rebuild the system_dlkm image from built packages
Stands for "SystemDlkm, NO Dependencies"
So, for example, you could run:
cd '"${TOP}"'
source build/envsetup.sh
lunch aosp_arm-userdebug
m -j java
to build all of the java code for the userdebug variant of the aosp_arm device.
'
echo "$message"

浙公网安备 33010602011771号