2011年9月2日金曜日

Build Configuration-XDAndroid

With the XDAndroid source checked out, the build system must be configured to build an XDAndroid product for one of the supported targets. Build system configuration is done via a single file in the root of the XDAndroid source tree whose name is buildspec.mk. The following configuration documentation applies to gingerbread and later branches.

NOTE For build configuration options for the froyo branch, please see Froyo Build Configuration.

NOTE For build configuration options for the eclair branch, please see Eclair Build Configuration.

The Android build system will use buildspec.mk to pass a variety of variables to the make program which parses all of the Makefile recipes that comprise the build system. Most of the variables supported by buildspec.mk are self-explanatory, especially after becoming familiar with the basics of an Android system.

[edit]Build System Configuration

Simply create a blank plain-text file in the root of your XDAndroid source tree. Name the file buildspec.mk and edit it with your preferred text editor.

Variables are each defined on their own single line. Similar to other configuration files, anything which proceeds a pound sign (#) is ignored as a comment.

To instruct the build system to generate an XDAndroid system image, the following variables must be defined in buildspec.mk...

# Configure for an XDAndroid user-debugging target.
TARGET_PRODUCT := full_msm
TARGET_BUILD_VARIANT := userdebug
TARGET_BUILD_TYPE := release
TARGET_USERIMAGES_USE_EXT2 := true

The final line in the above example, which enables TARGET_USERIMAGES_USE_EXT2, will have the Android build system generate ext2 filesystems. On the live device, these filesystems are mounted writable. The XDAndroid boot process supports an ext2-based system partition image, named system.ext2 on the SD card. This is highly recommended.

After completing the build configuration and saving the buildspec.mk file, you can proceed with Building and Packaging the system.

 

Getting the Source-XDAndroid (Memo)

XDAndroid is based on the Android open-source project (AOSP). AOSP is separated into many individual repositories for Android programs, frameworks and utilities. The AOSP source tree also includes third-party open-source libraries and programs, used by the Android system to perform various tasks. For all of these repositories, a utility called repo manages the logistics of checking out, updating and modifying the sources.

The following documentation is based highly on the standard AOSP source checkout procedures.

[edit]Prerequisites

Building an AOSP source tree requires a 64 bit Linux build environment. Currently, there is a dependency on glibc 2.11 which also requires a recent distribution such as Ubuntu 10.04 or newer.

In addition, a number of programs and development packages need to be already installed on the build host. Please check that your system has all of the following packages installed. The procedures for installing required packages varies based on the Linux distribution used on the build host.

˜                     Git (revision control system), version 1.5.4 or higher

˜                     Common source-building utilities: automake, GCC, etc. (the build-essential package on Debian/Ubuntu)

˜                     GNU Privacy Guard (gnupg or gpg)

˜                     Java Development Kit (JDK) 6.0 series (Froyo and earlier require Java Development Kit (JDK) 5.0 series, update 12 or higher.)

˜                     flex, a lexical analyzer

˜                     bison, a parser generator

˜                     gperf, a hash function generator

˜                     libsdl and its development files

˜                     esound (libesd0) and its development files

˜                     WxWidgets GTK 2.6 (libwxgtk2.6) and its development files

˜                     zip, a Zip-archive program

˜                     curl, an HTTP (and others) client and library


An example of installing these packages on Ubuntu/Debian:

$ sudo apt-get install git-core build-essential gnupg flex bison gperf libsdl-dev esound zip curl libwxgtk2.6-0 libc6-dev-i386 g++-multilib lib32z1-dev lib32ncurses5-dev java-common openjdk-6-jdk


If multiple versions of Java JREs or JDKs are available, the system must be configured to use JDK-6 by default. On Debian/Ubuntu systems, this can be done via
 sudo update-java-alternatives -s java-6-openjdk.

Froyo and Earlier Builds: Ubuntu Lucid (10.04) no longer supports Java 5. Please see the following procedure for adding the needed packages and repositories to your Ubuntu Lucid system...

As root, create a new file in /etc/apt/sources.list.d/ named jaunty.list. Inside the file, add the following two lines:

deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse

These sources may also be added via the user interface program, under System -> Administration -> Software Sources.

After that, update your local packages list and install the package:

$ sudo apt-get update
$ sudo apt-get install sun-java5-jdk

The build host will also need at least 1.5GiB of RAM and 10GiB of disk space for the Android build. The initial checkout of the source tree will require up to 2GiB of disk space.

[edit]Installing repo

It is recommended that repo be installed in a normal user's ~/bin directory.

$ mkdir ~/bin
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod +x ~/bin/repo
$ PATH=~/bin:$PATH

[edit]Initialize repo And Check Out the Source

The XDAndroid project maintains its own manifest for the repo program. This manifest contains a list of all repositories that repo must clone. The XDAndroid manifest directs repo to download variants of certain pieces of AOSP that require modifications for our devices.

The following examples assume you will be checking out the source tree into the directory ~/xdandroid.

$ mkdir ~/xdandroid
$ cd ~/xdandroid
$ repo init -u git://gitorious.org/xdandroid/manifest.git -b gingerbread
$ repo sync

Your tree can be initialized to track a specific branch by adding -b <branch_name> to the end of the repo init command. For example, to grab the froyo source tree, which will then not be forwarded to gingerbread (and any subsequent releases), the following repo init command would be used:

$ repo init -u git://gitorious.org/xdandroid/manifest.git -b froyo

WARNING The master branch is currently broken. Please use a named release branch, such as gingerbread or froyo.

Without a -b <branch_name> argument, the repositories will track the HEAD branch (master for most of the repositories), which will always be the latest released AOSP tree, with live development.

Wait quite a while and your XDAndroid source tree will be checked out. This will download up to 2GiB of data, so it may take a long time depending on your Internet connection's capacity, or traffic to the source repository servers, etc.

After the conclusion of this process, the build tree may be configured. See Build Configuration.