Initialize a Build Environment

Source: Internet
Author: User
Tags gnupg git commands
Initialize a Build Environment

The "Getting started" section describes how to create your local working environment on your machine, how to use repo to obtain Android files, and how to build these files to build Android source files, you will need to use Linux or Mac OS. Built in windows, which is currently not supported.

Note: The source download size is about 6 GB, and you will need 25 GB free to complete a single build, and up to 90 GB (or more) for a full build.

An overview of the entire code review and code update process, depending on the lifetime of a patch.

Select a branch

The requirement for building the environment is determined by the source code of the version you plan to compile. Depending on the number of builds in a full version, you can select a branch from here. You can also choose to download and build the latest source code (called "master"). In this case, you will simply ignore the branch version specifications when you initialize the library.

Once you select a branch, follow the steps below to create your build environment.

Create a Linux Build Environment

These descriptions apply to all branches, including the master branch.

Android build is a regular internal test in Ubuntu lts (10.04), but most releases should provide effective build tools. It is welcome that the submission is successful or fails in other distributions.

Gingerbread (2.3.x) and the latest version, including the master branch, are required in a 64-bit environment. The old version can be compiled on a 32-bit system.

Note: This may also be used to build android on a virtual machine. If you run Linux on a virtual machine,To build an android treeYou will need at least 16 gb ram/swap and 30 GB or more disk space.

Generally, you need:

  • Python 2.5 -- 2.7, you can download from python.org.

  • GNU make 3.81 -- 3.82, you can download from gnu.org,

  • JDK 6 if you want to build or update gingerbread; JDK 5 froyo or the old one. You can download the two
    Java.sun.com.

  • Git 1.7 or update. You can see it in git-scm.com.

The following is a detailed description of ubuntu 10.04 +.

Install JDK

Sun JDK is no longer in the main Ubuntu package library. To download it, you need to add a suitable library and support which JDK should be used by the system.

Java 6: gingerbread and update

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"$ sudo apt-get update$ sudo apt-get install sun-java6-jdk

Java 5: for froyo and the previous

$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"$ sudo apt-get update$ sudo apt-get install sun-java5-jdk

Note:Lunch commandIn the build process, make sure that Sun JDK is used to replace any previously installed JDK.

Install the required package (Ubuntu 10.04 -- 11.10)

You will need a 64-bit ubuntu. Ubuntu 10.04 is recommended. Building a newer version of Ubuntu is currently only supported by the current experiment, and does not guarantee that it works outside the main branch.

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \  x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \  libxml2-utils xsltproc

On Ubuntu 10.10:

$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so

On Ubuntu 11.10:

$ sudo apt-get install libx11-dev:i386
Install the required package (Ubuntu 12.04)

The build on Ubuntu 12.04 is currently only supported by experiments, and does not guarantee that it works outside the main branch.

$ 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$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Configure USB access

In GNU/Linux (UBUNTU), normal users cannot directly access the USB device by default. The system must be specified to allow such access.

The recommended method is to create a file./etc/udev/rules.d/51-android.rules(As the root user) and copy the following rows to it.<username>Must be replaced with the actual user name, authorized to access the USB on the mobile phone.

# adb protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"# fastboot protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"# adb protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"# fastboot protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"# adb protocol on stingray/wingray (Xoom)SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>"# fastboot protocol on stingray/wingray (Xoom)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>"# adb protocol on maguro/toro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"# fastboot protocol on maguro/toro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"# adb protocol on panda (PandaBoard)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>"# fastboot protocol on panda (PandaBoard)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>"# usbboot protocol on panda (PandaBoard)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="<username>"# usbboot protocol on panda (PandaBoard ES)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="<username>"

These new rules take effect the next time the device is inserted. You may need to unplug the device and connect it to your computer.

It is known to work on Ubuntu hard Heron (8.04.x LTs) and lucid Lynx (10.04.x LTs ). Other versions of ubuntu or other variants of GNU/Linux may require different configurations.

Establish ccache

You can selectively tell the ccache compilation tool to build. Ccache acts as a compiler cache and can be used to speed up rebuilding. If you often "make clean", it works very well, or you frequently switch between two different build products.

Put it down to your. bashrc or the same.

export USE_CCACHE=1

By default, the cache will be stored in ~ /. Ccache. Assume that your home directory is based on NFS or some other non-localized file systems, and you want to specify the directory in your. bashrc.

export CCACHE_DIR=<path-to-your-cache-directory>

