在newsgroup上找到一篇新的关于android build system的FAQ,讲的非常详细,原地址在这里:http://groups.google.com/group/android-building/msg/56676963a5616b57
Outdated Build system documentation
"http://source.android.com/porting/build_system.html"
In general, the key thing to note is that android build system is
non-recursive. For more on recursive vs non-recursive, please see
GNU Make Recursion
"http://www.gnu.org/s/hello/manual/make/Recursion.html"
Why recursion is harmful
"http://www.google.co.in/url?
sa=t&source=web&cd=1&ved=0CBkQFjAA&url=http%3A%2F
%2Faegis.sourceforge.net
%2Fauug97.pdf&ei=nWmITZonhLywA9KqjYIM&usg=AFQjCNHNpBwPrZj4wjVZcyFfqmagq0M2JQ&sig2=d0fecnqbexy71nytu4PguQ"
= FAQ =
All the commands mentioned here are from top of the tree and assume
you've already setup your environment with
$ source build/envsetup.sh
$ choosecombo
== What java version is my build using? ==
In Gingerbread, your JAVA_HOME is set to '''/usr/lib/jvm/java-6-sun'''
by build/envsetup.sh. You may see errors if you do not have JAVA 1.6
installed.
$ echo $JAVA_HOME # should return empty
$ source build/envsetup.sh # will set your JAVA_HOME if it's empty,
will honor the existing value otherwise
$ which java
$ java -version
$ javac -version
=== Related Build Error: method does not override a method from its
superclass. @Override ===
This "error" is due to a difference in the meaning of @Override
between Java 1.5 and Java 1.6: Java 1.6 added the ability to use
@Override to indicate that a method implements an interface method
[which this code does].
You should be able to compile this code without error if you use a
Java 1.6 compiler (the 'java -version' command only shows the JRE
version. Use 'javac -version' to get the compiler version and adjust
your path accordingly).
== What are the various build variants and their usage ==
Android build system supports the following build variants
*user
*userdebug
*eng
*tests
For more on their usage and meaning, please see the Android Build
Variants wiki
"http://source.android.com/porting/build_system.html#androidBuildVariants"
You can build these variants as follows
$ cd WORKSPACE Alternatively, you can run $ make PRODUCT- Note that '''choosecombo''' doesn't support tests variant. More == Where is the build log? == $ make 2>&1 | tee log == How do I clean the build? == You can use '''dataclean''' to clean the staging area for your data $ make dataclean # will rm -rf $(PRODUCT_OUT)/data/*, data-qemu/*, You can use '''installclean''' while switching between build variants $ choosecombo 1 1 Clean and clobber, both will remove the entire build dir $ make clean # Remove all builds for current and past targets, does == What is a module? == In android build system, an Android.mk file defines how you build. An A single Android.mk can build multiple modules. == How do I rebuild my module? == If you have a 'LOCAL_MODULE := foobar' in your Android.mk, you should $ make foobar == How do I build multiple modules in a dir? == These are build utilities provided by build/envsetup.sh. Here's a - croot: Changes directory to the top of the tree. Note that 'm' and 'mm' need a toplevel Android.mk in the directory you Example usage $ cd dalvik/tests == How do I turn off prelinking for my module? == Add LOCAL_PRELINK_MODULE := false For the module in your Android.mk LOCAL_PRELINK_MODULE is set to false == How do I see what commands make is running? == You can use the '''showcommands''' modifier target. Usage == How do I find out what are the available modules? == $ cd $some_dir_with_an_Android.mk You can also run 'make' to see the list of all the modules available == How do I clean a single module/package? == $ croot == How do I rebuild system image for an existing build? == $ make snod === What is snod? === 'snod' is a pseduo-target provided by build/core/Makefile. You can use $ make framework snod # rebuilds framework module, and system image == How do I build multiple variants and targets? == Note: this script. is broken in gingerbread. $ source build/tools/check_builds.sh Additionally you can run $ check_builds What this will do for you, according to check_build.sh comments: # Go get dinner, and when you get back, there will be a file == How do I find what build properties are available for my build and out/target/product/$(TARGET_PRODUCT)/build.prop This file is created/updated by build/core/Makefile (invoked by build/ == App development == $ cd your_app_folder If you don't use the same machine for compilation and loading it is == How do I build my binary/library/applicaton? == In general, refer to the build cookbook "http://source.android.com/ In summary, 'user' tags cannot be used, they are used only for legacy 'optional' tags makes sure that the module gets installed into user PRODUCT_PACKAGES for proprietary modules is defined in the device- Opensource modules are defined in device/ The 'eng' tag implies that the module will be picked up only by 'eng' The tests tag implies that the module will be picked up by tests Do not use development (or any other tags not sanctioned by the == My binary/library isn't available on target, whats wrong? == Check if you've updated the appropriate .mk configuration file to Check the build log to see if your module got built. You can also use == I don't want to build everything, takes too long. What do I do? == You can build "tiny android," an Android build with a limited $ BUILD_TINY_ANDROID=true make -j4 === How do I use a prebuilt kernel? === The kernel objects, vmlinux and zImage will be at $ make -j4 TARGET_PREBUILT_KERNEL=" === error: do_inode_allocate_extents: Failed to allocate blocks === == Misc == === If you want to see all warnings in a pretty format, do === See the html page for a nice classification for all the warnings on === What is the 'simulator' in lunch for? === "the simulator is somewhat maintained, but it's a very specialized See this thread for more detail === How do I rebuild the sdk? === $ make PRODUCT-sdk-sdk == What is the difference between board, target, product and device? == Android build system supports hierarchical layering of product, === TARGET === From a Build perspective, these are TARGET_PRODUCT: identifies the product that you are building From a PRODUCT perspective, these are TARGET_PRODUCT: identifies the product, for example, full_crespo, === BOARD === In Android Build System, BOARD refers to the schematics of a product === DEVICE === For OEMs, DEVICE refers to the physical layer of plastic on the device Each of these devices may result === PRODUCT === == How do I add a new target? == == How do I add a new product? == Android products use inheritance, you can generate a nice product $ sudo apt-get install graphviz == PRODUCT CONFIGURATION == You can choose what goes into a product, by adding to the === How do I generate a product graph === === What is device-vendor.mk, when do I modify it? === device-vendor.mk allows you to configure proprietary modules to be Starting with Gingerbread the Android build system enforces an When LOCAL_MODULE_TAGS of a module is defined with an "optional" tag, To get the module available in final image/s, module has to be part of === What is device/ The opensource counter part of device-vendor.mk [prev question] is === How do I configure (enable/disable) a module? === What gets installed can be configured at a product level using the Controlling what get's built, is a more complicated story. Presently, * Add/Remove Android.mk If you want your module to not be built for variants not supported by $(CLEAR_VARS) What this will do for you is == Emulator == "http://developer.android.com/guide/developing/devices/emulator.html === How is it used? === external/qemu The one in external/qemu produces an executable called "emulator" There are two such target products available target/product/generic They use the following boards from target/board, respectively target/board/generic (There's also an 'emulator' board available under target/board for target/board/*/README.txt explains the existence and usage of all More documentation about the sdk emulator and it's usage at Emulator usage example == How do I rebuild the emulator? == "http://groups.google.com/group/android-building/browse_thread/thread/
$ source build/envsetup.sh
$ choosecombo 1 1
$ choosecombo 1 1
$ choosecombo 1 1
$ make PRODUCT-
$ make PRODUCT-
details on
tests variant TBD.
You can save one for yourself with
partition
userdata-qemu.img
$ make installclean # deletes all of the files that change between
different
build types
$ choosecombo 1 1
rm -rf
$(OUT_DIR)
$ make clobber # Remove all builds for current and past targets
android module is the entity you are building and is specified by
variable LOCAL_MODULE in the Android.mk
be able to do
== What are m, mm, mmm? ==
description of all the available utilities
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory.
- mmm: Builds all of the modules in the supplied directories.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- mgrep: Greps on all makefiles
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file
- printconfig: tells you what configuration you are currently
building
use them on.
$ mm
$ mmm ../tools
$ godir Atomic.h
$ m
$ croot
by default for executables (built using BUILD_EXECUTABLE)
What is does (build/core/config.mk)
# The 'showcommands' goal says to show the full command
# lines being executed, instead of a short message about
# the kind of operation being done.
SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
$ make showcommands
$ cd $some_dir_with_an_Android.mk
$ mm showcommands
$ mm modules
in your tree
$ croot
$ make modules
$ make clean-$(LOCAL_MODULE)
it to rebuild your system image without following it's dependencies
and rebuilding everything else, apart from what you provide to make.
Example use cases
$ golden_builds
# test-builds/sizes.html that has a pretty chart of which files are
# in which tree, and how big they are.
how they were derived? ==
Post a full build, build properties can be examined in
core/main.mk). The file is a concatentation of build/tools/
buildinfo.sh output + your system.prop + $ADDITIONAL_BUILD_PROPERTIES
$ mmm
$ adb sync
possible to forward the port used by adb (5037) to the PC connected to
the device.
If it's a linux machine, it is a lot easier, but it is possible to
forward ports from windows.
Fastboot still has to be run on the connected machine, but since it
only needs a few image files it is easier to coordinate.
porting/build_cookbook.html" You can also look at existing Android.mk
files in your source tree. If you are tagging your module with
"optional".
modules (Grandfathered).
and eng builds as long as you add that module name to the list of
packages (PRODUCT_PACKAGES).
vendor.mk file, e.g. vendor/
common.mk
variant of the build.
variant of the build. The tests variant is not available from choosecombo.
android build system)
include a PRODUCT_PACKAGES entry for the module.
'mm' with 'showcommands' to see if the module is being built & installed.
userspace that is useful for kernel development and verification. The tiny android
build will not boot into the full UI. It will stay at one of the loading screens
(ANDROID_ - not the boot animation). ADB will be active, allowing you
to run unit tests, etc. The build time for tiny android is significantly less
than a full Android build. Tiny Android builds complete in less than 2
minutes, whereas a full Android build takes over 20 minutes.
target/product/
can override the TARGET_PREBUILT_KERNEL flag with your own kernel
image to build android with your kernel, as follows:
zImage"
One way to workaround this is to increase the system image size.
Please see BOARD_*_PARTITION_SIZE variables in device/
$ build/tool/warn.py my_build_log > warn.html
your product.
and very fragile tool which is only used by a handful of people at
Google.
It is likely to require the very precise environment that those
people" use, which is specific to Google and isn't publicly available."
"http://groups.google.com/group/android-building/browse_thread/thread/
55521a7849bbac1a/e4e020a8213cf7c7?lnk=gst&q=generic
+product#e4e020a8213cf7c7"
device, board, and arch in a one to many relationship as described at
"http://source.android.com/porting/build_system.html#androidBuildSystemLayers"
In Android Build System, 'target' or 'TARGET' refers to your build
target. There are a bunch of variables associated with a target.
TARGET_BUILD_TYPE: identifies the build type from one of 'release,
debug'
TARGET_BUILD_VARIANT: identifies the build variant from one of 'user,
userdebug, eng, tests'
passion_us, passion_eu
TARGET_DEVICE: identifies the device, for example, full_crespo,
passion
TARGET_BOARD_PLATFORM. can be used for a family of boards, for
example, qsd8k, msm7k
TARGET_BOOTLOADER_BOARD_NAME: used by OEMs for their boards, and by
chipset_variants. For example, mahimahi of htc, full_crespo
TARGET_ARCH: arm/x86
TARGET_ARCH_VARIANT: armv5/armv7
"http://source.android.com/porting/
build_system.html#androidBuildSystemLayers"
"http://source.android.com/porting/
build_system.html#androidBuildSystemLayers"
into multiple products. Examples
* crespo # Samsung
* passion # HTC
The product layer represents a complete specification of a shipping
product
"http://source.android.com/porting/
build_system.html#androidBuildSystemLayers"
Adding a new target means adding a new product. You can name your
product as chipset_variant. Note that if one product may suffice for
all your chipset variants.
Follow the instructions for configuring a new product "http://source.android.com/porting/build_new_device.html" for general info.
graph using
$ make product-graph # pdf goes in out/product.pdf
In general, android build system builds products, and allows you to
configure what goes into a product. It doesn't explicitly support
configuration at a build level, in allowing you to choose what to
build. A typical android build is supposed to build all possible code
that is available
"http://android.git.kernel.org/?p=platform/build.git;a=blob;f=core/
main.mk;h=3877bb2b784da528fc20d66dc2701bdb0e3703b5;hb=HEAD"
see build/core/main.mk line 638-639.
PRODUCT_PACKAGES list which is used to specify what additional
packages go into a product, as follows.
$ sudo apt-get install graphviz
$ make product-graph # pdf goes in out/product.pdf
installed on the target images.
explicit LOCAL_MODULES_TAGS for all modules which aren't in the GRANDFATHERED MODULES
list in "http://android.git.kernel.org/?p=platform/build.git;a=blob;f=core/user_tags.mk;h=3eade8aa840e5c2fe0c31babf7b437d3fdf37feb;hb=HEAD" and recommends using "optional" tag for modules which are expected to be in all builds of a product.
the module will not be available in the generated final image/s (which
will be flashed on Target).
PRODUCT_PACKAGES list.
device/
opensource modules to PRODUCT_PACKAGES.
Configuration has two aspects with respect to Android Build System
* What gets installed
* What gets built
device-vendor.mk and common.mk configuration files, described above
[prev questions].
for a typical build android build system builds all modules it can
find using findleaves.py [See modules_to_install and modules_to_check
in build/core/main.mk]. The two ways to enable/disable a module then
are
* Wrap the Android.mk in TARGET_PRODUCT if you don't want to build
your
* modules for products like generic, emulator etc.
your LOCAL_MODULE_TAGS, you can define LOCAL_DONT_CHECK_MODULE, though it is not recommended by android build system as of now. Example,
LOCAL_DONT_CHECK_MODULE := true
LOCAL_MODULE := foo
LOCAL_MODULE_TAGS := eng
* For all non-eng builds, your module will only be built if it's a
dependency
* of another module
* Else, it will be ignored
=== What is the emulator? ===
From the AOSP WIKI documentation: "The Android SDK includes a mobile
device emulator -- a virtual mobile device that runs on your computer.
The emulator lets you develop and test Android applications without
using a physical device."
Emulator Overview"
The emulator is provided by
sdk/emulator
prebuilt/linux-x86/emulator
which can be used from the commandline. It get's built and installed
in out/host/linux-x86/bin/emulator and can be used with the images
generated by building the 'generic' products provided in the AOSP
tree. The AOSP tree provides "non-hardware-specific targets" which can
be used "to build entire user-level system and work with emulator".
target/product/generic_x86
target/board/generic_x86
which there's no emulator.mk under target/product, device/ or vendor/ which
is where envsetup.sh looks for product makefiles, and so it doesn't show up in
choosecombo)
three, generic, generic_x86, emulator.
"http://developer.android.com/guide/developing/tools/emulator.html
developer guide for emulator"
"http://groups.google.com/group/android-platform/browse_thread/thread/
b115c4cadbfdb333/488ca1b48bc546d8?lnk=gst&q=generic
+product#488ca1b48bc546d8"
f8f0c3bacd6efae/05ec2449d4e5dc6f?lnk=gst&q=emulator#05ec2449d4e5dc6f"
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/291731/viewspace-697468/,如需转载,请注明出处,否则将追究法律责任。