Android 编译摘要

> 编译选项的help

liuxu@liuxu:~/workspace/froyo_td$ help
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- croot:   Changes directory to the top of the tree.
- 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.
- resgrep: Greps on all local res/*.xml files.
- godir:   Go to the directory containing a file.

Look at the source to view more functions. The complete list is:
add_lunch_combo cgrep check_product check_variant choosecombo chooseproduct choosetype choosevariant cproj croot findmakefile gdbclient get_abs_build_var getbugreports get_build_var getprebuilt gettop godir help isviewserverstarted jgrep lunch m mm mmm pid printconfig print_lunch_menu resgrep runhat runtest setpaths set_sequence_number set_stuff_for_environment settitle smoketest startviewserver stopviewserver systemstack tapas tracedmdump

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 编译命令

liuxu@liuxu:~/workspace/froyo_td$ . build/envsetup.sh
including device/htc/dream/vendorsetup.sh
including device/htc/passion/vendorsetup.sh
including device/htc/sapphire/vendorsetup.sh
including device/lenovo/rainbow/vendorsetup.sh
liuxu@liuxu:~/workspace/froyo_td$ lunch

You're building on Linux

Lunch menu... pick a combo:
     1. generic-eng
     2. simulator
     3. full_dream-userdebug
     4. full_passion-userdebug
     5. full_sapphire-userdebug
     6. rainbow-userdebug

Which would you like? [generic-eng] 6

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2.1
TARGET_PRODUCT=rainbow
TARGET_BUILD_VARIANT=userdebug
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=FRG83
============================================
liuxu@liuxu:~/workspace/froyo_td$ choosecombo
Build for the simulator or the device?
     1. Device
     2. Simulator

Which would you like? [1]


Build type choices are:
     1. release
     2. debug

Which would you like? [1]


Which product would you like? [rainbow]


Variant choices are:
     1. user
     2. userdebug
     3. eng
Which would you like? [eng] 2

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2.1
TARGET_PRODUCT=rainbow
TARGET_BUILD_VARIANT=userdebug
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=FRG83
============================================



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Android编译系统

1.            Android编译系统

编译脚本主要位置:

*.mk

build/core/

build/tools/

build/envsetup.sh:定义函数mm,mmm,choosecombo等;
2.            模块编译
2.1       Java模块

通常Java模块的编译提供一个Android.mk就可以了。

LOCAL_PACKAGE_NAME:模块名。

LOCAL_SRC_FILES:代码;
2.2       C/C++模块

通常C/C++模块的编译提供一个Android.mk就可以了。

LOCAL_MODULE:模块名;

LOCAL_SRC_FILES:编译的源文件;

LOCAL_C_INCLUDES:需要包含的头文件目录;

LOCAL_SHARED_LIBRARIES:链接时需要的外部库;

LOCAL_PRELINK_MODULE:是否需要prelink处理;

BUILD_SHARED_LIBRARY:指明要编译成动态库;

LOCAL_PATH:编译时的目录;

http://linux.chinaunix.net/techdoc/beginner/2009/10/25/1141239.shtml

http://heaven.branda.to/~thinker/GinGin_CGI.py/show_id_doc/393
2.3           build/envsetup.sh

定义函数mm,mmm,choosecombo等。
2.4           choosecombo

定义于:build/envsetup.sh。

function choosecombo()

{

    choosesim $1

//选择模拟器类型,echo $TARGET_SIMULATOR,值为   

//     1. Device

//     2. Simulator

    echo

    echo

    choosetype $2

//选择编译类型,echo $TARGET_BUILD_TYPE

//     1. release

//     2. debug

    echo

    echo

    chooseproduct $3

//选择产品类型,echo $TARGET_PRODUCT,如abcde

    echo

    echo

    choosevariant $4

//选择编译变量,echo $TARGET_BUILD_VARIANT

//     1. user

//     2. userdebug

//     3. eng

    echo

    set_stuff_for_environment

    printconfig

}  

综上,choosecombo选择这些命令后,把所有的用户选择信息输出在环境变量之中。所以,如果重新打开shell,需要重新选择,否则原有的配置信息丢失。
2.5           vendor/vendorabc/abcde/BoardConfig.mk

config输出:

system/core/include/arch/linux-arm/AndroidConfig.h
2.5.1      BOARD_HAVE_BLUETOOTH

主要引用处:frameworks/base/libs/audioflinger/。

实验:如何通过设置BOARD_HAVE_BLUETOOTH来避免编译蓝牙。

办法:删除 rm -rf  out/target/product/abcde/obj/STATIC_LIBRARIES/libaudiointerface_intermediates/ -rf

在vendor/vendorabc/abcde/BoardConfig.mk加入BOARD_HAVE_BLUETOOTH := false,才可以让宏BOARD_HAVE_BLUETOOTH生效.
2.5.2      TARGET_CPU_ABI

引用处:build/core/
2.6           build/core/

device.mk

prelink-linux-arm.map
2.7           build/core/Makefile
2.7.1      system.img制作

system.img的制作是由build/core/Makefile的宏build-systemimage-target调用MKYAFFS2来完成的。

命令MKYAFFS2定义于build/core/config.mk:

MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)

图 system.img制作流程
2.7.2      prop设定

 
2.8           build/core/ definitions.mk

transform-java-to-classes.jar

create-resource-java-files

transform-host-o-to-executable-inner

transform-o-to-executable-inner

transform-o-to-shared-lib-inner

transform-host-c-or-s-to-o-no-deps

transform-host-cpp-to-o

transform-cpp-to-o

你可能感兴趣的:(Android 编译摘要)