Android compile from sources

Материал из Toshiba AC100 wiki
Перейти к: навигация, поиск

How to compile Android CM for AC100 from sources


Build Enviroment

I use openSUSE 13.1 x64 as build enviroment. When installing 13.1 dont forget to choose this software package patterns:

Base Development
C/C++ Development
Java Development
Linux Kernel Development
Python Development
Perl Development

Or install patterns from terminal:

sudo zypper install -t devel_basis pattern devel_C_C++ devel_java devel_kernel devel_perl devel_python

Also add some additional packages:

zip
lzop
libxml2-tools

Install Oracle JDK following this guide http://en.opensuse.org/SDB:Installing_Java [ TODO: try java-1_7_0-openjdk-devel ]

Get Sources

Download repo tool and place it into path, latest repo url is here: http://source.android.com/source/downloading.html

Set your name and e-mail in git:

git config --global user.name "John Doe"
git config --global user.email [email protected]

Create directory for source for example:

mkdir ~/src/cm-ac100
cd ~/src/cm-ac100

Initialize jellybean repo:

repo init -u git://github.com/CyanogenMod/android.git -b jellybean
curl --create-dirs -L -o .repo/local_manifests/local_manifest.xml -O -L https://raw.githubusercontent.com/cm-paz00/cm-paz00/jellybean/local_manifest.xml

Initialize 11.0 repo:

repo init -u git://github.com/zombah/android.git -b cm-11.0-ac100

for 10.2 use this:

repo init -u git://github.com/zombah/android.git -b cm-10.2-ac100

for 10.1 use this:

repo init -u git://github.com/zombah/android.git -b cm-10.1-ac100

After repo initialized download sources:

repo sync -j16

If you see "unable to connect to github.com" errors, disable firewall and try sync again.

Compile

After all sources downloaded, prepare android build enviroment:

source ./build/envsetup.sh

Download prebuilt packages:

cd vendor/cm
./get-prebuilts
cd ../..

Choose AC100 configuration:

lunch cm_ac100-userdebug

Start source compilation:

make -j16 otapackage 2>&1 | tee ~/src/my-compile-log

When you need to clean compiled binaries:

make -j16 clobber

Rebuild after code change

For example something is modified in device/toshiba/paz00-common/audio but rebuilding whole base is too long, here is how to rebuild only changed part

cd ~/src/cm-11.0
make installclean
cd device/toshiba/paz00-common/audio
mm -B
cd ~/src/cm-11.0
make otapackage

Multiple Java versions

I use openSUSE, update-alternatives may be different for other dists.
Use update-alternatives to switch to specific version

 1 #!/bin/sh
 2 # cm-11
 3 ##sudo /usr/sbin/update-alternatives --set java /usr/java/jdk1.6.0_35/bin/java
 4 ##sudo /usr/sbin/update-alternatives --set javac /usr/java/jdk1.6.0_35/bin/javac
 5 # cm-12+
 6 #sudo /usr/sbin/update-alternatives --set java /usr/lib64/jvm/jre-1.7.0-openjdk/bin/java
 7 #sudo /usr/sbin/update-alternatives --set javac /usr/lib64/jvm/java-1.7.0-openjdk/bin/javac
 8 # cm-14+
 9 sudo /usr/sbin/update-alternatives --set java /usr/lib64/jvm/jre-1.8.0-openjdk/bin/java
10 sudo /usr/sbin/update-alternatives --set javac /usr/lib64/jvm/java-1.8.0-openjdk/bin/javac

Use .bashrc or .profile

export PATH=$PATH:$JAVA_HOME:$ANDROID_JAVA_HOME
# cm-11
##export JAVA_HOME=/usr/java/jdk1.6.0_35
##export ANDROID_JAVA_HOME=/usr/java/jdk1.6.0_35
# cm-12+
##export JAVA_HOME=/usr/lib64/jvm/java-1.7.0-openjdk/
##export ANDROID_JAVA_HOME=/usr/lib64/jvm/java-1.7.0-openjdk/
# cm-14+
export JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk/
export ANDROID_JAVA_HOME=/usr/lib64/jvm/java-1.8.0-openjdk/