Android编译执行envsetup.sh,产生工具命令m、mm、mmm、mmma、tapas 、croot、cgrep、jgrep、 resgrep、godir
一般来说编译一个sdk或者一个比较大的工程项目,第一步都是执行 envsetup.sh这个脚本,比如编译android,qt源码以及其他一些嵌入式的sdk。
而且执行的时候需要特别注意使用
source build/envsetup.sh
或者
. ./build/envsetup.sh
特别注意两个点之间是有空格的,这个作用相当于source。
==========================================补课开始=====================================================================
一般执行shell脚本时直接用./来执行,此时是系统启动一个子shell进程来执行命令,执行完后返回最后一条指令的结果(可以用echo $?来获取执行结果值(0-255)),其结果并不会对当前的BASH产生影响。
source命令的用法:
source FileName
他的作用是在当前bash环境下读取并执行FileName中的指令,这个命令执行完之后会把FileName执行过程中的一些输出设置到当前的BASH中,也就设置环境变量。
需要注意的是用source执行新产生的这些变量的作用范围(作用域)只是在当前终端有用,如果你关闭当前终端了,或者在其他终端是无法使用这些新增的变量的。
==========================================补课结束=====================================================================
当我们用source命令执行完encsetup.sh的时候,里面设置的一些变量(方法)就会输出到当前的BASH环境中,在后续的过程中我们就可以在当前终端使用这些变量,比如用android的envsetup.sh来说,执行完后会增加一些shell cmd及环境变量可以使用
输入hmm可以看到以下帮助信息
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] [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.
- 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.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file. Look at the source to view more functions. The complete list is:
addcompletions add_lunch_combo cgrep check_product check_variant choosecombo chooseproduct choosetype choosevariant cproj croot findmakefile gdbclient gdbwrapper get_abs_build_var getbugreports get_build_var getlastscreenshot getprebuilt getscreenshotpath getsdcardpath gettargetarch gettop godir hmm isviewserverstarted jgrep key_back key_home key_menu lunch _lunch m mangrep mm mma mmm mmma pez pid printconfig print_lunch_menu qpid resgrep runhat runtest sepgrep set_java_home setpaths set_sequence_number set_stuff_for_environment settitle smoketest stacks startviewserver stopviewserver systemstack tapas tracedmdump
liuxueneng@airfly-dev:~/workCode/allwinner_h2_2018-0907/android$ source build/envsetup.sh
find Makefile
including device/generic/mips/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/softwinner/common/vendorsetup.sh
including device/softwinner/dolphin-fvd-p1/vendorsetup.sh
liuxueneng@airfly-dev:~/workCode/allwinner_h2_2018-0907/android$ hmm
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] [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.
- 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.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file. Look at the source to view more functions. The complete list is:
addcompletions add_lunch_combo cgrep check_product check_variant choosecombo chooseproduct choosetype choosevariant cproj croot findmakefile gdbclient gdbwrapper get_abs_build_var getbugreports get_build_var getlastscreenshot getprebuilt getscreenshotpath getsdcardpath gettargetarch gettop godir hmm isviewserverstarted jgrep key_back key_home key_menu lunch _lunch m mangrep mm mma mmm mmma pez pid printconfig print_lunch_menu qpid resgrep runhat runtest sepgrep set_java_home setpaths set_sequence_number set_stuff_for_environment settitle smoketest stacks startviewserver stopviewserver systemstack tapas tracedmdump
liuxueneng@airfly-dev:~/workCode/allwinner_h2_2018-0907/android$
这些命令都是在android/build/envsetup.sh中定义输出的,可以打开看下
export ROOT_DIR=${PWD}
MAKEFILE=$ROOT_DIR/Makefile
if [ -f $MAKEFILE ]; then
echo "find Makefile"
else
echo "copy Makefile"
cp $ROOT_DIR/build/core/root.mk $ROOT_DIR/Makefile
fi
function hmm() {
cat <<EOF
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] [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.
- 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.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file. Look at the source to view more functions. The complete list is:
EOF
T=$(gettop)
local A
A=""
for i in `cat $T/build/envsetup.sh | sed -n "/^function /s/function \([a-z_]*\).*/\1/p" | sort`; do
A="$A $i"
done
echo $A
} # Get the value of a build variable as an absolute path.
function get_abs_build_var()
{
T=$(gettop)
if [ ! "$T" ]; then
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
return
fi
(\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
make --no-print-directory -C "$T" -f build/core/config.mk dumpvar-abs-$1)
}
这些方法还有一些变量都会输出到当前的BASH环境中,输入env指令就可以打印出当前BASH下的所有环境变量
liuxueneng@airfly-dev:~/workCode/allwinner_h2_2018-0907/android$ env
XDG_SESSION_ID=13509
TERM=xterm
SHELL=/bin/bash
SSH_CLIENT=192.168.11.102 1097 22
OLDPWD=/home/liuxueneng
SSH_TTY=/dev/pts/26
USER=liuxueneng
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
ROOT_DIR=/home/liuxueneng/workCode/allwinner_h2_2018-0907/android
MAIL=/var/mail/liuxueneng
PATH=/home/liuxueneng/bin:/home/liuxueneng/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=/home/liuxueneng/workCode/allwinner_h2_2018-0907/android
LANG=en_HK.UTF-8
SHLVL=1
HOME=/home/liuxueneng
LANGUAGE=en_HK:en
LOGNAME=liuxueneng
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
SSH_CONNECTION=192.168.11.102 1097 192.168.11.111 22
LESSOPEN=| /usr/bin/lesspipe %s
XDG_RUNTIME_DIR=/run/user/1006
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
其中我们可以看到至少以下两个变量是执行刚才的envsetup.sh输出来的
ROOT_DIR=/home/liuxueneng/workCode/allwinner_h2_2018-0907/android
联系以上的的croot指令就是改变当前工作目录的哦ROOT_DIR中。
另外还可以查看输出到当前BASH环境中的临时shell方法,输入set指令来查看(小心会有一大堆东西喷出来)
tracedmdump ()
{
T=$(gettop);
if [ ! "$T" ]; then
echo "Couldn't locate the top of the tree. Try setting TOP.";
return;
fi;
local prebuiltdir=$(getprebuilt);
local arch=$(gettargetarch);
local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu;
local TRACE=$1;
if [ ! "$TRACE" ]; then
echo "usage: tracedmdump tracename";
return;
fi;
if [ ! -r "$KERNEL" ]; then
echo "Error: cannot find kernel: '$KERNEL'";
return;
fi;
local BASETRACE=$(basename $TRACE);
if [ "$BASETRACE" = "$TRACE" ]; then
TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE;
fi;
echo "post-processing traces...";
rm -f $TRACE/qtrace.dexlist;
post_trace $TRACE;
if [ $? -ne 0 ]; then
echo "***";
echo "*** Error: malformed trace. Did you remember to exit the emulator?";
echo "***";
return;
fi;
echo "generating dexlist output...";
/bin/ls $ANDROID_PRODUCT_OUT/system/framework/*.jar $ANDROID_PRODUCT_OUT/system/app/*.apk $ANDROID_PRODUCT_OUT/data/app/*.apk 2> /dev/null | xargs dexlist > $TRACE/qtrace.dexlist;
echo "generating dmtrace data...";
q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return;
echo "generating html file...";
dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return;
echo "done, see $TRACE/dmtrace.html for details";
echo "or run:";
echo " traceview $TRACE/dmtrace"
}
treegrep ()
{
find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
}
verity_file_init ()
{
echo "verity_file_init";
cp -rf $DEVICE/verity ${OUT};
$DEVICE/verity/gen_file_verify_block.sh ${OUT}/system;
cp -f ${OUT}/verity/verity_block ${OUT}/verity_block.img
}
verity_key_init ()
{
$DEVICE/verity/gen_dm_verity_key.sh;
cp -f $DEVICE/verity/rsa_key/verity_key $OUT/root
}
以上treegrep tracedmdump等shell方法都是从envsetup.sh输出来的。
后续讲解下输出的m mm mmm mmma croot cgrep 等作用及用法。
Android编译执行envsetup.sh,产生工具命令m、mm、mmm、mmma、tapas 、croot、cgrep、jgrep、 resgrep、godir的更多相关文章
- Android 经常使用工作命令mmm,mm,m,croot,cgrep,jgrep,resgrep,godir
官方定义: Invoke ". build/envsetup.sh" from your shell to add the following functions to your ...
- android平台的三个编译命令——make,mm,mmm
在Android源码根目录下,执行以下三步即可编译android: 1. build/envsetup.sh #这个脚本用来设置android的编译环境; 2. lunch #选择编译目标 3 ...
- build/envsetup.sh 生成的命令详解表
参考: https://wiki.cyanogenmod.org/w/Envsetup_help 它是一个.sh文件,用source后就生成android编译相关函数,具体如下. 速查 Invokin ...
- 【转】Android源代码编译命令m/mm/mmm/make分析--不错
原文网址:http://blog.csdn.net/luoshengyang/article/details/19023609 在前文中,我们分析了Android编译环境的初始化过程.Android编 ...
- 【转】Android source build/envsetup.sh学习笔记
原文网址:http://blog.csdn.net/mliubing2532/article/details/7567164 如果你只需要修改某一个模块的内容,但是却每次都要执行make, 最后等待很 ...
- Android编译详解之lunch命令 【转】
本文转载自: Android编译详解之lunch命令 (2012-10-08 10:27:55) 转载▼ 标签: it 分类: android内核剖析 Android的优势就在于其开源,手机和 ...
- Android编译过程详解(二)
通过上篇文章,我们分析了编译android时source build/envsetup.sh和lunch命令,在执行完上述两个命令后, 我们就可以进行编译android了. 1. make 执行ma ...
- Android 编译时:m、mm、mmm、mma、mmma的区别
m:编译整个安卓系统 makes from the top of the tree mm:编译当前目录下的模块,当前目录下需要有Android.mk这个makefile文件,否则就往上找最近的Andr ...
- android编译遇到问题修改
(注意要确定安装了jdk) 第一步: cd lichee; ./build.sh -p sun5i_elite -k 3.0 (apt-get install uboot-mkimage需要安装 ...
随机推荐
- java.net.NoRouteToHostException: 无法指定被请求的地址
今天压力测试时, 刚开始出现了很多异常, 都是 java.net.NoRouteToHostException: Cannot assign requested address. 经网上查资料, 是 ...
- php 设计模式 --组合器模式
PHP 开启错误显示并设置错误报告级别 ini_set('error_reporting', E_ALL); ini_set('display_errors', 'on'); 目的:分级处理:整体 ...
- php-抽象工厂
目标:创建有依赖关系的实例;(套餐) <?php //抽象类 食物 interface IAllayFood { function Allay(); } interface IDrinkFood ...
- 一文让你快速入门pytest框架
pytest是什么 官方文档描述: pytest is a framework that makes building simple and scalable tests easy. Tests ar ...
- curl 理解
PHP使用CURL详解 CURL是一个非常强大的开源库,支持很多协议,包括HTTP.FTP.TELNET等,我们使用它来发送HTTP请求.它给我 们带来的好处是可以通过灵活的选项设置不同的HTTP ...
- mapper-spring-boot-starter 主要作用是
今天是第一次接触到 这个场景启动器内心中真是一片的茫然,学习了这么长时间我居然还不知道有这个的存在今天好好查一查资料 参考资料(https://blog.csdn.net/crq1205/articl ...
- GitHub 和 Gitee 开源免费 10 个超赞后台管理面板,看完惊呆了!
软件工程师在实际项目开发中不可避免需要依赖一些前后端的后台管理系统框架,而不是从零开始一点点的搭建,浪费人力.目前市面上有很多开放源码.且免费的后台管理面板,样式色彩也比较丰富美观. 今天整理 ...
- Unity Event Trigger 事件响应(二维,三维)添加组件
EventTrigger 上主要的方法有PointerEnter.PointerExit.PointerDown.PointerUp.PointerClick............都会显示在面板上面 ...
- MySQL MVCC原理深入探索
一.MVCC的由来 二.MVCC的实际应用 RR级别场景 RC级别场景 三.MVCC的实现 3.1 多版本的数据从哪里来--Undo Log 3.1.1 插入操作对应的undo log 3.1.2 删 ...
- Netty常用招式——ChannelHandler与编解码
本文是Netty系列第8篇 上一篇文章我们深入学习了Netty逻辑架构中的核心组件ChannelHandler和ChannelPipeline,并介绍了它在日常开发使用中的最佳实践.文中也提到了,Ch ...