Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
View Poll Results: Should I take the time to do the Bash Scripting Section?
HECK YES! ... I'm Lazy too... 18 81.82%
No, I need to CONTROL my builds 4 18.18%
Who Cares? This thread sux 0 0%
Voters: 22. You may not vote on this poll

Post Reply

Post [GUIDE] The Comprehensive AOKP Building Guide

OP TheByteSmasher

2nd April 2013, 02:44 AM   |  #1  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
Thread is outdated for 4.3... Working on Update. Thanks for your patience


Contents:

  1. Introduction
  2. Glossary & Linux Quick Guide
  3. Setting up Linux (Dual-Boot Style Setup)
  4. Setting up your Build Environment
  5. Building
  6. Cherry-Picking
  7. Using CCache
  8. Editing Local Manifests/Adding APKs to the build
  9. Bash Scripting Autonomy
  10. Creating Launchers
  11. Uploading
  12. Reserved
Last edited by TheByteSmasher; 4th September 2013 at 06:44 AM.
The Following 47 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:45 AM   |  #2  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
1. Introduction

Welcome To The Most Comprehensive Tutorial For Building AOKP ROMs I Can Think Of! All of the tutorials I have found have links to other websites interspersed throughout and are dependent on the other sites keeping their information current. Also, they can be confusing. My goal is to create a single document which, unfortunately, will contain some links but will flow in an orderly manner and include a discussion thread for building AOKP nightlies. The setup I will be describing will be using an Ubuntu - 64bit System. YOU MUST USE 64 BIT TO BUILD/COMPILE ANDROID. That said, I recommend Ubuntu 13.04

PLEASE POST ANY QUESTIONS, COMMENTS OR ITEMS YOU THINK WOULD BE BENEFICIAL IN THE THREAD. If this post has helped you, HIT THANKS and TELL OTHERS where to find the info they need. Post the thread on your G+, Facebook, Twitter Etc Accounts. Let's get the word out! Anyone can build! The goal is to create a community feel to this thread. Beginners to advanced users are welcome!

Here is My version of GAPPS. It will install AOKP Camera (Alongside Stock so You can Keep the Photo Sphere feature), Removes the Old Calendar and installs the newest Play Store Version, ***Play Store Version 4.0.25!!!*** Yay!!!!! The First Time you Flash it you might have to select your default calendars again

Thanks to:
VonEsch
Romanbb

These guys have been indispensable for helping me out when I got started, either pointing me in the right direction or learning together...
Last edited by TheByteSmasher; 15th June 2013 at 02:23 AM.
The Following 27 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:46 AM   |  #3  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
2. Glossary & Linux Quick Guide
2. Glossary & Linux Quick Guide

Let's start with some basic terms I will use.

Kang:
Internet term meaning to steal.
Root:
Akin to Android's SuperUser
Nautilus:
Ubuntu's default file manager
sudo:
Terminal Command to perform the request as Root.
gksu:
Terminal Command to open a program as Root i.e. nautilus, gedit, terminal...
Repo:
1. Repository. 2. A Python Script used for synchronization between your local repository and AOKP's server repository.
Gerrit:
A web based code review system, facilitating online code reviews for projects using the Git version control system.
Git:
An online system used to store source code and manage version control (branches).
jb-mr1:
Google's branch name for Jellybean 4.2 (jb-mr1.1 is 4.2.2).
Terminal:
A Linux command prompt. (Ctrl+Alt+t).
Commit:
A new feature/fix either implemented (merged) or awaiting review and/or approval (open).
Build:
(n) A completed ROM. (v) To compile a ROM
Cherry-Pick:
To merge an open commit into your local repository to be incorporated into the build.
Nightly:
A build containing all the merged commits since the last Official Build.
Bash:
A simple programming language similar in function to DOS.
Distro:
Short for distribution. Used to refer to a "flavor" of Linux. Different distros have different pros/cons and abilities.
Ubuntu:
The Linux distro I use.
PPA:
A Linux package containing software... sorta' like a windows executable.
Clone:
To download the contents of an online Git repository folder onto your local machine.
Build Box:
(Box) The PC you are using to build your ROMs.
MBR:
Master Boot Record - The Hard Drive's own index.
Manifest:
An XML file that tells the repo script what to include and where to get it from when it syncs your local repository.
URL:
Short for Universal Resource Locator... basically a Web address.

