- make: 编译源码,生成相应的系统镜像文件。
- make snod: 重新生成一个system.img系统镜像文件
- make kernel: 编译内核(可选)一般根据envsetup.sh文件内容而论
- m: Makes from the top of the tree(编译全部模块)。
- mm: Builds all of the modules in the current directory(编译当前目录下的所有模块)。
- mmm: Builds all of the modules in the supplied directories(编译指定目录下的所有模块)。
我们可以通过启动模拟器来验证我们是否编译正确 ,注意,我们最好在system.img所在的目录下进行如下动作
~$ emulator -kernel ~/android2.2/prebuilt/android-arm/kernel/kernel-qemu -ramdisk ramdisk.img -debug all -data userdata-qemu.img -system system.img -sysdir . -show-kernel -skin 800x480
如果能正确启动则说明完全编译成功啦。
完全编译完后我们就可以使用make sdk命令做一次SDK的编译拉,步骤如下:
~$ cd ~/android/src
~$ make sdk
注意:如果需要build SDK,随着版本的不同,我们所需的环境也不同,编译android2.2之前的版本需要安装sun-java5-jdk, 而不是sun-java6-jdk,否则会出现如下错误:(略)
sdk编译成功后会在~/android /src/out/host/linux-x86/sdk/ 生成sdk的文件目录和压缩包:
android-sdk_eng.anjoy_linux-x86
android-sdk_eng.anjoy_linux-x86.zip
并在~/android /src/out/target/product/generic(generic是默认的产品名)下打包所有的映像文件:
generic-img-eng.anjoy.zip
生成的SDK目录结构为:
/home/anjoy/android/src/out/host/linux-x86/sdk/android-sdk_eng.anjoy_linux-x86:
总计 32
drwxrwx--- 6 anjoy anjoy 4096 2011-06-27 17:48 .
drwxr-x--- 3 anjoy anjoy 4096 2011-06-27 17:48 ..
drwxrwx--- 2 anjoy anjoy 4096 2011-06-27 17:48 add-ons
drwxrwx--- 14 anjoy anjoy 4096 2011-06-27 17:48 docs
-rw-rw---- 1 anjoy anjoy 172 2011-06-27 17:50 documentation.html
drwxrwx--- 3 anjoy anjoy 4096 2011-06-27 17:48 platforms
-rw-rw---- 1 anjoy anjoy 225 2011-06-27 17:50 RELEASE_NOTES.txt
drwxrwx--- 3 anjoy anjoy 4096 2011-06-27 17:50 tools
想很方便的使用生成的SDK只需要在.bashrc中增加:
export PATH=$PATH:/home/anjoy/android/src/out/host/linux-x86/sdk/android-sdk_eng.anjoy_linux-x86/tools
2.2、模块化编译
注意:在模块化编译之前我们一定要把envsetup.sh 脚本source 一下,或者你直接把envsetup.sh文件所在的路径配置到你个人的bashrc文件里面,这样你就不要每次都作source动作拉。
envsetup.sh 提供了一些的bash函数定义,当运行了envsetup.sh后就可以使用help 命令来查看:
~$ help
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- 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.
- mmm : Builds all of the modules in the supplied directories.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Gr