第四章

第四章linux

本章主要介紹瞭如何下載和編譯Android源代碼和Linux內核源代碼。android

下載、編譯和測試Android源代碼:git

1)配置Android源代碼下載環境:curl

建立用於存放腳本文件的目錄測試

# mkdir ~/binui

# PATH=~/bin:$PATHgoogle

下載repo腳本文件url

# curl http://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~bin/repoes5

# chmod a+x ~/bin/repospa

建立用於存放Android源代碼的目錄

# mkdir android_source

#cd android_source

初始化

# repo init -u https://android.googlesource.com/platform/mainfest 

開始下載Android源代碼

# repo sync

(2)Android源代碼目錄結構解析

這些目錄分別存放了Android源代碼的不一樣子項目

(3)下載Android源代碼中的一部分

下載Android源代碼中的某個子項目有兩種方法:

repo sync命令# repo sync platform/bootable/recovery

git clone命令git clone http://android.googlesource.com/<project name> 

(4)編譯Android源代碼 

初始化編譯環境

# source build/envsetup.sh

選擇目標

# lunch full-eng

編譯Android源代碼

# make

# make -j4

(5)out目錄結構分析

(6)將本身的APK做爲Android內置程序發佈

(7)用模擬器測試system.img文件

下載和編譯Linux內核源代碼

(1)下載Linux內核源代碼

# git clone https://android.googlesource.com/kernel/common.git 

# git branch -a 

# git checkout -b android-3.0 remotes/origin/android-3.0

# git clone https://android.googlesource.com/kernel/goldfish.git

# git checkout -b android-goldfish-2.6.29 remotes/origin/android-goldfish-2.6.29

(2)Linux內核源代碼的目錄結構

(3)安裝Android內核的編譯環境

安裝交叉編譯器

準備工做:

arm-linux-gcc-4.3.2.tgz文件和arm-none-linux-gnueabi-arm-2008q3-72-for-linux.tar.bz2文件複製到工做目錄

解壓編譯器:

# tar zxvf arm-linux-gcc-4.3.2.tgz -C /

# tar jxvf arm-none-linux-gnueabi-arm-2008q3-72-for-linux.tar.bz2 -C/

驗證交叉編譯器是否安裝成功:

# ls /usr/local/arm -l

安裝libncurses5

# apt-get install libncurses5 -dev

(4)配置和編譯Linux內核

#export PATH=/root/comppilers/arm-none-linux-gnueabi/bin:$PATH

相關文章
相關標籤/搜索