Linux Quick Guide:

Show Hidden Files in Nautilus:
Ctrl+H
Terminal Keyboard Shortcuts:

Copy:
Ctrl+Shift+C
Paste:
Ctrl+Shift+V
Break Operation:
Ctrl+C
Last edited by TheByteSmasher; 7th April 2013 at 08:28 PM.
The Following 25 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:46 AM   |  #4  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
3. Setting up Linux (Dual-Boot Style Setup)
3. Setting up Linux (Dual-Boot Style Setup)

I am using the assumption that you have no dedicated PC to build ROMs. The following method will turn your Windows PC into a Dual-Boot Ubuntu/Windows PC. If you already have a build box, go ahead and skip to post #3. Let's get started.

First you need to download Ubuntu. We're going to download Ubuntu 13.04 64-bit. (By the way, Ubuntu's Version control is Year.Month so 13.04 is the April 2013 version). You can burn the image to a disk or a USB stick (Pen Drive). I'm going to show you how to use a pen drive. *IN EITHER CASE* Make sure your BIOS is set to boot from that device first. Don't forget to switch it back afterward.

You can download Ubuntu here: http://www.ubuntu.com/download/desktop

You can download the pen drive installer here: http://www.pendrivelinux.com/univers...easy-as-1-2-3/

OK... Here you're gonna follow the directions for Using the appropriate tools to make your bootable disk. So, Yes I am going to give you some links... but they will be specific, I promise!

To create a bootable DVD: http://www.ubuntu.com/download/help/...dvd-on-windows

To create a bootable USB stick: http://www.ubuntu.com/download/help/...ick-on-windows

OK.. That done? Great! Moving on...

Another link... But it is fantastic and has pictures! Here you will receive excellent instructions on how to create the dual-boot.

Windows 7
http://www.linuxbsdos.com/2012/05/17...and-windows-7/

Windows 7 with 2 hard drives
http://www.linuxbsdos.com/2012/07/23...2-hard-drives/

Windows 8
http://www.linuxbsdos.com/2012/11/05...uefi-hardware/
Last edited by TheByteSmasher; 15th June 2013 at 02:24 AM.
The Following 15 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:47 AM   |  #5  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
4. Setting up your Build Environment
4. Setting up your Build Environment

OK! Make sure your system is completely functional and up to date, using software updater.

Ready to make a build box? Good!

The following will make life easier and your Box more fun. The following are optional but recommended. All code should be cut and pasted into terminal to prevent typos.

Install proprietary media codecs/libraries:

Code:
sudo apt-get install ubuntu-restricted-extras
Code:
sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
Code:
sudo apt-get install libdvdcss2
Install VLC Media Player:

Code:
sudo apt-get install vlc
Install "Open in Terminal" Extension. This allows you to open a terminal window in any folder by right click and selecting "Open in Terminal" This is very helpful for cherry picking!!!! ***THIS ONE ISN'T A TERMINAL COMMAND*** Either option will work.

Option #1 Paste this into the address bar of your browser and install in Software Center

Code:
apt:nautilus-open-terminal
Option #2 Paste this into the software center search box and install.

Code:
Nautilus plugin for opening terminals in arbitrary paths
Install gvfs-mtp mount to easily mount and unmount your android 4.2 devices upon plugging in and unplugging: (Not Required for 13.04)

Code:
sudo add-apt-repository ppa:langdalepl/gvfs-mtp
Follow the prompts then:

Code:
sudo apt-get update
Then run software updater

Now, create a file /etc/udev/rules.d/51-android.rules (as the root user) and to copy the following lines in it. must be replaced by the actual username of the user who is authorized to access the phones over USB.

1. Open a Root Access Nautilus Session:
Code:
gksu nautilus
2. Now, Click on File System in the Left Hand Pane, then navigate to etc/udev/rules.d/

3. Now, right click in the folder and Select "Create New Document" then "Empty Document"

4. Name the document 51-android.rules

5. Open 51-android.rules

