1砰蠢、構(gòu)建編譯環(huán)境
寫在開頭:因為sync源碼一直失敗亏栈,在網(wǎng)上找了別人匯總的各版本源碼岳颇,步驟參照1.3氧骤,在這里直接下載就好
鏈接: https://pan.baidu.com/s/1yMlHJHJitdI3YvKY2v_AfA 提取碼: cigx
1.1 虛擬機實現(xiàn)
搭建虛擬機運行環(huán)境
這里使用PD虛擬機進行構(gòu)建的ubuntu 16.04環(huán)境
# download
http://mirrors.aliyun.com/ubuntu-releases/16.04/
#安裝,配置國內(nèi)源</pre>
1.1.1 環(huán)境配置
sudo apt-get install git
git config –global user.email ""
git config –global user.name ""
# https://github.com/mikecriggs/ez-aosp
git clone git://github.com/mikecriggs/ez-aosp.git ez-aosp
cd ez-aosp
./ez-aosp.sh
EZ AOSP is a simple automated and user input driven tool for Ubuntu Linux LTS 16.04+ for an easy setup of an AOSP (Android Open Source Project) build environment.
1.1.2 AOSP build
- repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/bin/repo #使用tuna的git-repo鏡像
chmod a+x ~/bin/repo
?
vim ~/bin/repo
# 將這行
REPO_URL = 'https://gerrit.googlesource.com/git-repo'
# 改為這行
REPO_URL = 'https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'</pre>
- Aosp 7.1
mkdir aosp
cd aosp
# repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.2_r36
repo sync
1.2 Docker
docker pull tedwang/aosp-v4:latest
docker search到的應(yīng)該都是類似的東西几于,隨便jdk版本選擇一個pull到本地
Docker門外漢蕊苗,查看Dockerfile文件應(yīng)該是直接對ubuntu的公共鏡像進行配置,有jdk有g(shù)++沿彭,可以直接把源碼拉過去編譯朽砰,免去自己配置
# dockerfile一般有以下信息
RUN apt-get update && apt-get install -y make \
gcc-arm-linux-gnueabi gcc lib32ncurses5 \
lib32stdc++6 lib32ncurses5 lib32bz2-1.0 \
lib32z1 u-boot-tools fakeroot libncurses5-dev \
python bison flex xsltproc gperf g++ lzma zip \
libxml2-utils git busybox
ADD jdk-6u31-linux-x64.bin /usr/java/jdk-6u31-linux-x64.bin
- 啟動鏡像
docker run --name='AOSP_New' -it --rm -v ~/Docker/Android/Aosp4:/aosp fanyinmeng/ubuntu14-android4-build-env-docker
-v 本地文件夾:鏡像環(huán)境文件夾
將下載的源碼復(fù)制到本地文件夾,在/aosp中查看
2喉刘、 編譯
- $ source build/envsetup.sh
root@faf8b93fc475:/aosp/android-4.0.4_r1# source build/envsetup.sh
including device/moto/stingray/vendorsetup.sh
including device/moto/wingray/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
including device/samsung/crespo4g/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/samsung/torospr/vendorsetup.sh
including device/samsung/tuna/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
- $ lunch
編譯前對部分文件進行修改(我的環(huán)境是 tedwang/aosp-v4:latest + android4.0.4.r1瞧柔;環(huán)境不同會出現(xiàn)各種不同的奇奇怪怪的錯誤,參見https://blog.csdn.net/zhangwenhaojf40it/article/details/78110106)
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
make: *** Waiting for unfinished jobs....
$ vim build/core/combo/HOST_linux-x86.mk
修改源碼目錄下/build/core/combo/HOST_linux-x86.mk文件:
將以下語句
HOST_GLOBAL_CFLAGS+= -D_FORTIFY_SOURCE=0
修改為
HOST_GLOBAL_CFLAGS+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1
make: *** Waiting for unfinished jobs....
$ vim external/mesa3d/src/glsl/linker.cpp
Add '#include <stddef.h>' to list of includes
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1
make: *** Waiting for unfinished jobs....
$ vim external/oprofile/libpp/format_output.h
Remove 'mutable' from 'mutable counts_t & counts;' on line 94:
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1
$ vim external/gtest/include/gtest/internal/gtest-param-util.h
添加:#include <cstddef>
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
make: *** Waiting for unfinished jobs....
$ vim external/llvm/llvm-host-build.mk
add "LOCAL_LDLIBS := -lpthread -ldl"
- $ make -j4
核心數(shù)*2
編譯了2天睦裳,終于是完成了造锅,各種錯誤。
$ mmm development/tools/idegen/
$ sh ./development/tools/idegen/idegen.sh
獲得 android.iml android.ipr
Tips
命令刪除所有以前編譯操作的已有輸出:
make clobber
Docker環(huán)境中中斷需要重新執(zhí)行下列命令廉邑,不然會報 not found
$ source build/envsetup.sh
$ lunch
AOSP Android 源碼-簡書
http://www.reibang.com/p/4a845a65fa8a
從零開始分析AOSP源碼(一)——源碼下載與編譯
http://www.reibang.com/p/2495c47c2d27
第四章 01 安裝部署Android源碼編譯環(huán)境