vendredi 7 mars 2014

[Guide] A very in depth guide on Compiling from source with useful Tips and F.A.Qs topic




Okay so there are several guides on XDA on how to compile Roms from source etc. Since the development for this device is growing... I want to encourage other members to contribute to development and teach those who don't know yet about compiling. This is an extremely indepth tutorial intended not only to teach basics...but also to clear up working of some stuff.
THIS IS A 5 PART TUTORIAL COVERED IN 5 POSTS.
So without further ado.......

################
THE BASIC STUFF
################
This will cover all the basics of android development...which is I think common to most other tutorials. This part will teach you how to compile a ROM from source.

First we select an OS. You can use gentoo or mint
But I prefer to use Ubuntu 12.04 64 bit.
Note: YOU CANNOT COMPILE ROMS ON 32 BIT ONLY KERNELS.
So let's download Ubuntu 12.04 (Precise Pangolin) image
http://www.google.co.in/url?sa=t&sou...WiZ1r-K_awsOoQ

Now that you have downloaded it.. You can set it up as a virtual machine in virtual box or dual boot it. You may also use it as primary os if you want.

Now let's set up the build environment.

Open up the terminal
Type this in the terminal window:

Code:


sudo apt-get install openjdk-6-jdk python git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev x11proto-core-dev \
libx11-dev libreadline6-dev libgl1-mesa-glx \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev


You also need to run this in 12.04:

Code:


sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Now you need to install the android SDK
Get it here :http://developer.android.com/sdk/index.html
Extract this in the home directory
Now in the terminal window type this:

Code:


gedit .bashrc

A text editor will pop up. Add these lines at the very end:

Code:


# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin


Now again in terminal window type:

Code:


gedit .profile

Add this:

Code:


PATH="$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"

The SDK is now installed!

Now before we install the repo tool
Run this in terminal window

Code:


gksudo gedit /etc/udev/rules.d/51-android.rules

and add these lines:

Code:


#Acer
SUBSYSTEM=="usb", ATTR{idVendor}=="0502", MODE="0666"

#ASUS
SUBSYSTEM=="usb", ATTR{idVendor}=="0b05", MODE="0666"

#Dell
SUBSYSTEM=="usb", ATTR{idVendor}=="413c", MODE="0666"

#Foxconn
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666"

#Garmin-Asus
SUBSYSTEM=="usb", ATTR{idVendor}=="091E", MODE="0666"

#Google
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666"

#HTC
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666"

#Huawei
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666"

#K-Touch
SUBSYSTEM=="usb", ATTR{idVendor}=="24e3", MODE="0666"

#KT Tech
SUBSYSTEM=="usb", ATTR{idVendor}=="2116", MODE="0666"

#Kyocera
SUBSYSTEM=="usb", ATTR{idVendor}=="0482", MODE="0666"

#Lenevo
SUBSYSTEM=="usb", ATTR{idVendor}=="17EF", MODE="0666"

#LG
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"

#Motorola
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666"

#NEC
SUBSYSTEM=="usb", ATTR{idVendor}=="0409", MODE="0666"

#Nook
SUBSYSTEM=="usb", ATTR{idVendor}=="2080", MODE="0666"

#Nvidia
SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666"

#OTGV
SUBSYSTEM=="usb", ATTR{idVendor}=="2257", MODE="0666"

#Pantech
SUBSYSTEM=="usb", ATTR{idVendor}=="10A9", MODE="0666"

#Philips
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", MODE="0666"

#PMC-Sierra
SUBSYSTEM=="usb", ATTR{idVendor}=="04da", MODE="0666"

#Qualcomm
SUBSYSTEM=="usb", ATTR{idVendor}=="05c6", MODE="0666"

#SK Telesys
SUBSYSTEM=="usb", ATTR{idVendor}=="1f53", MODE="0666"

#Samsung
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666"

#Sharp
SUBSYSTEM=="usb", ATTR{idVendor}=="04dd", MODE="0666"

#Sony Ericsson
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666"

#Toshiba
SUBSYSTEM=="usb", ATTR{idVendor}=="0930", MODE="0666"

#ZTE
SUBSYSTEM=="usb", ATTR{idVendor}=="19D2", MODE="0666"


Save it and run:

Code:


sudo chmod a+r /etc/udev/rules.d/51-android.rules

What we just did was Adding vendor id's for USB connectivity.

Whew ..... That was quite long.... Now let's be back to business.

Installing the repo tool:
To manage the git repos and to use them for our various needs like initializing them and syncing we use a tool made by Google called the repo tool.
Type this in terminal window:

Code:


mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo


Now you are all geared up for compiling roms !
For demonstration in this tut we will take the device as golfu and our source path as:
/home/user/android/system
So make the source folder by:

Code:


cd ~/
mkdir android
cd android
mkdir system
cd system


Now let's initialize the repo..... Let's decide which one to sync.... I'll use cm11 for this tutorial.

When you are in source folder type in terminal:

Code:


repo init -u *git link to source* -b *branch name*

The repo init link can generally be found in the manifest of the ROM on github.
So for cm 11 it should be like this :

Code:


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

Now you have successfully initialized cm11 source code in your directory!

Now you need to download the sources..... The android source code is very large and it may take a little to a looong time to download depending on your internet speed.
So when you are in your source directory:

Code:


repo sync -j#

# will be the no. Of jobs
A larger number will give better result if your internet is fast but entering an insane number won't help.
I use:
repo sync -j8

Now wait till your source is synced...long process.

After the source is downloaded you need to get the device specific parts.
You need to get the kernel source, device tree and vendor tree.
For this device you need not download the vendor tree
Download device tree as a zip from github
Extract CONTENTS to:
/home/user/android/system/device/htc/golfu
Create folders if not present.
Download the kernel source from github as a zip
Extract CONTENTS to:
/home/user/android/system/kernel/htc/golfu
Create folders if not present.

Now your source code is completely set up for compiling for our device !

Before building get the prebuilts:

Code:


cd /home/user/android/system/vendor/cm
. get-prebuilts.sh


Set up for building:
Type this in terminal

Code:


. build/envsetup.sh

Do this every time before building

And now finally start building!!
Type this in terminal to start building:

Code:


brunch cm_devicename-userdebug -jx+1

Where x is number of cores. My laptop has 4 cores.
So for golfu it should be :

Code:


brunch cm_golfu-userdebug -j5

Wait for it to complete building.
After it is done .... Your build can be found at
/home/user/android/system/out/target/product/golfu.
It will look like : cm-11-YYYYMMDD-UNOFFICIAL.zip
CONGRATULATIONS! You have built your very own ROM
This is the end of part one of series.





Aucun commentaire:

Enregistrer un commentaire