前言:

Android 的 build system 已經大幅將build的過程簡單化、自動化,所以可以在執行 envsetup.sh 之後使用各種方便

的指令,以下列出目前支援的功能:

Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:

- croot:   Changes directory to the top of the tree.
- m:       Makes from the top of the tree.
- mm:      Builds all of the modules in the current directory.
- mmm:     Builds all of the modules in the supplied directories.
- cgrep:   Greps on all local C/C++ files.
- hgrep:   Greps on all local C/C++ header files.
- jgrep:   Greps on all local Java files.
- mkgrep:  Greps on all local make files.
- rcgrep:  Greps on all local .rc files.
- resgrep: Greps on all local res/*.xml files.
- shgrep:  Greps on all local .sh files.
- godir:   Go to the directory containing a file.

也可以在登入時自動執行此 script,編輯 ~/.bashrc 或其他 shell 的 rc 檔,加入此 script 即可

# invoke android envsetup.sh
source ~/android/build/envsetup.sh

這些功能可以協助處理大部分的例行性 build 功能,但有時候要 debug 或是特別需求時就不是那麼方便,

此時可以編輯 Anroid.mk 加入一些參數設定,可參考:

 

下面是一個 debug macro 時可能有用的範例:

如何知道 macro 展開的結果?

傳統來說,gcc 支援 -E 指令將 preprocessor 的展開結果產生出來:

#gcc –E MacroTest.c –o MacroTest_E.c

在 Android build system 中,預設使用的 arm-eabi-gcc 也支援這功能,但是要使用此功能就要可能

自己寫出又臭又長的的編譯指令,不如直接使用現有的 build system:

編輯 Android.mk

修改/加入:

LOCAL_CFLAGS := -E 

使用mm編譯,結果會失敗,這是正常的,因為原本的 obj file 已經變成展開結果

可以檢查 out 底下的路徑的 obj 檔,應該已經是展開的結果啦

out/target/product/a1/obj/EXECUTABLES/xxxx_intermediates/ 

 

官方的 Build system 文件:

其實最早有一篇文件是講述 Android 整個 build system 的文件,但該文件適用版本大概只到1.5左右,不過還是可以參考一下。

連結:http://android.git.kernel.org/?p=platform/build.git;a=blob_plain;f=core/build-system.html

之後官方網頁也有放上一些比較簡單的參考項目,可在下面連結找到:

http://source.android.com/porting/build_system.html

REF://http://huenlil.pixnet.net/blog/post/26729508

arrow
arrow
    全站熱搜

    BB 發表在 痞客邦 留言(0) 人氣()