[myTouch 4G Android Development] sykopompos:
Compiling cyanogenmod 7 source

Now we work on actually pulling sources and compiling source code. Since Cyanogenmod 7 is the most popular we will work with this (as of writing 1/15/11, cm7 source does not have a Rc1 yet so non official builds after the bacon script has the KANG attached to them)

So let’s pull cm7, open a terminal and type these commands

(you can name your source folder whatever you like but for guide purposes it will be cm7)

(make sure you are at ~)

mkdir cm7

cd cm7

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

It will ask you to enter your name and email (this is completely optional and you can just press enter to skip)

Press y and enter to confirm that your identity is correct, press y again to enable user color

You will now see repo initialized in our in our cm7 folder

Now we can use repo sync (this acts as a git clone to copy the source to our local branch)

In the terminal type

repo sync

This will take a while to download depending on your internet connection since it is pulling in over 2gb of source code (don’t use tethering during this as it will eat up your data for the month)

(you can use -j`grep 'processor' /proc/cpuinfo | wc -l` to run at full cpu speed. -j# (# means twice the amount of cores in your computer) means jobs. I will compare this to workers, your cpu could be a dual core, quad core and/or have hyperthreading (hyperthreading means a quad core will be seen as having 8 cores, I7 are considered this) well each one of your cores is a worker so one worker would be -j2 meaning the worker will handle 2 jobs. If you tell your workers to do more jobs then they won’t be happy being overloaded just like how any worker would be and will actually be slower. Now -j`grep 'processor' /proc/cpuinfo | wc -l` means read your computer’s info and run at optimal speed, now why choose between the 2 well you might not wanna run at max speed and just wanna use only half your power so you use your computer for other things during)

When we are done syncing we can get back to work :)

I am gonna use vision as an example but you can change it to suit the device you are working on

connect your phone you are gonna work for adb and open a terminal or use current previous terminal

(note, the proprietary vendors have been modified to work for gingerbread so make sure you have either the most up to date cm7src build or when rc1/stable comes out on your phone to get the proper files)

(this assumes you are using a previous and are in cm7)

cd device

cd htc/vision

bash extract-files.sh

cd ~/cm7

cd vendor/cyanogen/

bash get-rommanager

cd ~/cm7

We now have pull the proprietary files for our phone so we can inject them into our build along with rom manager since it is required and will fail the build if you don’t

(if you look in your cm7 source you will now see inside vendor a folder called htc (our manufactor, if you are working on a samsung or motorola you will see that) and inside it you will see your device)

We are actually now ready to build so in our terminal

source build/envsetup.sh

lunch cyanogen_vision-eng

make clean

make bacon -j`grep 'processor' /proc/cpuinfo | wc -l`

Now our build is compiling

(the lunch command pulls target specific info so there is no need for a buildspec.mk to be made as lunch does this for us)

(always make clean between builds to remove old compiled files and make sure you have a fully working build with each update, it takes a bit longer but it is worth it)

(make bacon is a script that runs make otapackage and the squisher script which uses pngcrush to cut down the size and also removes unneeded things added by doing a -eng build, it also resigns it)

When your build is complete you should have a update-cm-7.0.0-RC0-vision-KANG-signed.zip in your cm7/out/target/product folder, this is your new build.

Congratulations on your first build from cm7 source :)

Now for a new build you would repo sync again, make clean and make bacon again