[HTC Desire C] <CyberAnarchy>:
Let's get on with part 2 of this series of 5!

########################

THE SOURCE CODE

########################

OKAY so if you followed the tutorial you theoretically speaking have created your own build.

BUUT ... Its not always like that practically.

You are bound to get errors especially if you are using your own device tree. So let's have a study of the source code so that you know what's wrong and what is what.

Let's get started!

So the source code in our folder has 2 parts:

a) Generic source code

b)Device-specific code

The generic source code is the ROM source code which is similar for all devices

The folders you should find there:

Bionic

Build

Bootable

Dalvik

Art

Device

Docs

External

Frameworks

Hardware

Kernel

Ndk

Out

Packages

Prebuilt

Prebuilts

System

Vendor

So let's see what goes in each folder:

Bionic: is the Android mobile-friendly version of libc.Lots of cpu-specific stuff present here. Better not to touch anything here and move along.

Build:The scripts and various files that are used for the actual build process are present here. You can see the various steps for compiling android

Bootable: The source of CWM is here

Dalvik: its the virtual machine that runs java apps.

You might recall in computer classes you were taught that java programs do not depend on the underlying architecture. This is why its so.

Art: art stands for android runtime. Its a replacement for dalvik in android 4.4

Device: it contains the device configurations for a particular device.

Docs: contain the source for Android Open Source website.

External: This is where non-android specific utilities go. Lots of the stuff in here are just regular open source projects that are used by Android.

Frameworks:This refers to the core Android frameworks. It's the stuff that makes Android, Android. The frameworks contain the Android user experience and the abstracted "hooks" that programmers use to build Android apps.

Hardware : specific libraries go in this folder.

The drivers for our WiFi chip ath6kl should be here.

Kernel: the kernel source code can be found here.

Ndk: Tools for allowing cross-platform C code to be included in Android apps.

Out: the output I.e the compiled ROM will be here.

Packages: the android apps are present here.

Prebuilts : contains the tool chains.

System: Lower-level linuxy system stuff such as netd, fastboot support, the shell

Vendor: it contains stuff particular to a vendor build such as CyanogenMod. It's also the place where proprietary blobs are extracted from the device.

That's it for generic sources.

Source: cyanogenmod docs

Now let's talk about the device specific code. You may already have guessed, its the code that contains all the configurations for our device...making the compiled ROM unique for our device.

Now let's have a closer look at it.

The device specific code contains 3 parts:

a)device tree

b)vendor tree

c)kernel source code.

Let's talk about the device tree.

Here is a perfect example of a great device tree.https://github.com/codexblack/golfu

Kidding. That one is for 4.3 and it barely works but it will do for demonstration.

In depth look time!

Files in the device tree *yawn* you guys still with me?

AndroidBoard.mk

AndroidProducts.Mk

BoardConfig

Device.Mk (for us: golfu.Mk)

Cm.Mk(for cyanogenmod. Will vary with different Roms)

Recovery.fstab

System.prop

Vendorsetup.sh

Now what each one does:

AndroidBoard: these files are present in our ramdisk in the kernel. You can decompile the kernel to see these files.

BoardConfig: you set up paths to some files and declare some stuff about architecture.

Device.Mk: define libs to be compiled along with other stuff. Take a look and you should understand

System.prop: build prop configuration

Vendorsetup.sh: self explanatory.

Let's move on to kernel

Its the source code of the kernel for our device.

After compilation it looks something like a boot.IMG..you might have seen in ROM folder . The kernel is very important. But what does it do? When software needs the hardware to do anything, it sends a request to the kernel.

That's it for kernel..... It handles all the instructions to put simply.

Vendor tree.....

It contains the proprietary blobs for our device.

We do not use it in golfu

Whew .... That's it for device specific code!

Move on to part 3.