【初步构想】
如果是在一台PC上先完整的编译一次Android源码,然后将整个编译好的源码移到另一台PC,然后再在移到的PC上编译,这样估计是可以减少时间的吧?
【初步测试】
初步测试结果,很令我感动意外,似乎所花费的时间跟make clean后,再make所花的时间差不多,这是为啥呢?看来得好好研究一下make的规则。
【今天测试进展-20091024】
在看了有关Makefile的介绍后,才了解到Makefile跟时间戳关联很紧密,于是,我采用了如下方法编译Android源码:
1、拷贝一份已经编译好的源码到另一个路劲下,这样整个源码的时间都会被修改;
2、修改out目录下所有文件的时间戳为当前时间(请参考linux时间戳一文),这样保证目标文件总比依赖文件新;
3、开始编译源码,编译时终于发现一些令人惊喜的log,即源码好像不再是从C/C++源码开始编译,而是做一些拷贝或者格式转换的工作,对于动态链接库主要有三步,分别是:target SharedLib,
target Prelink,
target Strip,值得特别说明的是libwebcore.so档是唯一重新编译的一个动态链接库,原因尚未找出来。
1)、target SharedLib
target SharedLib: libwebcore
(out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so)
prrebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi g++
-nostdlib -wl,-soname,libwebcore.so -wl .......
2)、target Prelink
target Prelink: libwebcore (out/target/product/generic/symbols/system/lib/libwebcore.so)
out/host/linux-x86/bin/apriori
--prelinkmap build/core/prelink-linux-arm.map --locals-only --quiet out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so
--output out/target/product/generic/symbols/system/lib/libwebcore.so
3)、 target Strip
target Strip: libwebcore (out/target/product/generic/obj/lib/libwebcore.so)
out/host/linux-x86/bin/soslim
--strip --shady --quiet out/target/product/generic/symbols/system/lib/libwebcore.so
--outfile out/target/product/generic/obj/lib/libwebcore.so
libwebcore.so在三个文件夹中出现
obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so(258MB)-> symbols/system/lib/libwebcore.so(257MB)-> obj/lib/libwebcore.so(3.9MB)
4)、其他举例
对于JAR
target Java: am (out/target/common/obj/JAVA_LIBRARIES/am_intermediates/classes)
Copying out/target/common/obj/JAVA_LIBRARIES/am_intermediates/classes-full-debug.jar
Copying: out/target/common/obj/JAVA_LIBRARIES/am_intermediates/classes.jar
target Dex: am
target Jar: am (out/target/common/obj/JAVA_LIBRARIES/am_intermediates/javalib.jar)
对于APK:
target Java
: Camera (out/target/common/obj/APPS/Camera_intermediates/classes)
Copying out/target/common/obj/APPS/Camera_intermediates/classes-full-debug.jar
Copying: out/target/common/obj/APPS/Camera_intermediates/classes.jar
target Dex
: Camera
target Package
: Camera (out/target/product/generic/obj/APPS/Camera_intermediates/package.apk)
对于可执行文件:
target Executable
: ssh (out/target/product/generic/obj/EXECUTABLES/ssh_intermediates/LINKED/ssh)
target Non-prelinked
: ssh (out/target/product/generic/symbols/system/bin/ssh)
target Strip
: ssh (out/target/product/generic/obj/EXECUTABLES/ssh_intermediates/ssh)
4、img文件的生成过程描述
1)、system.img
Target system fs image
: out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
out/host/linux-x86/bin/mkyaffs2image
-f out/target/product/generic/system
out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
Install system fs image
: out/target/product/generic/system.img
out/host/linux-x86/bin/acp
-fpt out/target/product/generic/obj/PACKAGING/systemimage_unopt_intermediates/system.img
out/target/product/generic/system.img
2)、ramdisk.img
Target ram disk
: out/target/product/generic/ramdisk.img
out/host/linux-x86/bin/mkbootfs
out/target/product/generic/root
| gzip > out/target/product/generic/ramdisk.img
3)、userdata.img(此种方法userdata.img并未重新生成,怪事啊)
out/host/linux-x86/bin/mkyaffs2image
-f out/target/product/generic/data
out/target/product/generic/userdata.img
5、对于整个编译过程的描述
1)、更新动态链接库
2)、生成javalib.jar
3)、生成APK
4)、生成可执行文件
5)、编译生成libwebcore.so(很费时间)
6)、生成img
6、附件说明
1)、整个编译过程log摘要:
host Executable: acp (out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp)
true
Install: out/host/linux-x86/bin/acp
host Java: droiddoc (out/host/common/obj/JAVA_LIBRARIES/droiddoc_intermediates/classes)
Install: out/host/linux-x86/framework/droiddoc.jar
Install: out/host/linux-x86/lib/libneo_util.so
Install: out/host/linux-x86/lib/libneo_cs.so
Install: out/host/linux-x86/lib/libneo_cgi.so
Install: out/host/linux-x86/lib/libclearsilver-jni.so
Install: out/host/linux-x86/bin/dx
host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
host SharedLib: libSR_Core (out/host/linux-x86/obj/lib/libSR_Core.so)
host SharedLib: libSR_AcousticModels (out/host/linux-x86/obj/lib/libSR_AcousticModels.so)
host SharedLib: libSR_AcousticState (out/host/linux-x86/obj/lib/libSR_AcousticState.so)
host SharedLib: libSR_Semproc (out/host/linux-x86/obj/lib/libSR_Semproc.so)
host SharedLib: libSR_Vocabulary (out/host/linux-x86/obj/lib/libSR_Vocabulary.so)
host SharedLib: libSR_Grammar (out/host/linux-x86/obj/lib/libSR_Grammar.so)
host SharedLib: libSR_Nametag (out/host/linux-x86/obj/lib/libSR_Nametag.so)
host SharedLib: libSR_Session (out/host/linux-x86/obj/lib/libSR_Session.so)
host Executable: grxmlcompile (out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile)
true
Install: out/host/linux-x86/lib/libESR_Portable.so
Install: out/host/linux-x86/lib/libESR_Shared.so
Install: out/host/linux-x86/lib/libSR_EventLog.so
Install: out/host/linux-x86/lib/libSR_Core.so
Install: out/host/linux-x86/lib/libSR_AcousticModels.so
Install: out/host/linux-x86/lib/libSR_AcousticState.so
Install: out/host/linux-x86/lib/libSR_G2P.so
Install: out/host/linux-x86/lib/libSR_Semproc.so
Install: out/host/linux-x86/lib/libSR_Vocabulary.so
Install: out/host/linux-x86/lib/libSR_Grammar.so
Install: out/host/linux-x86/lib/libSR_Nametag.so
Install: out/host/linux-x86/lib/libSR_Session.so
Install: out/host/linux-x86/lib/libfst.so
Install: out/host/linux-x86/bin/grxmlcompile
2)、libwebcore.so编译过程摘要:
target thumb C++: libwebcore <= external/webkit/
JavaScriptCore/bytecode/CodeBlock.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/bytecode/JumpTable.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/bytecode/Opcode.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/bytecode/SamplingTool.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/bytecode/StructureStubInfo.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/debugger/Debugger.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/debugger/DebuggerActivation.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/debugger/DebuggerCallFrame.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/interpreter/CallFrame.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/interpreter/Interpreter.cpp
target thumb C++: libwebcore <= external/webkit/JavaScriptCore/interpreter/RegisterFile.cpp
.........................................
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/ANPSoundInterface.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/ANPTypefaceInterface.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/ANPWindowInterface.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/PluginTimer.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/PluginViewBridgeAndroid.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/PluginWidgetAndroid.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/plugins/SkANP.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/wds/Command.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/wds/Connection.cpp
target thumb C++: libwebcore <= external/webkit/WebKit/android/wds/DebugServer.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/
JavaScriptCore/parser/Grammar.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/CSSGrammar.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/XPathGrammar.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/UserAgentStyleSheets.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSCharsetRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSFontFaceRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSImportRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSMediaRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSPageRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSPrimitiveValue.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSRuleList.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSStyleDeclaration.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSStyleRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSStyleSheet.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSUnknownRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSValue.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSValueList.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSVariablesDeclaration.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCSSVariablesRule.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSCounter.cpp
target thumb C++: libwebcore <= out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/WebCore/css/JSMediaList.cpp
target SharedLib: libwebcore (out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates/LINKED/libwebcore.so)
target Prelink: libwebcore (out/target/product/generic/symbols/system/lib/libwebcore.so)
target Strip: libwebcore (out/target/product/generic/obj/lib/libwebcore.so)
【今天测试进展-20091025】
1、昨天提到“值得特别说明的是libwebcore.so档是唯一重新编译的一个动态链接库,原因尚未找出来。”这个问题,已经得到解决了,原来在out目录下(
out/target/product/generic/obj/SHARED_LIBRARIES/libwebcore_intermediates
),也有.java及其.cpp文件,所以会重新编译了。
我昨天在out目录下使用指令find ./* -exec touch {} /;
,结果把out下的文件的时间戳都改为当前时间,其中也包括.java及其.cpp文件,如果是要解决这个问题,必须把.java及其.cpp文件排除在外啊。
如果是要排除某一类型文件,可以执行类似命令:
find . -type f ! -name "*.cpp" -exec touch {} /;
find . -type f ! -name "*.java" -exec touch {} /;
但是要同时排除这两种类型的文件,该怎么执行指令呢?
find . -type f /( ! -name "*.java" -and ! -name "*.cpp" /) -exec touch {} /;
如果不用这个办法,还有一种方法是理清整个编译过程所产生的文件,比如链接库的产生过程是:*.c/cpp---->*.o--->*.a/*.so,只要保证目标文件是最新的就行。除了静态、动态连接库外,还有jar文件的产生过程也要清楚。
找出out目录下的所有*.cpp,
*.o,
*.a,
*.so文件,并保存在txt文件中。
today=`date +%y-%m-%d`
find ./out -type f /( -name "*.cpp" -or -name "*.o" -or -name "*.a" -or -name "*.so" /) -exec echo {} >> cpp_o_a_so_$today.txt /;
找出out目录下的所有*.java,
*.class,
*.jar,
*.dex,*.apk文件,并保存在txt文件中。
find ./out -type f /( -name "*.java" -or -name "*.class" -or -name "*.jar" -or -name "*.dex" -name "*.apk" /) -exec echo {} >> java_class_jar_dex_$today.txt /;
2、今天无意中发现了几个包含"timestamp"字样的文件,其中的文件作用可能与时间戳有紧密关联,也和make紧密关联,得研究一下才行。
-rw-rw-r-- 1 san san 0 2009-10-27 03:20 ./out/target/common/docs/offline-sdk-timestamp
-rw-rw-r-- 1 san san 0 2009-10-27 03:20 ./out/target/common/obj/PACKAGING/checkapi-current-timestamp
-rw-rw-r-- 1 san san 0 2009-10-27 03:20 ./out/target/common/obj/PACKAGING/checkapi-last-timestamp
-rw-rw-r-- 1 san san 0 2009-10-27 03:20 ./out/target/product/generic/obj/NOTICE_FILES/hash-timestamp
【今天测试进展-20091027】
1、今天的做法仍然是保证目标文件是最新的,测试结果是编译时间大概需要50分钟,比当初的重新编译所需的两个小时缩短了很多。
find ./out -type f /( ! -name "*.java" -and ! -name "*.cpp" /) -exec touch {} /;
或者
find ./out -type f /( -name "*.o" -or -name "*.a" -or -name "*.so" /) -exec touch {} /;
find ./out -type f /( -name "*.class" -or -name "*.jar" -or -name "*.dex" -or -name "*.apk" /) -exec touch {} /;
2、编译的过程中有几个地方比较花时间,至今尚未找到解决办法。
(1)、产生libwebcore.so(258MB)
(2)、从jar产生dex
(3)、soslim链接可执行文件
3、关于timestamp
今天测试修改了"timestamp"字样的文件的时间戳,但好像没什么效果。
find ./out -type f -name "*timestamp" -exec touch {} /;
4、待测试,修改*intermediates下所有文件的时间戳
find ./out -type d -name "*intermediates" -exec touch {} /;
【今天测试进展-20091101】
查找并显示所有Makefile的文件内容
find . -type f -name "*.mk" -print -exec cat {} /; > all_android_mk_file.txt
find
. -type f -name "*.mk" -printf "/n#
===========================================/n" -print -printf "#
===========================================/n/n" -exec cat {} /; >
~/Desktop/android_mk.txt
研究过了Android编译过程的一些Log,现在该好好看一下MK是怎么写的了,其实,MK只是Log的浓缩而已了。