第一次下载好Android源代码工程后,我们通常是在Android源代码工程目录下执行make命令,经过漫长的等待之后,就可以得到Android系统镜像system.img了。以后如果我们修改了Android源代码中的某个模块或者在Android源代码工程新增一个自己的模块,是不是还是执行make命令呢?答案是否定的,Google为我们准备了另外的命令来支持编译单独的模块,以及重新打包system.img的命令。在继续学习Android源代码之前,就让我们先来看看这个命令吧。
一. 首先在Android源代码目录下的build目录下,有个脚本文件envsetup.sh,执行这个脚本文件后,就可以获得一些有用的工具:
USER-NAME@MACHINE-NAME:~/Android$ . ./build/envsetup.sh
注意,这是一个source命令,执行之后,就会有一些额外的命令可以使用:
- croot: Changes directory to the top of the tree.
Android比较重要的三个img文件:
make systemimage - system.img
make userdataimage -userdata.img
make ramdisk - ramdisk.img
make snod - 快速打包system.img
(with thiscommand, it will build a new system.img very quickly. well, youcannot use “make snod” for all the situations. it would not checkthe dependences. if you change some code in the framework whichwill effect other applications)
因為
system.img 是 從 out/target/product/xxxx/system 做出來的。
如果改了 這個 folder 的內容,想要重新產生 system.img。不要管 system folde 裡面的 file 的dependency,可以用 snod 這個 target:
make snod