[Moto G 2015 General] :
Im sick of seeing guides around that tell you all about how to build a rom but never ever go into detail about the hardest part in my opinion which is obtaining device specific code, its ridiculous!? So im here to help.

Just a prior note, im a dev, ive built few roms but special thanks to devs like [MENTION=6485916]squid2[/MENTION] [MENTION=3873953]eng.stk[/MENTION] who built a lovely repos for us with lots of good documentation. So please go and give them a thanks on any one of there posts!

Also i would like to personally thank [MENTION=6485916]squid2[/MENTION] for helping me when i asked for info regarding building and errors.

Lets get started shall we! :D

1 - Pre-requisites

4+ GB RAM (I have 8GB)

Preferably a Quad-Core CPU (I have an i7)

At least 100GB of HDD/SSD space for the repo & ccache (SSD recommended for faster compile times, i have a 1TB HDD)

GPU - (not needed but may aswell throw it in here) Radeon HD 7670M & Intel HD 4000

And lastly a Github account, please go make one (its free!) :)

2 - Installing Linux

We need a Linux based 64 bit OS, i use Mint with my own scripts

Download and install it, either dual-boot or use it as your primary OS like the bad-ass you are! (If you want help on doing this there at least +100000 guides in google and youtube alone) :)

3 - Grabbing build dependencies

sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng

Copy & Pasta that code above into your terminal and accept/press ok/press yes to any prompts that appear

That should get your system fit with all the necessary things to build and work with androids source, its about 600MB of a download! So sit back and relax...

4 - Preparing to download the massive source-code

I recommend downloading a small movie before doing this so you can relax while it all syncs! (just be sure to keep your eye on that sync window to make sure its still scrolling...)

Lets make a folder to hold all our stuff:

mkdir -p ~/android/roms/cm && cd ~/android/roms/cm

Now your inside the cm folder, you have to be in the cm directory every-time you want to start building!

Now initiate the cm repo: (one-time thing)

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

Now it might give a small error at the end stating for some email and user id stuff.

So now is the time to add your github infos (run this in terminal):

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

EG:

git config --global user.email "me@vatsalkoradia.com"
git config --global user.name "Vatsal"

We haven't yet downloaded the CM source, but we will in the next part...

(source code is roughly 25GB for CM12.1 , pure AOSP is slightly smaller)

5 - Downloading & waiting

Note: Straight after syncing official CM12.1 repo this is its size: (31GB)

It is time!, run one of the two commands below (depending on your networking speed) to initiate the long wait of syncing!)

repo sync

Finished? sweet, lets have a rave party! :D

6 - Building!

Now once youve downloaded all the source code you should be able to run your first build after init! :D

Thanks to some nice build scripts from CM, running builds is super duper easy! :)

To initialize the last thing, run:

. build/envsetup.sh

then to build run

brunch <device code name> ; (for osprey it will be, [B]brunch osprey [/B])

to build, ive read around and on my system it should only take 1 to 1.5 hours tops, and my system is mediocre + its a laptop so take in account that it may thermally throttle, if you have a desktop it should only take around 1-2 hours with relatively decent specs! :)

7 - Party Time!

If you want help please leave a comment in this thread and i/others will try to help.

Also if you do get a successful build done please share it with us, we would love to be a part of your victory party! :D

Thanks to this guide: Link

&

CM devs again!