Paste the following:
Code:
# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0666", OWNER="thebytesmasher"
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0666", OWNER="thebytesmasher"
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0666", OWNER="thebytesmasher"
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0666", OWNER="thebytesmasher"
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0666", OWNER="thebytesmasher"
# usbboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0666", OWNER="thebytesmasher"
# usbboot protocol on panda (PandaBoard ES)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0666", OWNER="thebytesmasher"
# adb protocol on grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0666", OWNER="thebytesmasher"
# fastboot protocol on grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0666", OWNER="thebytesmasher"
# mtp protocol on the grouper (Nexus 7)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e41", MODE="0666", OWNER="thebytesmasher"
## Google
#SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0666", OWNER="thebytesmasher"
## LG Nexus 4
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666", OWNER="thebytesmasher"

SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", SYMLINK+="android_adb", MODE="0666"

SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev" 
# Google Nexus 7 MTP mode : automatic mount when plugged (all android versions)
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus4"
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus4"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e41", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus7"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e42", ACTION=="add", RUN+="/usr/bin/sudo -b -u yourlogin /usr/local/sbin/go-mtpfs -allow-other=true /media/Nexus7"

# Google Nexus 7 MTP mode : automatic unmount when unplugged (all android versions)
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="remove", RUN+="/bin/umount /media/Nexus4"
ENV{ID_MODEL}=="Nexus_4", ENV{ID_MODEL_ID}=="4ee2", ACTION=="remove", RUN+="/bin/umount /media/Nexus4"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e41", ACTION=="remove", RUN+="/bin/umount /media/Nexus7"
ENV{ID_MODEL}=="Nexus_7", ENV{ID_MODEL_ID}=="4e42", ACTION=="remove", RUN+="/bin/umount /media/Nexus7"
6. Use the Find and Replace (magnifying glass with pencil) option to find thebytesmasher and replace with your Ubuntu username.

7. Save the file.

Reboot for the above changes to take effect.

** Now to install the required libraries to make your build box work! **

Copy and paste this in terminal:

Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
After that is done installing do:

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

Code:
sudo apt-get install schedtool pngcrush
Next we will make the required directories, get the Repo binary/script, Add repo to the path & give it permissions, initialize the repo binary and download the Manifest, then sync the source. Ready?

Make directory for repo binary:
Code:
mkdir ~/bin
Add that directory to your path:
Code:
PATH=~/bin:$PATH
Download repo binary and place it in the proper directory This has recently changed:
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Give repo the proper permissions:
Code:
chmod a+x ~/bin/repo
Create directory for where the AOKP repo will be stored and synced, then go to it:
Code:
mkdir ~/aokp_kk && cd ~/aokp_kk
Notice in the above code how We used && to string together 2 commands.

Initialize the AOKP repo and download the manifest for the KITKAT branch ( -b kitkat):

INITIALIZING REPOSITORY
Init core trees without any device/kernel/vendor :

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat
Init repo with all devices, kernels and vendors supported by OurROM :

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,kernel,device,vendor
Init repo only for a particular device :

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,<devicename>,<vendorname>
for example, to init only trees needed to build mako

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,mako,lge
Init repo for multiple devices

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,<devicename1>,<devicename2>,<devicename3>,<vendorname1>,<vendorname2>,<vendorname3>
for example, to init trees needed to build mako and grouper

Code:
repo init -u https://github.com/AOKP/platform_manifest.git -b kitkat -g all,-notdefault,mako,grouper,lge,asus
Sync AOKP source. This can be sped up by using the -j variable. -j4, -j8, -j16, -j32.. Take the number of THREADS your processor have and multiply by 4. The higher the value, the more multitasking... also the higher the number, the slower your build box will run if YOU try to multitask while using a command with a -j variable. Change the number after -j to your liking:

Code:
repo sync -j8
Go do something else. This will take a LONG time! You will be downloading about 10GB of source code. Then Continue on... At this point I reboot my Linux box... Why Not, Right?

Get it? OK!
Last edited by TheByteSmasher; 17th June 2014 at 05:54 PM.
The Following 23 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:48 AM   |  #6  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
5. Building...Finally!
5. Building...Finally!

Now we're going to build our first ROM.