The recommended cache size is 50-100 GB. Once you download the source code, you need to run the following command.

prebuilt/linux-x86/ccache/ccache -M 50G

This setting is stored in ccache_dir and is persistent.

Use a separate output directory

By default, the output of each build is saved in the out/directory of each machine source code tree.

On some machines with multiple storage devices, building is fast when the source files and output files are stored in separate volumes. With additional performance, the output can be stored in a speed-optimized file system, instead of unexpected, because all files can be regenerated when the file system is destroyed.

Set these and exitOUT_DIR_COMMON_BASEThe variable only misses the place where you want to save the output directory.

export OUT_DIR_COMMON_BASE=<path-to-your-out-directory>

Each separate source tree output directory is named after the directory maintains the source tree.

For example, if your source tree is/source/master1And/source/master2And
OUT_DIR_COMMON_BASE
Is set/Output, the output directory will be/output/master1And/output/master2.

It is important that, in this case, there is no multi-source tree quota, there is a directory with the same name, for these will end sharing an output directory, unpredictable results.

This only supports new branches than 4.0.x (icecreamsandwich.

Create a Mac OS X Build Environment

In a default installation, OS X runs in a reserved but case-insensitive file system. This type of file system does not know how to eat git and will be caused by exceptions in some git commands (such as "Git status. Because of this, we recommend that you always work on aosp source files in case sensitive file systems. This can be quite simple to use a disk image, as discussed below.

Once an appropriate file system is effective, it is very simple to build the main branch in a modern OS X environment. Early branches, including ICS, need some attachments and sdks.

Create a case-sensitive disk image

You can create a case-sensitive file system and use a disk image in your existing OS X environment to run diskutility and select "New Image". A 25 GB file is the smallest build, A bigger number is more future-oriented. When the storage space with sparse images is allowed to grow, it will appear as needed. Select "case sensitive, journaled" as the volume format.

You can also create it from a shell using the following command:

# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmg

This will create a. DMG (or possibly a. DMG. sparsefile) file, which is mounted in a segment and acts as a device and needs to be formatted for Android development. A disk image named "android. DMG" is stored in your home directory. You can add the following to your ~/.bash_profileWhen you run "mountandroid ":

# mount the android file imagefunction mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }

Mount once, you will do all your work in the "android" volume. You can pop it up (uninstall it) Just as you want, just as an external device.

Main Branch

To build the latest source code in a Mac OS environment, you will need an Intel/x86 machine to run MACOs 10.6 (snow leopard) or MACOs 10.7 (Lion), along with xcode4.2 (Apple's development tool ). Although lion does not have a JDK, it will be automatically installed when you try to build the source.

The rest of Mac OS X is only applicable to other branch versions.

Branch 4.0.x and all earlier branches

Build android-4.0.x and branch earlier in an IE Mac OS environment and you need anintel/x86 machines to run MACOs 10.5 (Leopard) or MACOs 10.6 (snow leopard ). You will need the MACOs 10.5 SDK.

Install the required package
  • Install xcode from the apple developer website. We recommend version 3.1.4 or later, that is, GCC 4.2. Version 4.x may cause difficulties. If you have not registered as an apple developer, you need to create an Apple id for download.

  • Install macports from macports.org.

    Note: OK/opt/local/binAppears in your path before/usr/bin. If no, add

    export PATH=/opt/local/bin:$PATH

    To your~/.bash_profile.

  • Get make, git, and GPG packages from macports:

    $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg

    If Mac OS 10.4 is used, install bison:

    $ POSIXLY_CORRECT=1 sudo port install bison
Restore from make 3.82.

In the Android version earlier than ICS, There is a bug in gmake 3.82 to prevent Android construction. To Install Version 3.81 with macports, follow these steps:

  • Edit/opt/local/etc/macports/sources.confAnd a line of insight

    file:///Users/Shared/dports

    On the rsync line, create the directory:

    $ mkdir /Users/Shared/dports
  • In the newdportsDirectory, run

    $ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
  • Create a port index for your new local database:

    $ portindex /Users/Shared/dports
  • Finally, install a long version of gmake

    $ sudo port install gmake @3.81
Sets the description limit of a file.

On MacOS, the number of file descriptors opened at the same time is too low by default. A high parallel build may exceed this limit.

Increase online and add the following lines to your~/.bash_profile:

# set the number of open files to be 1024ulimit -S -n 1024
Below: Download Source

Your build environment is doing well !, Continue to download the source ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.