[XDA-University] Red Devil:
Some miscellaneous tips :

​

Tip # 1 : What all can I remove using local manifests ?

​

Since we just learnt about the local_manifests, I thought I'd just explain this first !

Note : What I refer to as remove from manifest is actually removing using local manifest.

If you don't know what that is yet then read the the 1st post !

The following repos are what you can remove :

Remove official device trees if you are not planning to build for them :

What this includes :

android_device_htc_codename
android_device_sony_codename
android_device_samsung_codename

If you don't own an HTC device you don't need any of their repos ! Same goes with Sony , Samsung and all other manufacturers.

Note: Do NOT delete generic repos like android_device_common etc.

If you own a samsung/sony/htc/blah device DO NOT Remove their common/ generic repos using the local manifest !

Also download a few sample device trees which are similar to your device so that you can reference the way the device trees are while compiling your unofficial ROM.

This process is called

" KangBang"-ing

. ;)

Remove all kernel source repos that you do not need !

Remove all projects named :

android_kernel_oem_codename
kernel_oem_codename

or similar !

If you don't plan on building for that device , Why do you need its kernel source code ! :eek:

And most of these sources are HUGE !:crying:

Remove all the unnecessary packages that are present in the manifest; for example if your phone does not have flash, there is no point downloading the torch.apk.. so might as well remove that from manifest

This includes many packages like CDMA specific packages for a GSM phone , torch , flashlight packages for a phone that doesnt have flash , unnecessary live wallpapers , and many more stuff.

If your phone's ROM is less you can also remove many packages from syncing itself instead of removing them from the build !

Saves a lot of bandwidth as well as time ! :D

Mostly all these packages have project names similar to :

android_packages_apps_appname
packages_apps_appname
android_packages_wallpapers_wallpapername

and so on.

Remove all unnecessary vendor trees from the manifest.. Why do you need the blobs for a device you are not building for !!

Remove all device specific vendor packages that include the blobs of the device.

Eg:

android_vendor_oem_codename_proprietary

Use your common sense to remove these repos.

Nexus devices use the blobs from TheMuppets.. so if you are not building for a Nexus then remove those for example ! :)

Remove all the darwin tool chains, and other darwin packages from the manifest if you are not building from a mac.

Remove all of these toolchains if you are NOT building on a macintosh :

<project path="prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6" name="platform/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6" groups="pdk,darwin,arm" />
<project path="prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6" name="platform/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6" groups="pdk,darwin,arm" />
<project path="prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6" name="platform/prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6" groups="pdk,darwin,mips" />
<project path="prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6" name="platform/prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6" groups="pdk,darwin,x86" />

Other packages may vary according to the ROM source you are syncing.

Remove all unnecessary repos that may not be needed.. for eg exynos specific hardware packages if your building for a qcom device!

What I said .. or in some cases like my phone the HTC Explorer, uses display-legacy from Qcom instead of the default one..

So I just remove all the display specific packages that are not needed from manifest.

Caution ! I am not mentioning examples as this may even break your build if you DON'T know what you're doing! So be careful and use your common sense ! :)

Tip # 2 : Use the reference flag before you initialize a repo !​

The repo tool is somewhat of a blessing for android ROM developers.

There is a certain flag called as a Reference flag that can be used before you repo sync while initializing a repo.

This flag has a basic syntax as follows :

repo init --reference=~/root/of/already/downloaded/source -u git://url.com/ROM.git -b branch

Consider the following scenario:

I have already downloaded the CyanogenMod 10.1 source mechanically as many guides state :

repo init -u git//www.github.com/CyanogenMod/android.git -b cm-10.1
repo sync -j4

and this is what I ended up with

as follows :

How does this work ?

What the repo tool does it checks the locally downloaded source and skips downloading that it Symlinks the code from the existing source to the new source.

Cool tool isn't it ? :cool:

This and local_manifests cut down a majority of the download time during repo sync !

Some more help with the Reference flag errors !

http://xdaforums.com/showpost.php?p=49365049&postcount=112 - By thewisenerd
​

Tip # 3 : Use CCACHE while compiling​

CCACHE : that is also known as compiler cache is another trusted friend of the ROM / Kernel developers.

It cuts down a lot of the time required for compilation.

How to use ccache :

1) Open a terminal ( cntrl + alt + t )

2) Enter gedit .bashrc

3) Add the following code :

For Jellybean :

export USE_CCACHE=1
[COLOR="Red"]export CCACHE_DIR=/source-directory/prebuilts/misc/linux-x86/ccache[/COLOR]

and for ICS and older

export USE_CCACHE=1
[COLOR="DarkOrange"]export CCACHE_DIR=/source-directory/prebuilt/linux-x86/ccache/ccache[/COLOR]

Once that is done just type in this command while you are in youre source directory

prebuilts/misc/linux-x86/ccache/ccache -M 50G

ICS and lower change it accordingly.

50 G ---> 50 GB of ccache..

Ideal values range for 50-100 GB.

Though if you want you can set it to around 40 GB

How does ccache work ?

