Jump to content

  1. 0
  2. 0
  3. 0/5

Rate this Topic

* * * * *
17 votes

[TUTORIAL] Building AOKP [Ubuntu 12.04+]

  • Please log in to reply

OP ProTekk

ProTekk

Developer

Posted 27 July 2012 - 03:11 AM #1

Build Environment
  • Linux based operating system -- Tested on Ubuntu 12.04, 12.10, 13.04 (64bit)
  • Terminal
  • Decent hardware (minimum of at least a dual core CPU and 4 GB of RAM)
  • Optimally have an SSD (standard mechanical drives work as well but slow down the process drastically)
  • Must have required packages for building installed, I will list them further down

Required Packages (based on Initializing a Build Environment)
Based on the version of Linux you run you might need to install slightly different packages. The following is for Ubuntu 12.04 and later:
sudo apt-get install git 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 tofrodos \  python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \  pngcrush schedtool

After installing the packages you need to create a symlink:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so


IMPORTANT
It is recommended to build Android using the Oracle JDK 6. However it is no longer available as package in Ubuntu. A good source is http://www.webupd8.org
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer
sudo update-java-alternatives -s java-6-oracle
sudo apt-get install oracle-java6-set-default


Obtaining repo
Make directory for repo binary
mkdir ~/bin
Add directory for repo binary to your path
PATH=~/bin:$PATH
Download repo binary and place it in the proper directory
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
Give the repo binary the proper permissions
chmod a+x ~/bin/repo
Create directory for where the AOKP repo will be stored and synced
mkdir ~/aokp
Move to our new AOKP directory
cd ~/aokp


Download the source
Please read the AOSP building instructions before proceeding. Initialize
repo init -u https://github.com/AOKP/platform_manifest.git -b jb-mr1
Run the following to sync the source
repo sync


Download the kernel source
Integrated kernel building is now required to compile AOKP for all supported devices (even Nexus devices!) From the root of your source tree, run the following script to grab the kernel sources required
. ./platform_manifest/manual_add_kernel_manifest.sh


Advanced users: Since the kernel trees are fairly large, you may want to sync only specific kernel trees for devices you build for, take a look at the file .repo/local_manifests/kernel_manifest.xml. You can edit this file to suite your needs.


Building
After the sync is finished, please read the instructions from the Android site on how to build.
. build/envsetup.shbrunch
You can also build (and see how long it took) for specific devices like this:
. build/envsetup.shtime brunch aokp_mako-userdebug

Remember to
make clobber
every now and then!


Setting up ccache (Optional)
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products. Put the following in your .bashrc or equivalent.
export USE_CCACHE=1

By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.
export CCACHE_DIR=

The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code:
. prebuilts/misc/linux-x86/ccache/ccache -M 50G

This setting is stored in the CCACHE_DIR and is persistent.
  • 79 Likes
HTC DROID Incredible - Retired
HTC Thunderbolt - Retired
HTC DROID Incredible 2 - Retired
Samsung Galaxy Nexus - Daily Driver
HP TouchPad 32 GB
http://www.twitter.com/ProTekkFZS

OP ProTekk

ProTekk

Developer

Posted 27 July 2012 - 03:12 AM #2

Reserved.
  • 2 Likes
HTC DROID Incredible - Retired
HTC Thunderbolt - Retired
HTC DROID Incredible 2 - Retired
Samsung Galaxy Nexus - Daily Driver
HP TouchPad 32 GB
http://www.twitter.com/ProTekkFZS

wildchld

wildchld

Supporting Member

Posted 27 July 2012 - 04:21 AM #3

Thank you!


Sent from my SGH-T999 using Tapatalk 2
  • 0 Likes

codesplice

codesplice

Good at breaking things

Posted 27 July 2012 - 04:57 AM #4

Thanks for this! I've been stumbling through making some builds over the past few days which seems to be working (after adapting a variety of different tutorials and a bit of guesswork). This confirms I'm on the right path!

One issue I've repeatedly run into... all my builds seem to be missing /system/etc/audio_policy.conf, which makes all audio go over the speaker no matter what. Any hints on what I may be messing up?

And finally... for repeating builds, I assume all that is necessary is:

cd ~/aokp_jb
make clobber
repo sync
. build/envsetup.sh && brunch <target>

