Rehber [GUIDE] How to build ROM from sources

Hoşgeldiniz <3

DevOtağ is a developer platform with a number of enhancements shared for various Android devices. Become a member and benefit from the contents!

DevOtağ, çeşitli Android cihazlar için birtakım geliştirmeler paylaşılan bir geliştirici platformudur. Üye olun ve içeriklerden faydalanın!

Şimdi, Bir Dakikada Kayıt Olun!

windowzytch

Wind/owZ
Moderatör
Messages
155
Likes
380
Location
Japan
#1
Everything is easy if you know. And so, here I share a complete guide on building ROMs from sources.

Please make sure you have a LINUX PC or server and follow the first steps on this guide for getting the server/PC ready for building. Make sure you're familiar with command-line tools even though I tell keyboard combinations also. So you don't get yourself into problems.

If you're all ready, let's begin!


talimatlar

Section #1: Getting ROM sources and device trees
First things first. Get ROM sources by initiating and syncing repo. I'll be using Project Sakura R and GM9PRO_sprout sources along the way.
Bash:
repo init [--depth=1] -u <repo> -b <branch>

repo sync [--current-branch] [--force-sync] [--no-clone-bundle] [--no-tags] [--optimized-fetch] [--prune] [-j<cores>]

For my case;​
Code:
repo init --depth=1 -u git://github.com/ProjectSakura/android.git -b 11

repo sync --current-branch --force-sync --no-clone-bundle --no-tags --optimized-fetch --prune -j8

Sync will take around 20 minutes or a whole night according to server performance and connection speed.
When it's done, get device trees;
git clone https://github.com/<provider>/<devicetree> device/<brand>/<codename> -b <branch>
git clone https://github.com/<provider>/<kerneltree> kernel/<brand>/<chipset> -b <branch>
git clone https://github.com/<provider>/<vendortree> vendor/<brand>/<codename> -b <branch>
git clone https://github.com/<provider>/<commontree> device/<brand>/<chipset>-common -b <branch>​
Code:
git clone https://github.com/<provider>/<devicetree> device/<brand>/<codename> -b <branch>

git clone https://github.com/<provider>/<kerneltree> kernel/<brand>/<codename> -b <branch>

git clone https://github.com/<provider>/<vendortree> vendor/<brand>/<codename> -b <branch>

git clone https://github.com/<provider>/<commontree> device/<brand>/<chipset>-common -b <branch>

Since GM9PRO_sprout doesn't have kernel and common trees open sourced, I'll just clone device and vendor trees.​
Code:
git clone https://github.com/devotag-open-source/android_device_gm_gm9pro_sprout device/GM/GM9PRO_sprout -b eleven

git clone https://github.com/devotag-open-source/android_vendor_gm_gm9pro_sprout vendor/GM/GM9PRO_sprout -b eleven

After those, apply or cherry-pick required commits, if, any. and then do these to adapt trees;

Section #2: Adapting trees
[In device/<brand>/<codename>]​
Code:
mv <baserom>_<codename>.mk <targetrom>_<codename>.mk

mv <baserom>.dependencies <targetrom>.dependencies

nano AndroidProducts.mk
[Replace all mentions for base ROM with target ROM]
[Ctrl+X] - [y] - [Enter]
Code:
nano <targetrom>_<codename>.mk
[Replace all mentions for base ROM with target ROM and remove or adapt non-existent paths]
[Ctrl+X] - [y] - [Enter]
Code:
cd ../../..
For my case;​
Code:
mv revengeos_GM9PRO_sprout.mk lineage_GM9PRO_sprout.mk

mv revengeos.dependencies lineage.dependencies

nano AndroidProducts.mk
[Replace $(LOCAL_DIR)/revengeos_GM9PRO_sprout.mk with $(LOCAL_DIR)/lineage_GM9PRO_sprout.mk]
[Ctrl+X] - [y] - [Enter]
Code:
nano lineage_GM9PRO_sprout.mk
[Replace vendor/revengeos/config/common.mk with vendor/lineage/config/common.mk and revengeos_GM9PRO_sprout with lineage_GM9PRO_sprout]
[Ctrl+X] - [y] - [Enter]
Code:
cd ../../..
Section #3: Building ROM
After all, let's start building! Make sure to check your ROM's manifest for compiling but this is the most common command series.​
Code:
. build/envsetup.sh # Pay attention that the period on the beginning is separate! Also, depending on vendorsetup.sh on device tree, this may add additional patches to source and/or clone other trees.

lunch <targetrom>_<codename>-<buildtype>

mka bacon -jX

For my case;​
Code:
. build/envsetup.sh # GM9PRO_sprout device tree's vendorsetup.sh has patching sources and cloning kernel and vendor trees.

lunch lineage_GM9PRO_sprout-userdebug

mka bacon -j8

When compiling is done, you can find the ZIP file in this path;
out/target/product/<codename>

Easy building! ;)

Tesekkurler
Forum owner: @hgunduz295
Telling about missing parts: @Tenshi2112
First guide: @Celexa (feat. @omeready)​
 

windowzytch

Wind/owZ
Moderatör
Messages
155
Likes
380
Location
Japan
#6
Alright so, according to my checks, I forgot to mention to check ROM manifest for compiling commands. The one in this guide is most common (but may not be exact) command series.

Such as, if you somehow have access to Weeb Projekt ROM vendor and want to try building it, command series turn into this (I'll be using seed for these series btw);
Code:
. build/envsetup.sh

lunch weeb_seed-eng

make weeb-prod -j16
 
Top
Lütfen Javascript'i etkinleştirin!Javascript'i etkinleştirin!
"