The easiest way is to create the ROM and build it into a zip file in one step. to do this we will use the BRUNCH command.

Later we'll set up bash scripts and launchers to simplify the process.

Open a new terminal in the aokp_jb folder using the right click - open in terminal extension we set up earlier

-OR-

you can open a terminal and do
Code:
cd ~/aokp_jb
Then, I always make sure all my variables are set and the build directory is clear:

Code:
PATH=~/bin:$PATH
Code:
make clobber
Now for the next step, use your -j number you decided on earlier (or try another) and substitute mako (both instances) with the device you want to build for (again, don't forget the "."), -j8 or -j12 are reasonable compromises:

Code:
. build/envsetup.sh && brunch mako aokp_mako-userdebug -j32
That's it... for a basic nightly. Now to watch the progress, you can maximize the Terminal Window and open the edit menu (***By default, the Global Menu is enabled in Ubuntu 13.04, that means that for the current window in focus, if you place your mouse pointer at the top left of the screen, you'll get the menu options for that window) and select "Profile Preferences" under the "Scrolling" tab, select "scroll on output"

Now on to More customizations!
Last edited by TheByteSmasher; 15th June 2013 at 02:30 AM.
The Following 17 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:48 AM   |  #7  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
6. Cherry-Picking
6. Cherry-Picking

This is the part that most people really want to know about. What is cherry-picking and how do I do it?
On your local computer, you actually have 2 copies of the online Repo. One is in a hidden directory and the other is the one you work with. That way you can modify your visible local copy and if you want to revert or screw something up, it's usually relatively painless to fix. Cherry-picks modify the visible local directory with the modified/added/deleted information of the cherry. When you revert, you're basically calling back up the information from the hidden directory that has been unchanged.

Here is how to cherry pick:

Open up the AOKP Gerrit at
HTML Code:
http://gerrit.sudoservers.com/#/q/status:open,n,z
Find a change you want to add.
This is where you want to be careful. If the change has multiple parts (i.e. [1/2]) You'll want to cherry-pick both parts.
__________________________________________________ __________________________________________________ ________________________________

This is what the Open Commit will look like:


__________________________________________________ __________________________________________________ ________________________________

Choosing the Commit below the highlight by clicking on the Subject name, The next screen looks like this:



Notice the Commit message, (circled in BLUE) it often contains a brief description of the change.
To the left of the commit message is the basic change info.
***The section entitled Project is the important one.*** This section (Circled in RED) tells you where the cherry pick needs to be downloaded to. For this Commit, it needs to be downloaded to your "/home/YourUserName/aokp_jb/device/asus/grouper" directory.

About halfway down the page, you'll find the download section (Circled in GREEN. Click on the "cherry-pick" label. Now copy the URL underneath by either Ctrl+C or right click and copy.


Now we're going to use the "Open in Terminal" extension we installed earlier. You need to navigate into the aokp_jb/device/asus/grouper directory and right click then select "Open in Terminal" or you can do the same by right clicking on the grouper folder and selecting "Open in Terminal"
__________________________________________________ __________________________________________________ ________________________________

Once the terminal is open, paste the URL at the command prompt. Either with a right click and paste or Ctrl+Shift+V.

Press Enter

If successful, You should see this or a similar message:


__________________________________________________ __________________________________________________ ________________________________

If you want to cherry pick into the same directory as an active pick, you'll need to commit those changes first:
The easiest way is open a terminal in the folder containing the pick you want to commit and type
Code:
git add -A
then
Code:
git commit -a
Select the files you want to keep and press Ctrl+O (like save) and enter, the Ctrl+X to exit.

When you're done picking go back to the root aokp_jb folder and build!

================================================== ================================================== ===============

**In order to sync, you'll need to revert your cherry picks, so sync completes successfully. To do this, type the following in a terminal in each directory you picked into.**

Code:
git reset --hard HEAD && git clean -f && git checkout aokp/jb-mr1
This can also be split up into 3 different commands.
Last edited by TheByteSmasher; 10th April 2013 at 05:25 PM.
The Following 16 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:50 AM   |  #8  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
7. Using CCache
7. Using ccache

