[ZenFone 2 General] Niropa:
Well I've been getting a lot of questions on how users can take development into their own hands and start compiling your very own builds of your favorite ROM's. Because of this I have decided to write up a guide that will explain all the steps you need to take to compile a ROM.

NOTE: if your problem is that you cant get your build booting but you already know how to compile ROM's then skip to step 5

Step 1: Install A linux distribution

you will need to be on a linux distribution such as Ubuntu to compile android from source. You can do it on OSX as well but I don't have instructions for that because I haven't done it. So if you aren't on a linux distribution that will be the first thing you need to do. there's thousands of guides online on how to do that so go do that

Step 2: set up the build environment

you will need a lot of packages installed to successfully compile without any errors which ill list here

if you're using ubuntu or another debian based distro then type this in your terminal

sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-6-jdk openjdk-6-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev openjdk-7-jdk android androidsdk-uiautomatorviewer android-copyright android-src-vendor android-emulator android-tools-adb android-headers android-tools-adbd androidsdk-ddms android-tools-fastboot androidsdk-hierarchyviewer android-tools-fsutils androidsdk-traceview yasm

you probably dont need all of those installed but its better to have one extra package then one missing package.

now that you have all the packages needed. its time to set up repo so you are able to sync the sources. type this into your terminal

mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Step 3: getting the ROM sources

time to play the waiting game! For this part of the guide I will explain how to fetch cyanogenmod's sources.

in your home folder, make a folder called cyanogenmod. Now open the folder and open a terminal inside of it.

inside the terminal type

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

now you might get an error that says something like "Error, tell me who you are!" so you are going to want to type

git config --global user.email yourEmail@gmail.com

then

git config --global user.name YourGithubName

you can use fake credentials but i recommend making a git and using your real information.

now run the command once more

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

now it will properly set up the repository. After that type in

repo sync

and wait for all the sources to download. It will probably take a few hours so I suggest you go do something else and come back later.

If you get any errors while syncing type

repo sync -j1 -f

Step 4: set up Zenfone specific sources

now that you have cyanogenmods sources downloaded you will need to add zenfones sources.

you can find the zenfone sources here:

https://github.com/CM-zenfone2

for now go into the .repo folder inside your cyanogenmod folder. you may have to enable "show hidden folders" in your file managers settings to see it. inside of this folder create another one called local_manifests . inside this folder create a file called local_manifest.xml .

now open that xml file with a text editor and paste this into it

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!-- REMOVE AOSP PROJECTS -->
<remove-project name="platform/hardware/intel/common/libmix" path="hardware/intel/common/libmix" />
<remove-project name="platform/hardware/intel/common/libstagefrighthw" path="hardware/intel/common/libstagefrighthw" />
<remove-project name="platform/hardware/intel/common/libva" path="hardware/intel/common/libva" />
<remove-project name="platform/hardware/intel/common/omx-components" path="hardware/intel/common/omx-components" />
<remove-project name="platform/hardware/intel/common/utils" path="hardware/intel/common/utils" />
<remove-project name="platform/hardware/intel/common/wrs_omxil_core" path="hardware/intel/common/wrs_omxil_core" />
<remove-project name="platform/hardware/intel/img/hwcomposer" path="hardware/intel/img/hwcomposer" />
<remove-project name="platform/hardware/intel/img/libdrm" path="hardware/intel/img/libdrm" />
<remove-project name="platform/hardware/intel/img/psb_video" path="hardware/intel/img/psb_video" />

<!-- ADD CM-ZENFONE2 PROJECTS -->
<project name="CM-zenfone2/android_hardware_intel_common_libmix" path="hardware/intel/common/libmix" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_common_libstagefrighthw" path="hardware/intel/common/libstagefrighthw" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_common_libva" path="hardware/intel/common/libva" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_common_omx-components" path="hardware/intel/common/omx-components" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_common_utils" path="hardware/intel/common/utils" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_common_wrs_omxil_core" path="hardware/intel/common/wrs_omxil_core" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_img_hwcomposer" path="hardware/intel/img/hwcomposer" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_img_libdrm" path="hardware/intel/img/libdrm" remote="github" />
<project name="CM-zenfone2/android_hardware_intel_img_psb_video" path="hardware/intel/img/psb_video" remote="github" />

