Android Porting Book--Android Build System
来源:互联网 发布:韩顺平java满汉楼资源 编辑:程序博客网 时间:2024/06/05 09:55
AndroidBuild System
In thisdocument
Understandingthe makefile
Layers
Buildingthe Android Platform
Buildingthe Android Kernel
BuildVariants
Android'sbuild system is make based and requires a recent version of GNU Make(note that Android uses advanced features of GNU Make that may notyet appear on the GNU Make web site). Before continuing, check yourversion of make by running %make -v
.If you don't have version 3.80 or greater, you need to upgradeyour version of make.
Understandingthe makefile
Amakefile defines how to build a particular application. Makefilestypically include all of the following elements:
Name:Give your build a name (
LOCAL_MODULE:= <build_name>
).LocalVariables: Clear local variables with CLEAR_VARS (
include$(CLEAR_VARS)
).Files:Determine which files your application depends upon(
LOCAL_SRC_FILES:= main.c
).Tags:Define tags, as necessary (
LOCAL_MODULE_TAGS:= eng development
).Libraries:Define whether your application links with other libraries(
LOCAL_SHARED_LIBRARIES:= cutils
).Templatefile: Include a template file to define underlining make tools fora particular target (
include$(BUILD_EXECUTABLE)
).
Thefollowing snippet illustrates a typical makefile.
LOCAL_PATH := $(my-dir)include $(CLEAR_VARS)LOCAL_MODULE := <buil_name>LOCAL_SRC_FILES := main.cLOCAL_MODULE_TAGS := eng developmentLOCAL_SHARED_LIBRARIES := cutilsinclude $(BUILD_EXECUTABLE)(HOST_)EXECUTABLE, (HOST_)JAVA_LIBRARY, (HOST_)PREBUILT, (HOST_)SHARED_LIBRARY, (HOST_)STATIC_LIBRARY, PACKAGE, JAVADOC, RAW_EXECUTABLE, RAW_STATIC_LIBRARY, COPY_HEADERS, KEY_CHAR_MAP
Thesnippet above includes artificial line breaks to maintain aprint-friendly document.
Layers
Thebuild hierarchy includes the abstraction layers described in thetable below.
Eachlayer relates to the one above it in a one-to-many relationship. Forexample, an arch can have more than one board and each board canhave more than one device. You may define an element in a givenlayer as a specialization of an element in the same layer, thuseliminating copying and simplifying maintenance.
Layer
Example
Description
Product
myProduct,myProduct_eu, myProduct_eu_fr, j2, sdk
Theproduct layer defines a complete specification of a shippingproduct, defining which modules to build and how to configurethem. You might offer a device in several different versionsbased on locale, for example, or on features such as a camera.
Device
myDevice,myDevice_eu, myDevice_eu_lite
Thedevice layer represents the physical layer of plastic on thedevice. For example, North American devices probably includeQWERTY keyboards whereas devices sold in France probably includeAZERTY keyboards. Peripherals typically connect to the devicelayer.
Board
sardine,trout, goldfish
Theboard layer represents the bare schematics of a product. You maystill connect peripherals to the board layer.
Arch
arm(arm5te) (arm6), x86, 68k
Thearch layer describes the processor running on your board.
Buildingthe Android Platform
Thissection describes how to build the default version of Android. Onceyou are comfortable with a generic build, then you can begin tomodify Android for your own target device.
DeviceCode
Todo a generic build of android, source build/envsetup.sh
,which contains necessary variable and function definitions, asdescribed below.
% cd $TOP% . build/envsetup.sh# pick a configuration using choosecombo% choosecombo% make -j4 PRODUCT-generic-user
Youcan also replace user with eng for a debug engineering build:
% make -j4 PRODUCT-generic-eng
These BuildVariants differin terms of debug options and packages installed.
CleaningUp
Execute %m clean
toclean up the binaries you just created. You can also execute %m clobber
toget rid of the binaries of all combos. %m clobber
isequivalent to removing the//out/
directorywhere all generated files are stored.
SpeedingUp Rebuilds
Thebinaries of each combo are stored as distinct sub-directoriesof //out/
,making it possible to quickly switch between combos without havingto recompile all sources each time.
However,performing a clean rebuild is necessary if the build system doesn'tcatch changes to environment variables or makefiles. If this happensoften, you should define theUSE_CCACHE
environmentvariable as shown below:
% export USE_CCACHE=1
Doingso will force the build system to use the ccache compiler cachetool, which reduces recompiling all sources.
ccache
binariesare provided in //prebuilt/...
anddon't need to get installed on your system.
Troubleshooting
Thefollowing error is likely caused by running an outdated version ofJava.
device Dex: core UNEXPECTED TOP-LEVEL ERROR:java.lang.NoSuchMethodError: method java.util.Arrays.hashCode withsignature ([Ljava.lang.Object;)I was not found. at com.google.util.FixedSizeList.hashCode(FixedSizeList.java:66) at com.google.rop.code.Rop.hashCode(Rop.java:245) at java.util.HashMap.hash(libgcj.so.7)[...]
dx
isa Java program that uses facilities first made available in Javaversion 1.5. Check your version of Java by executing %java -version
inthe shell you use to build. You should see something like:
java version "1.5.0_07"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)
Ifyou do have Java 1.5 or later and your receive this error, verifythat you have properly updated your PATH
variable.
Buildingthe Android Kernel
Thissection describes how to build Android's default kernel. Once youare comfortable with a generic build, then you can begin to modifyAndroid drivers for your own target device.
Tobuild the kernel base, switch to the device directory(/home/joe/android/device
)in order to establish variables and run:
% . build/envsetup.sh% partner_setup generic
Thenswitch to the kernel directory /home/joe/android/kernel
.
CheckingOut a Branch
Thedefault branch is always android
.To check out a different branch, execute the following:
% git checkout --track -b android-mydevice origin/android-mydevice //Branch android-mydevice set up to track remote branch% refs/remotes/origin/android-mydevice. //Switched to a new branch "android-mydevice"
Tosimplify code management, give your local branch the same name asthe remote branch it is tracking (as illustrated in the snippetabove). Switch between branches by executing %git checkout <branchname>
.
VerifyingLocation
Findout which branches exist (both locally and remotely) and which oneis active (marked with an asterisk) by executing the following:
% git branch -a android* android-mydevice origin/HEAD origin/android origin/android-mydevice origin/android-mychipset
Toonly see local branches, omit the -a
flag.
Buildingthe Kernel
Tobuild the kernel, execute:
% make -j4
BuildVariants
Whenbuilding for a particular product, it's often useful to have minorvariations on what is ultimately the final release build. These arethe currently-defined build variants:
eng
Thisis the default flavor. A plain make
isthe same as makeeng
.
Installsmodules tagged with:
eng
,debug
,user
,and/ordevelopment
.Installsnon-APK modules that have no tags specified.
InstallsAPKs according to the product definition files, in addition totagged APKs.
ro.secure=0
ro.debuggable=1
ro.kernel.android.checkjni=1
adb
isenabled by default.
user
makeuser
Thisis the flavor intended to be the final release bits.
Installsmodules tagged with
user
.Installsnon-APK modules that have no tags specified.
InstallsAPKs according to the product definition files; tags are ignoredfor APK modules.
ro.secure=1
ro.debuggable=0
adb
isdisabled by default.
userdebug
makeuserdebug
Thesame as user
,except:
Alsoinstalls modules tagged with
debug
.ro.debuggable=1
adb
isenabled by default.
Ifyou build one flavor and then want to build another, you shouldrun makeinstallclean
betweenthe two makes to guarantee that you don't pick up files installed bythe previous flavor. makeclean
willalso suffice, but it takes a lot longer.
- Android Porting Book--Android Build System
- ANDROID Porting系列三、Build Cookbook
- Android build system
- Android Build System
- Android build system
- Android Build System
- Android build System
- Android build system note
- android build system links
- Android build system note
- Android build system note
- Android build system note
- Android build system note
- Android build System
- Android Build System
- Android build system note
- Android快速Build system
- Android Build System
- 钩子函数与回调函数概念
- 二级Access数据库视频教程
- vm虚拟机上外网网络设置
- 关于JspSmartUpload上传文件大小限制的问题
- 关于java网络编程第三版中文版
- Android Porting Book--Android Build System
- 设置 取消input的disabled属性 getattribute(),setAttribute(),removeattribute()用法
- The controller for path '/favicon.ico' could not be found or it does not implement the IController interface./r/nParameter name:
- HRESULT是什么类型
- HDU 1257 最少拦截系统 LIS最长不减子序列
- JBOSS5.0 Beta4 配置详解
- 增加 oracle 数据库连接数
- xfire 由wsdl自动生成客户端代码验证出错( src-resolve.4.2 Error resolving component )
- 多媒体编程:出现无法解析的外部符号