ccache is a compiler cache for C and C++ that can help make builds faster. It will use space on your Home Partition. The recommended size is 50-100GB. I use 20-30GB and find it speeds up things tremendously. Using ccache is easy. in the root of your build directory (aokp_jb) type the following in Terminal:

Code:
export USE_CCACHE=1
Code:
export CCACHE_DIR=/<path_of_your_choice>/.ccache
Code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
The 50G is the size you want for your ccache. If you want to watch ccache doing its thing type the following in a new terminal:

Code:
watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s
Later, we'll use a script to automate using ccache each time.
Last edited by TheByteSmasher; 10th April 2013 at 05:21 PM.
The Following 9 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:50 AM   |  #9  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
8. Editing Local Manifests/Adding APKs
8. Editing Local Manifests/Adding APKs

So, if you've followed this, You've already edited your /home/YourUserName/aokp_jb/.repo/local_manifests/kernel_manifest.xml file. We're going to use this file as our local_manifest.xml. Your default.xml found in the directory platform_manifest is the file that repo uses to sync your local repository. kernel_manifest.xml is a local manifest that adds to your default manifest. We're going to use it to add to and remove from the default manifest. Why is this useful? Well if you want to add something to your build that isn't in AOKP's repository, or replace something that is, you use the local manifest to accomplish this.

Your default.xml defines where on the internets repo can find the base repository (called a remote) for the project you want to add. With some basic deduction, we can see in the following example that the name of the remote is cm and the base repository domain is at https://github.com/:

Quote:

<remote name="cm"
fetch="https://github.com/"
review="review.cyanogenmod.com" />

Understanding how the remote is defined is important because if you want to add projects from a different source, not defined by the default.xml, you'll need to define it in your local manifest. You can name it whatever you want, you'll use that name to call it out in your project path statement.

To add a project that doesn't already exist in default manifest you'd simply add a line to the local manifest (kernel_manifest.xml) like this:

Code:
  <project path="packages/apps/CMFileManager" name="CyanogenMod/android_packages_apps_CMFileManager" remote="cm" revision="cm-10.1" />
Defined:

"project path=": this is the local folder the project will sync into/with

"name=": this is the remote location of the repository.

"remote=": this is a call the the remote defined at the head of the manifest.

"revision=": this is the branch of the repository you want.

So in this case:

We are downloading the server repository "android_packages_apps_CMFileManager" from "https://github.com/CyanogenMod/" from the "cm-10.1" branch into our local repository ~/aokp_jb/packages/apps/CMFileManager. GET IT?

So now, whenever we perform a repo sync from the root folder, ~/aokp_jb/packages/apps/CMFileManager will be updated with new commits from CyanogenMod's repository. Cool, huh?

That won't create an app in the build by itself, but it gets us much closer!

In order to tell the AOKP build that you want to build in that app, you need to add it to ~/aokp_jb/build/target/product/core.mk. In this case you add the name of the app "CMFileManager" to the list of Apps in core.mk


Code:
    abcc \
    apache-xml \
    atrace \
    bouncycastle \
    bu \
    cacerts \
    CMFileManager \
    com.android.location.provider \
    com.android.location.provider.xml \
    core \
So all we did was add it, plus a space and a back-slash. That's it! Now if we build, CMFileManager will be an available app!

But what if you want to replace an existing app with one from a different repository? You first must remove the AOKP project path, then add the new one as shown above. For this example, we'll say that AOSPs calendar app is different from AOKPs and we want to use AOSPs version. So in kernel_manifest.xml we'll do the following:

Code:
<remove-project name="platform/packages/apps/Calendar" />
  <project path="packages/apps/Calendar" name="platform/packages/apps/Calendar" remote="aosp" revision="jb-mr1.1-release" />
See, we removed the standard one, then called out the one we wanted. Since this app has the same name, there is no need to modify any other files. Play with it... See what you can do.

Some applications require other "hooks" like a way to access their settings like CMs LockClock or Chronus. You need to add additional strings and xml settings to create a settings menu in ROM Control.

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

Adding APKs.

Sometimes it's not possible to build an app in from a repository. In this case, we'll use the APK itself!

