[Android General] phoenixita:
I'm using HTC One S and LiquidSmooth as examples. It should work for all devices. Nexus should be a little different story.

Do you know about a ROM that it's not builded for our beloved One S? Do you want to port it for our device? This easy guide will help you.

Requirements:

A One S.

A relatively recent computer (Linux, OS X, or Windows) w/a reasonable amount of RAM and about 35 GB of free storage. The less RAM you have, the longer the build will take. Using SSDs results in faster builds than traditional hard drives.

A micro USB cable.

A decent Internet connection & reliable electricity :)

Some familiarity with basic Android operation and terminology. It would help if you’ve installed custom roms on other devices and are familiar with what a recovery image such as ClockworkMod is, for example. It may also be useful to know some basic command line concepts such as cd for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /, etc.

​

HERE IS THE GUIDE.

Installing Build Packages

Open the terminal and type: (for 64-bit&32-bit)

sudo apt-get install bison build-essential curl flex git-core gnupg gperf libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-6-jdk openjdk-6-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev

In addition to the above, for 64-bit systems:

sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

Creating Directories

In order to start building ROMs you'll need to create some directories

mkdir -p ~/bin
mkdir -p ~/yourworkingdirectory

Installing the REPO command

Enter the following to download the "repo" binary:

curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

Now lets give this the proper permissions to make it runnable:

chmod a+x ~/bin/repo

Put the ~/bin directory in your path of execution

Make sure that the ~/bin directory you just created is in your path of execution so that you can easily run the repo command even when you're not in ~/bin.

export PATH=${PATH}:~/bin

Initialize the source repository

cd yourworkingdirectory

Now you'll need the repo init related to the rom you'd like to build. Here i will insert some of the I used. Anyway to find this you can go the rom's github and search for the manifest (android or platform-manifest).Just choose the right branch.

repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
repo init -u git://github.com/LiquidSmooth/android.git -b kitkat
repo init -u git://github.com/SlimRoms/platform_manifest.git -b kk4.4-caf
repo init -u git://github.com/ChameleonOS/android.git -b kitkat-staging

Download the source code

This will download all the source code to your computer.Prepare to wait a long time while the source code downloads.

repo sync

Download device,kernel and vendor tree for Liquid

We will use CM ones. Thanks a lot.

Basically we need to add some projects to the download list. To do this we'll need a local_manifest.

Go in the .repo folder in your working directory(it's an hidden folder press ctrl+h). Create a new folder called "local manifests" then double click on it. Now you'll have to create a roomservice.xml file for the most of the ROMs and a slim_manifest.xml for SlimRoms, it's the same thing just the name it's different.

Open this file and paste this inside:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="github"
fetch="git://github.com/" />
<project name="CyanogenMod/android_device_htc_ville" path="device/htc/ville" remote="github" revision="cm-11.0" />
<project name="CyanogenMod/android_device_htc_s4-common" path="device/htc/s4-common" remote="github" revision="cm-11.0" />
<project name="CyanogenMod/android_device_htc_msm8960-common" path="device/htc/msm8960-common" remote="github" revision="cm-11.0" />
<project name="CyanogenMod/android_kernel_htc_msm8960" path="kernel/htc/msm8960" remote="github" revision="cm-11.0" />
<project name="TheMuppets/proprietary_vendor_htc" path="vendor/htc" remote="github" revision="cm-11.0" />
</manifest>

Now give another:

repo sync

and wait.

Do some modifications to the .mk files

Since we are using CM device tree we need to modify them for the choosen ROM.

Go into the device folder(device/htc/ville) and do some modifications. I will explain you what i mean using LiquidSmooth as example.

1) Create a new file called vendorsetup.sh . Open it and inside you'll have to write a script to add it to the lunch list.

add_lunch_combo liquid_ville-userdebug

You can choose if you want an userdebug version of the rom or an eng one just by writing eng instead of userdebug.

2) Now rename cm.mk into liquid.mk(for other ROMs this file should be renamed in a different way. Use an existing device tree to see the correct naming.)

3) Open the .mk file. You'll find something like this:

# Release name
PRODUCT_RELEASE_NAME := ville

# Boot animation
TARGET_SCREEN_HEIGHT := 960
TARGET_SCREEN_WIDTH := 540

# Inherit some common CM stuff.
$(call inherit-product, vendor/cm/config/common_full_phone.mk)

# Inherit device configuration
$(call inherit-product, device/htc/ville/device_ville.mk)

# Device naming
PRODUCT_DEVICE := ville
PRODUCT_NAME := cm_ville
PRODUCT_BRAND := htc
PRODUCT_MODEL := One S
PRODUCT_MANUFACTURER := HTC

# Set build fingerprint / ID / Product Name ect.
PRODUCT_BUILD_PROP_OVERRIDES += PRODUCT_NAME=htc_ville BUILD_FINGERPRINT=htc_europe/ville/ville:4.1.1/JRO03C/128506.8:user/release-keys PRIVATE_BUILD

You need to modify some things to make it buildable:

# Inherit some common CM stuff.
$(call inherit-product, vendor/cm/config/common_full_phone.mk)

becomes:

# Inherit some common LiquidSmooth stuff.
$(call inherit-product, vendor/liquid/config/common_phone.mk)

To understand the changes you'll have to go in the vendor folder searching the rom specific vendor and open the config folder to see what .mk file you need.

This:

PRODUCT_NAME := cm_ville

becomes:

PRODUCT_NAME := liquid_ville

4) Now rename cm.dependencies in liquid.dependencies(SlimRoms does not require this step for unsupported devices.)

Start the build

source build/envsetup.sh

If you created the vendorsetup.sh in the right way you will read the ville folder.

lunch

Now you have to choose the number near the ville in the list of the supported devices.

If you have done all in the correct way in your terminal you'll see a page like this:

View attachment 2470228

Build

After lunching you have to start the build using the right command:

For liquid:

time mka liquid

For others:

make bacon
make
brunch devicename

Wait some time till the build ends hopefully with no errors.​

Credits: http://wiki.cyanogenmod.org/w/Build_for_ville

and all the experience i got in this 2 months of building.