Well , in short , what it does is that for C and C++ programs it caches the output. One it detects that the program is getting repeated it directly sends out the output and thus reduces the time of compilation.

After using ccache you will really feel the difference in the compilation speeds of your ROMs and kernels :cool: .

​

Tip # 4 : Use a custom toolchain

​

Try to use toolchains like linaro toolchains for compiling your ROMs and kernels.

For me personally it made a lot of difference in the performance of the ROM compiled. Nearly a 20-30 % increase in the performance.

Where can I get these toolchains ?

This is the link to download linaro's toolchains. HERE.

Get the latest one from the android section.

How to setup the toolchain?

Just extract the toolchain in a directory similar to the one I have mentioned in the picture

and edit these 2 lines in the envsetup.sh

To compile the inline kernel using a custom toolchain :

Place your toolchain in the ~source~/

prebuilt

/linux-x86/toolchains/

and in your device tree edit the BoardConfig.mk for eg :

In addition to this, you may need some device specific patches too. That maybe you will be able to find out in your device specific forums.

​

Tip # 5 Cherry-picking ​

So here's the scenario.

I have built a ROM and simeltaneously CyanogenMod development is taking place and their developer is fixing some bugs that are present in the device tree of the ROM.

He has implemented some changes that might help me fix stuff in my device tree thereby improving my ROM .

So what do I do ?

Manually apply those commits ?

There is a better way than that. Manually applying commits may result in a few human errors in your source code and thereby may cause some unwanted errors. So why not apply the CyanogenMod dev's commits itself! :silly:

To do this, we use a git feature called cherry-picking.

How to cherry pick commits :

First change your directory to the directory in which you want to apply the commits in.

I will take an example of my phone's device tree.

cd device/htc/pico

The best thing is to initialize an empty git and pull your own repo from here.

This allows you to push your changes to your github so that you can track your changes effectively.

If you dont have a repo on your github then push one right away or fork someone else and do :

So I do this :

git init
git pull git@github.com:red-devil/android_device_htc_pico_aokp.git

Once that is done , I just make sure everything is committed and local device tree matches the device tree online at my github.

then I pull all the commits from the CyanogenMod maintainer's github.

Basic syntax for this is :

git remote add somename git://github.com/user/repo.git

git fetch somename

So what I do is :

git remote add cyanogenpico git@github.com:TeamPico/android_device_htc_pico.git
git fetch cyanogenpico

Now just check using the git log function wheter the last commit shown is the last commit on YOUR repository on github.

In this case the last commit at git@github.com:red-devil/android_device_htc_pico_aokp.git should match the last commit on the git log of my local source.

This just ensures that you are going right at least up till now.

Now start the cherry picking.

The syntax is

git cherry-pick <sha-of-commit>

So what I do is :

git cherry-pick aa39fd899e321395f3c08c9a7f606ac458bbbd1b

and grab that commit.

If that is done smoothly

The terminal will start a new line automatically

and you can do this :

git push git-ssh

in my case

git push git@github.com:red-devil/android_device_htc_pico_aokp.git

If something goes wrong.

it may look something like this

akshat@vaio:/media/akshat/HD/android/kang/device/htc/pico$ git cherry-pick aa39fd899e321395f3c08c9a7f606ac458bbbd1b
error: could not apply aa39fd8... cut out debugging
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

This means that there are some lines in a file that this particular commit is looking for which are not present, thus it shows that the git has added / modified a few lines to apply that commit.

It marks those changes as uncommitted and thus it wont allow you to push those changes.

To make it push-able.. you can do a

git status

Check which files have changed.

Then

manually edit and logically correct those changes .

That for you is hacking my friends.

See this image for an example of how a bad head looks like

This is how I corrected the changes..

after this is done.

git add .
git commit -m " name of commit "
git push url.git

Important Note :

For this case I just had to remove the head and the settings worked after that..

This may NOT be the case with your repo.

Overlapping commits sometimes may break the build .

So you need to logically remove the bad heads and also ensure the package/code isn't damaged during the process !

Check out Commits from ROMs like PAC , RootBox , ReVolt etc to know how exactly to cherry-pick stuff and take reference from them to make your code work.

​

Still got some doubts ?

​

Ask on the thread, not via pm. This ensures everyone is cleared of the doubt.

​

Got a compilation error ?​

Head over here for some more help :

[HELP/Q&A][SourceBuilding,AllDevices] The Source Building Q&A Help Thread by [MENTION=4445428]speed_bot[/MENTION]
​

Finally the last bit

This guide had featured on the portal : Article : http://www.xda-developers.com/android/guide-on-using-the-repo-tool/[/COLOR]

This guide has also been mentioned in the official Omni Wiki : http://docs.omnirom.org/Setting_Up_A_Compile_Environment ​

​

The Credits

​

I would like to thank [MENTION=4445428]speed_bot[/MENTION] and [MENTION=4621813]legen_dary[/MENTION] , [MENTION=4626557]Nihar.G[/MENTION] among others who solved cleared my doubts whenever I asked them anything silly.

You guys for reading this whole piece and xda-developers for the platform.

Always remain a newbie and NOT a noob.

Know the difference.​