编译Nexus 7 源码的流程

运行环境:

ubuntu 10.04 64-bit

源修改:

sudo gedit etc/apt/sources.list

将源修改为速度较快的163源
deb http://mirrors.163.com/ubuntu/ lucid main universe restricted multiverse
deb-src http://mirrors.163.com/ubuntu/ lucid main universe restricted multiverse
deb http://mirrors.163.com/ubuntu/ lucid-security universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ lucid-security universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ lucid-updates universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ lucid-proposed universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ lucid-proposed universe main multiverse restricted
deb http://mirrors.163.com/ubuntu/ lucid-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ lucid-backports universe main multiverse restricted
deb-src http://mirrors.163.com/ubuntu/ lucid-updates universe main multiverse restricted

文章参考
http://forum.xda-developers.com/showthread.php?t=1386615


编译过程

一、搭建编译环境

1.root权限
sudo -i
2.添加JAVA源
add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse"
3.更新源列表
apt-get update
4.安装JAVA
apt-get install sun-java6-jdk
5.安装python
apt-get install python
6.安装git
apt-get install git-core
7.安装其他组件
apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils

二、安装和初始化repo

这一部分可以参考安卓源码http://source.android.com/source/downloading.html中的方法继续
8.取消证书认证
git config --global http.sslVerify false
9.下载repo

$ mkdir ~/bin
$ PATH=~/bin:$PATH

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo -k
chmod a+x ~/bin/repo
-k是为了取消证书认证,这里必须用https,否则会出错;然后修改repo的执行权限
10.创建工作目录,JB代表Jelly Bean,等等
mkdir JB_SOURCE
cd JB_SOURCE
11.更新repo列表
repo init -u http://android.googlesource.com/platform/manifest -b android-4.1.1_r4
这里用的是http而非原文中的https,也是为了取消证书认证,避免下载时出错

三、下载源码
12.下载源码
repo sync

四、下载驱动文件
13.下载驱动文件
到https://developers.google.com/android/nexus/drivers下载所需对应的机型的驱动文件
下载后使用
sudo nautilus
启动拥有root权限的文件管理器,复制到之前建立的工作目录,运行
sh 文件名.sh
进行安装,这些驱动都会安装到vendor文件夹
14.设置编译环境
source build/envsetup.sh 或

           .  build/envsetup.sh  前面有个 点+空格

五、编译
15.选择编译对应的机型
lunch
对应的机型说明代码如下
Nexus S ("crespo")
Nexus S 4G ("crespo4g")
Motorola Xoom (US Wi-Fi) ("wingray")
Galaxy Nexus (GSM/HSPA+) ("maguro")
Galaxy Nexus (Verizon) ("toro")
Nexus 7 ("grouper")

PandaBoard ("panda")


/*************************************************************

lenovo@ThinkPad:~/WORKING_DIRECTORY$ lunch

You're building on Linux

Lunch menu... pick a combo:
     1. full-eng
     2. full_x86-eng
     3. vbox_x86-eng
     4. full_grouper-userdebug
     5. mini_armv7a_neon-userdebug
     6. mini_armv7a-userdebug
     7. full_wingray-userdebug
     8. full_crespo-userdebug
     9. full_maguro-userdebug
     10. full_panda-userdebug

Which would you like? [full-eng] 4   //nexus  7选四

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.1.1
TARGET_PRODUCT=full_grouper
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-2.6.32-42-generic-x86_64-with-Ubuntu-10.04-lucid
HOST_BUILD_TYPE=release
BUILD_ID=JRO03C
OUT_DIR=out
============================================

****************************************************************************/


16.开始编译
有两种方式,第一种是输出img格式:
make -j4  // -j? 看你电脑的线程数了,编内核普通电脑要很长时间,我的电脑编了一下午
第二种是输出.zip格式,后者更通用,比如使用第三方recovery的CWM也可以使用:
make -j4 otapackage

你可能感兴趣的:(Android)