android源码下载与编译过程记录


参考:

https://www.ibm.com/developerworks/cn/opensource/os-cn-android-build/


1、下载

参考了以下的下载失败重下载脚本:

[zzz@localhost android-src]$ cat myrepo.sh 
#!/bin/sh
repo sync
while [ $? -ne 0 ] 
do 
    echo "try repo sync again"
    repo sync
done
[zzz@localhost android-src]$ 


下班前开始跑,第二天就有了。


2、编译第一次直接进入下载的源代码目录,运行make,过了3个多小时后,报错:

[ 31% 9980/31772] host Java: bouncycastle-host (out/host/common/obj/JAVA_LIBRARIES/bouncycastle-host_intermediates/classes)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 31% 9983/31772] host Java: bouncycastle-bcpkix-host (out/host/common/obj/JAVA_LIBRARIES/bouncycastle-bcpkix-host_intermediates/classes)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 31% 9987/31772] Build: out/host/linux-x86/obj/EXECUTABLES/jack_intermediates/jack
Writing client settings in /home/gumh/.jack-settings
Installing jack server in "/home/gumh/.jack-server"
Launching Jack server java -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/gumh/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
[ 31% 10007/31772] host C++: zipalign <= build/tools/zipalign/ZipEntry.cpp
build/tools/zipalign/ZipEntry.cpp:145:52: warning: unused parameter 'pZipFile' [-Wunused-parameter]
status_t ZipEntry::initFromExternal(const ZipFile* pZipFile,
                                                   ^
build/tools/zipalign/ZipEntry.cpp:151:12: warning: destination for this 'memcpy' call is a pointer to dynamic class 'CentralDirEntry'; vtable pointer will be overwritten [-Wdynamic-class-memaccess]
    memcpy(&mCDE, &pEntry->mCDE, sizeof(mCDE));
    ~~~~~~ ^
build/tools/zipalign/ZipEntry.cpp:151:12: note: explicitly cast the pointer to silence this warning
    memcpy(&mCDE, &pEntry->mCDE, sizeof(mCDE));
           ^
           (void*)
2 warnings generated.
[ 31% 10012/31772] host C: libzopfli <= external/zopfli/src/zopfli/lz77.c
external/zopfli/src/zopfli/lz77.c:95:60: warning: unused parameter 'datasize' [-Wunused-parameter]
void ZopfliVerifyLenDist(const unsigned char* data, size_t datasize, size_t pos,
                                                           ^
1 warning generated.
[ 31% 10040/31772] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex
FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
GC overhead limit exceeded
Try increasing heap size with java option '-Xmx'
Warning: This may have produced partial or corrupted output.
ninja: build stopped: subcommand failed.

make: *** [ninja_wrapper] Error 1
[zzz@localhost android-src]$ 



//---2015-11-13--//

make之前还运行了下面的指令:

#source ./build/envsetup.sh

这个命令选择你的编译环境的硬件体系

#lunch

下面这个命令就开始编译了

#make


通过跟踪顶层makefile,找到有关jack的目录:prebuilts/sdk/tools,其中看到有个jack-admin,正是启动jack所在的shell。里面有个设置:

#
# Settings
#
JACK_HOME="${JACK_HOME:=$HOME/.jack-server}"
CLIENT_SETTING="${CLIENT_SETTING:=$HOME/.jack-settings}"
TMPDIR=${TMPDIR:=/tmp}
JACK_SERVER_VM_ARGUMENTS="${JACK_SERVER_VM_ARGUMENTS:=-Dfile.encoding=UTF-8 -XX:+TieredCompilation}"


修改一下,增加-Xmx2048M:

#
# Settings
#
JACK_SERVER_VM_ARGUMENTS="${JACK_SERVER_VM_ARGUMENTS:=-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx:2048M}"

再次make,好像没起作用:

[  1% 296/20841] Build: out/host/linux...bj/EXECUTABLES/jack_intermediates/jack
Jack server already installed in "/home/gumh/.jack-server"
Launching Jack server java -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/gumh/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher


找到jack-admin中的start-server语句,直接在里面增加:

 start-server)
    isServerRunning
    RUNNING=$?
    if [ "$RUNNING" = 0 ]; then
      echo "Server is already running"
    else
      echo "before to start-server,JACK_SERVER_VM_ARGUMENTS=" $JACK_SERVER_VM_ARGUMENTS
      JACK_SERVER_COMMAND="java -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS
-Xmx2048M -cp $LAUNCHER_JAR $LAUNCHER_NAME"
      echo "Launching Jack server" $JACK_SERVER_COMMAND
      (


再次执行make指令,这次ok了。

这里有一个问题没弄清楚:有时候执行make的时候,会自动启动jackserver,有时候又不会,会报错说server未启动,请用jack-admin start-server来启动的提示。


经过了4个多小时,终于完成了。

external/gtest/include/gtest/gtest_pred_impl.h:77:52: note: expanded from macro 'GTEST_ASSERT_'
  if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                                   ^
1 warning generated.
[100% 20544/20544] host Executable: ne...t_test_osi_intermediates/net_test_osi)

查看一下:

[zzz@localhost android-src]$ ll out/target/product/generic/
total 1594800
-rw-rw-r--.  1 zzz zzz          7 Nov 14 11:27 android-info.txt
-rw-rw-r--.  1 zzz zzz         63 Nov 14 11:25 build_fingerprint.txt
drwxrwxr-x.  2 zzz zzz       4096 Nov 14 14:37 cache
-rw-r--r--.  1 zzz zzz   69206016 Nov 14 14:37 cache.img
-rw-rw-r--.  1 zzz zzz      72964 Nov 10 15:40 clean_steps.mk
drwxrwxr-x.  4 zzz zzz       4096 Nov 14 11:27 data
drwxrwxr-x.  3 zzz zzz       4096 Nov 14 12:02 dex_bootjars
drwxrwxr-x.  5 zzz zzz       4096 Nov 14 13:58 gen
-rw-rw-r--.  1 zzz zzz      72739 Nov 14 14:37 installed-files.txt
drwxrwxr-x. 12 zzz zzz       4096 Nov 14 14:36 obj
-rw-rw-r--.  1 zzz zzz        788 Nov 14 11:25 previous_build_config.mk
-rw-rw-r--.  1 zzz zzz    1244829 Nov 14 14:37 ramdisk.img
drwxrwxr-x.  3 zzz zzz       4096 Nov 14 11:27 recovery
drwxrwxr-x. 15 zzz zzz       4096 Nov 14 11:28 root
drwxrwxr-x.  6 zzz zzz       4096 Nov 10 17:57 symbols
drwxrwxr-x. 14 zzz zzz       4096 Nov 14 14:36 system
-rw-r--r--.  1 zzz zzz 1610612736 Nov 14 14:37 system.img
-rw-r--r--.  1 zzz zzz  576716800 Nov 14 14:37 userdata.img
[zzz@localhost android-src]$ 


这些应该如何测试呢?下面再补。


你可能感兴趣的:(android)