zoukankan      html  css  js  c++  java
  • CM12.1/13.0编译教程

    环境搭建

    1.安装64位Ubuntu系统(实体安装、虚拟机安装均可)

    注意:要求机器至少4G内存(虚拟机至少分配4G内存),硬盘至少100G空间(源码20G+,编译后整个目录约60~70G)
    安装方法请百度~

    2.更新系统至最新版本,在终端下输入

    sudo apt-get update
    sudo 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-dev
    openjdk-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 removed from the official Ubuntu repositories, you have a couple options:

    1. Obtain OpenJDK 1.7 from the openjdk-r PPA
    2. 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: 
    3. 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/cm
    cd ~/android/cm

    2.初始化源码目录

    repo init -u git://github.com/CyanogenMod/android.git -b cm-12.1

    若初始化失败,请参考http://www.cnblogs.com/dinphy/p/5669384.html

    3.添加红米3专用文件目录

    mkdir ~/android/cm/.repo/local_manifests
    gedit ~/android/cm/.repo/local_manifests/ido.xml

    把以下内容复制进去

    <?xml version="1.0" encoding="utf-8"?>
    <manifest>
        <!-- Device repos -->
        <project name="dinphy1205/android_device_xiaomi_ido-cm12.1" path="device/xiaomi/ido" revision="cm-12.1" remote="github" />
        <project name="dinphy1205/proprietary_vendor_xiaomi_ido-12.1" path="vendor/xiaomi" revision="cm-12.1" remote="github" />
        <project name="dinphy1205/android_kernel_xiaomi_msm8916-12.1" path="kernel/xiaomi/ido" revision="cm-12.1" remote="github" />
        <project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" revision="cm-12.1" remote="github" />
        <!-- Other --> 
        <project name="CyanogenMod/android_external_mm-dash" path="external/mm-dash" revision="cm-12.1" remote="github" />
    </manifest>

    13.0的复制如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
        <!-- Device repos -->
        <project path="device/xiaomi/ido" name="dinphy1205/android_device_xiaomi_ido-1" revision="cm-13.0" />
        <project path="kernel/xiaomi/ido" name="dinphy1205/android_kernel_xiaomi_ido" revision="cm-13.0" />
        <project path="vendor/xiaomi/ido" name="dinphy1205/android_vendor_xiaomi_ido-1" revision="cm-13.0" />
          <project path="device/qcom/common" name="CyanogenMod/android_device_qcom_common" revision="cm-13.0" /> 
        <!-- Other --> 
        <project path="external/sony/boringssl-compat" name="CyanogenMod/android_external_sony_boringssl-compat" revision="cm-13.0" /> 
        <project path="external/stlport" name="CyanogenMod/android_external_stlport" revision="cm-13.0" /> 
    </manifest>

    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.sh
    lunch cm_ido-userdebug

    2.编译ROM(我笔记本下面虚拟机花费时间约2小时,取决于个人电脑性能)

    mka ido
    
    or
    
    brunch cm_ido-userbug

    注意:目前编译刚开始出现下面几行是正常现象,不影响的~

    1. find: 'src': No such file or directory
    2. find: 'phone/java': No such file or directory
    3. find: 'dummy': No such file or directory

    再次编译
    1.建议每次编译都要把上一次编译的内容清除,否则有可能出现莫名其妙的问题

    1. make clobber

    2.再次同步源码到最新版本

    repo sync -c -f -j8 --force-sync --no-clone-bundle

    3.初始化编译环境

    . build/envsetup.sh
    lunch 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
  • 相关阅读:
    通过JDBC连接oracle数据库的十大技巧
    asp.net里导出excel表方法汇总
    流式媒体
    html 另存为/打印/刷新/查看原文件等 代码
    JSP 语法详解
    让一个网页打开的同时自动为另一个网页自动填写表单并提交
    StreamWriter输出中文乱码的问题
    “mailto”的六则应用技巧
    返回目录大小
    JDBC基础(二)
  • 原文地址:https://www.cnblogs.com/dinphy/p/5655307.html
Copyright © 2011-2022 走看看