<!-- CM-ZENFONE2 DEVICE PROJECTS -->
<project name="CM-zenfone2/android_device_asus_Z00A" path="device/asus/Z00A" remote="github" />
<project name="CM-zenfone2/android_device_asus_Z008" path="device/asus/Z008" remote="github" />
<project name="CM-zenfone2/android_device_asus_mofd-common" path="device/asus/mofd-common" remote="github" />
<project name="CM-zenfone2/android_kernel_asus_moorefield" path="kernel/asus/moorefield" remote="github" />
<project name="CM-zenfone2/proprietary_vendor_asus" path="vendor/asus" remote="github" />

</manifest>

now save and close that xml file. go back to your terminal in the cyanogenmod folder and run

repo sync -j1 --force-sync

this will now pull in the zenfone files you need.

Zenfone sources are now synced into the official CM github so these steps aren't needed. the only extra thing to do now is:

in your vendor folder

git clone https://github.com/TheMuppets/proprietary_vendor_asus.git -b cm-12.1

then rename the folder to "asus"

Step 5: adding device specific commits

this is probably the step that most people don't do and therefore get builds that won't boot. You need to add 4 A bunch of very important commits to get your ROM properly booting.

commit 1

go inside of your external/tinyalsa folder and open a terminal then type in:

git fetch http://review.cyanogenmod.org/CyanogenMod/android_external_tinyalsa refs/changes/43/103343/1 && git cherry-pick FETCH_HEAD

now close the terminal and go to the folder hardware/intel/img/hwcomposer and open a terminal. type this in:

git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_intel_img_hwcomposer refs/changes/82/117182/1 && git cherry-pick FETCH_HEAD

and

git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_intel_img_hwcomposer refs/changes/83/117183/1 && git cherry-pick FETCH_HEAD

open up hardware/intel/img/libdrm and paste this in the terminal:

git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_intel_img_libdrm refs/changes/01/117201/1 && git cherry-pick FETCH_HEAD

put this in hardware/intel/common/libmix

git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_intel_common_libmix refs/changes/91/117191/1 && git cherry-pick FETCH_HEAD

now go into the folder hardware/ril. Open the terminal and type:

git fetch http://review.cyanogenmod.org/CyanogenMod/android_hardware_ril refs/changes/25/102725/2 && git cherry-pick FETCH_HEAD

now open the frameworks/native folder and type in the terminal:

git fetch http://review.cyanogenmod.org/CyanogenMod/android_frameworks_native refs/changes/36/108636/2 && git cherry-pick FETCH_HEAD

these are the 4 commits that those commands are adding for anybody interested:

https://github.com/TeamEOS/system_core/commit/870fff040f14f4a659807d74419300ef0f223a30

https://github.com/TeamEOS/system_core/commit/7fb271f606394692cbf303f3e7d4889e4ff04369

https://github.com/TeamEOS/hardware_ril/commit/bb9b4e567e5bba35ae380ee0a56833ba385af654

https://github.com/TeamEOS/external_tinyalsa/commit/3bba475d5ad4db3f813ff121ff3d195043307f46

NOTE:New commits for the quick charging UI have been added that you need to add. check post 3 for them

now we have set everything we need properly to build the rom!

Step 6: Start the build

finally, time to start building! open a terminal in the cyanogenmod folder and type

. build/envsetup.sh

now type

brunch Z00A

for Z00A or

brunch Z008

for Z008.

this will also take a while depending on your computers specs (around 4 hours).

When its done you will find the zip in the folder out/target/product/Z00A (or Z008).

you can now put this zip on your device and flash away :)

to update sources and make a new build you can do repo sync and step 5 and 6 again

I hope this guide can help motivate people interested in building to give it a go as well as help grow the community even more then it already is! feel free to post any questions you have here and I will help to the best of my ability. :)