I read some on source.android.com about enabling CCACHE, but that doesn't appear (to my n00b eyes) to be an option when building AOKP - is this correct?

Thanks again!

... one more thing: I had been using "lunch" followed by "make otapackage" to build; now trying using "brunch maguro" I get a notice that "schedtool" is not installed. No biggie to install, just wondering if I missed something along the way.

Edited by codesplice, 27 July 2012 - 05:28 AM.

  • 1 Likes

OP ProTekk

ProTekk

Developer

Posted 27 July 2012 - 05:31 AM #5

Thanks for this! I've been stumbling through making some builds over the past few days which seems to be working (after adapting a variety of different tutorials and a bit of guesswork). This confirms I'm on the right path!

One issue I've repeatedly run into... all my builds seem to be missing /system/etc/audio_policy.conf, which makes all audio go over the speaker no matter what. Any hints on what I may be messing up?

And finally... for repeating builds, I assume all that is necessary is:

cd ~/aokp_jb
make clobber
repo sync
. build/envsetup.sh && brunch <target>

I read some on source.android.com about enabling CCACHE, but that doesn't appear (to my n00b eyes) to be an option when building AOKP - is this correct?

Thanks again!

... one more thing: I had been using "lunch" followed by "make otapackage" to build; now trying using "brunch maguro" I get a notice that "schedtool" is not installed. No biggie to install, just wondering if I missed something along the way.


For the audio policy config file, that is usually pulled in via your device tree. Might want to take a look at that.

For CCACHE, all AOSP flavors can use it.

For schedutil, just run
sudo apt-get install schedutil pngcrush

  • 2 Likes
HTC DROID Incredible - Retired
HTC Thunderbolt - Retired
HTC DROID Incredible 2 - Retired
Samsung Galaxy Nexus - Daily Driver
HP TouchPad 32 GB
http://www.twitter.com/ProTekkFZS

codesplice

codesplice

Good at breaking things

Posted 27 July 2012 - 05:49 AM #6

For the audio policy config file, that is usually pulled in via your device tree. Might want to take a look at that.

For CCACHE, all AOSP flavors can use it.

For schedutil, just run

sudo apt-get install schedutil pngcrush


Thanks again for the help. I'm doing my best to learn this, but there just seem to be a few things that don't quite match up (maybe just in my mind). I'm eternally grateful to those who go out of their way to help me help myself :)

For the device tree, does that refer to the ~/aokp_jb/device directory tree, or is it something else? I have confirmed that ~/aokp_jb/device/samsung/tuna/audio/audio_policy.conf does exist. What else should I check? In the meantime, manually copying that file over to /system/etc/ after flashing my build seems to work fine so it's not a huge huge issue.

And thanks for the info on ccache. I guess I was stumped a bit since it didn't seem to exist under prebuilt/linux-x86/ccache as specified in the source.android.com documentation. Found it at prebuilts/misc/linux-x86/ccache though, so I'll give that a go for my next build.
  • 1 Likes

Parkman

Parkman

Average Android

Posted 27 July 2012 - 06:30 AM #7

I am a big time n00000b at this stuff, so how do we compile this now? Don't laugh!
  • 0 Likes

Parkman

Parkman

Average Android

Posted 27 July 2012 - 06:32 AM #8

Ohh nevermind, thats basically that last command at the bottom of your post correct?
  • 0 Likes

codesplice

codesplice

Good at breaking things

Posted 27 July 2012 - 06:47 AM #9

Ohh nevermind, thats basically that last command at the bottom of your post correct?


Correct. Apparently the "brunch" command combines the "lunch" command (which effectively specifies the build target - that is, the device the build will be for) with the "make otapackage" command, which actually kicks off the compiling.

I think. I'm also king n00b.
  • 0 Likes

xchor

xchor

Average Android

Posted 27 July 2012 - 07:00 AM #10

For the audio policy config file, that is usually pulled in via your device tree. Might want to take a look at that.

For CCACHE, all AOSP flavors can use it.

For schedutil, just run

sudo apt-get install schedutil pngcrush


For me, I ran
sudo apt-get install schedtool
instead of schedutil running 12.04 if it makes a difference.
  • 2 Likes