环境搭建 1.安装64位Ubuntu系统(实体安装、虚拟机安装均可)
注意:要求机器至少4G内存(虚拟机至少分配4G内存),硬盘至少100G空间(源码20G+,编译后整个目录约60~70G) 安装方法请百度~ 2.更新系统至最新版本,在终端下输入sudo apt-get updatesudo apt-get upgrade
3.安装编译必需软件包
sudo apt-get install
For both 32-bit & 64-bit systems, you'll need:
bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev → lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev → libwxgtk3.0-devopenjdk-7-jdk → openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
- CyanogenMod 7 - 9: Sun/Oracle Java SE 1.6
- CyanogenMod 10.1: Sun/Oracle Java SE 1.6 or 1.7
- CyanogenMod 10.2 - 11.0: Sun/Oracle Java SE 1.6 or 1.7 (OpenJDK 1.7 works fine, but the build system will display a warning)
- CyanogenMod 12.0 - 13.0: OpenJDK 1.7 (see note about OpenJDK 1.8 below)
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was from the official Ubuntu repositories, you have a couple options:
- Obtain OpenJDK 1.7 from the
- Enable experimental OpenJDK 1.8 support in CyanogenMod 13.0 (not available in earlier version). To enable OpenJDK 1.8 support, add this line to your
$HOME/.bashrc
file: -
export EXPERIMENTAL_USE_JAVA8=true
4.建立repo命令
mkdir -p ~/bin
curl https://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo echo "export PATH=~/bin:$PATH" >> ~/.bashrc
注意,第二行要从谷歌那里下载repo小程序,国内网络你懂的,可以在浏览器上面挂个代理通过以下地址下载好,拷贝到~/bin/repo,再执行第三行和第四行命令,当然,最好的办法是:
同步源码
1.新建一个储存源码的文件夹,这里以~/android/cm为例
mkdir ~/android/cmcd ~/android/cm
2.初始化源码目录
repo init -u git://github.com/CyanogenMod/android.git -b cm-12.1
若初始化失败,请参考
3.添加红米3专用文件目录
mkdir ~/android/cm/.repo/local_manifestsgedit ~/android/cm/.repo/local_manifests/ido.xml
把以下内容复制进去
13.0的复制如下:
4.针对国内网络环境的处理(略自己使用VPN或者SS,教程请百度)
5.拉取代码(需要下载约十几个G的内容,花费时间参考各自网速)
repo sync -c -f -j8 --force-sync --no-clone-bundle
如果中间断网了,或者出错了,重新repo sync一下就可以继续了~
6.获取预编译的部分文件
cd ~/android/cm/vendor/cm./get-prebuilts
如果已经有了,这步跳过
编译ROM
1.初始化编译环境cd ~/android/cm. build/envsetup.shlunch cm_ido-userdebug
2.编译ROM(我笔记本下面虚拟机花费时间约2小时,取决于个人电脑性能)
mka idoorbrunch cm_ido-userbug
注意:目前编译刚开始出现下面几行是正常现象,不影响的~
- find: 'src': No such file or directory
- find: 'phone/java': No such file or directory
- find: 'dummy': No such file or directory
再次编译
1.建议每次编译都要把上一次编译的内容清除,否则有可能出现莫名其妙的问题- make clobber
2.再次同步源码到最新版本
repo sync -c -f -j8 --force-sync --no-clone-bundle
3.初始化编译环境
. build/envsetup.shlunch cm_ido-userdebug
4.编译ROM
mka ido
一点贴士
1、机型文件device、kernel、vendor放置路径
1)device
device/xiaomi/ido
2)kernel
kernel/xiaomi/msm8916
3)vendor
vendor/xiaomi/ido
2、开启ccache,加速编译过程
$ echo "export USE_CCACHE=1" >> ~/.bashrc$ ~/cm/prebuilts/misc/linux-x86/ccache/ccache -M 50G