OK, This is a little trickier..
  • First you need a copy of the APK you want to install during the build. Do I need to tell you not to install paid versions unless the ROM is solely for you???
  • Then copy the APK into ~/aokp_jb/vendor/aokp/prebuilt/common/app
  • Now we need to modify 2 Files to incorporate the APK into the Build.
  • The first is ~/aokp_jb/vendor/aokp/prebuilt/Android.mk
  • You'll need to add the following code (For this example, we'll assume we are adding the DashClock APK):
    Code:
    include $(CLEAR_VARS)
    LOCAL_MODULE := DashClock
    LOCAL_MODULE_OWNER := aokp
    LOCAL_SRC_FILES := common/app/$(LOCAL_MODULE).apk
    LOCAL_MODULE_TAGS := optional
    LOCAL_MODULE_SUFFIX := .apk
    LOCAL_MODULE_CLASS := APPS
    LOCAL_CERTIFICATE := PRESIGNED
    include $(BUILD_PREBUILT)
  • The next file to edit is ~/aokp_jb/vendor/aokp/configs/common.mk
  • Here you just need to add DashClock in the same format as the other APKs like this:

    Code:
    PRODUCT_PACKAGES += \
        AOKPtips \
        AppWidgetPicker \
        DashClock \
        LatinImeDictionaryPack \
        Microbes \
        NovaLauncher \
        PerformanceControl \
        ROMControl \
        Superuser \
        su \
        SwagPapers \
        Torch \
        UnicornPorn

That's it. Now when you build you'll see that the APKs you added are built in and annotated as pre-signed!
Last edited by TheByteSmasher; 10th April 2013 at 05:21 PM.
The Following 7 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
2nd April 2013, 02:51 AM   |  #10  
TheByteSmasher's Avatar
OP Recognized Contributor
Flag Atlantis
Thanks Meter: 705
 
995 posts
Join Date:Joined: Jan 2010
Donate to Me
More
9. Bash Scripting Autonomy
9. Bash Scripting Autonomy

Bash scripting is an easy tool to create an automated method to perform all of the multi-step functions we've covered already. To create a bash script open a new empty document by right clicking and selecting "create new document", then "empty document". Name it something convenient to the task you want to accomplish with the extension ".sh" like "makemako.sh" Obviously omit the quotes. Open the file.

for a bash script the first line should be:

Code:
#!/bin/bash
Then put all the commands you want in the order you want. For this example, I will show you a script to make a MAKO build incorporating all of the previous elements we've covered so far.

Code:
#! /bin/bash

cd ~/aokp_jb
PATH=~/bin:$PATH
make clobber

export USE_CCACHE=1
wait
export CCACHE_DIR=/home/thebytesmasher/.ccache
wait
prebuilts/misc/linux-x86/ccache/ccache -M 20G
wait
startBuildTimeM=$(date +%r)
. build/envsetup.sh && brunch mako aokp_mako-userdebug -j32
wait
endBuildTimeM=$(date +%r)

echo " "
echo "Build Time: $startBuildTimeM"
echo "Finished: $endBuildTimeM"

cd ~/aokp_jb/out/target/product/mako/
file=$(echo aokp_mako_Purely_Merged*.zip)
cp $file /home/thebytesmasher/Desktop/Latest_Builds/mako/
echo ""
echo "File copy complete"
I used the command "wait" in between operations to ensure they complete prior to commencing the next. Additionally I created Start and Stop variables called "startBuildTimeM" and "endBuildTimeM" to display (echo "") the start and stop times so I can find out exactly how long the build took to make. Also in this command, I specified a ccache size of 20GB.

Next, right-click on the newly created script and go to the permissions tab and select "Allow executing file as a program" as seen below:



Doing this allows you to double click the script and select "Run in Terminal" to execute your script. Later on it will be necessary to have this box checked to allow a launcher to work.

Basically, you can make scripts to automate all of your tasks. The next section, Creating Launchers will simplify the process even more.

**Hint: Put all of your scripts into a folder in your Home directory in a folder to keep them out of the way**
Last edited by TheByteSmasher; 10th April 2013 at 02:14 PM.

The Following 4 Users Say Thank You to TheByteSmasher For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
aokp, build aokp, linux, repo, setup
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes