http://blog.csdn.net/yajun0601/article/details/7309010

  Android 完成编译的时候先执行  source build/envsetup.sh。  在这个shell 脚本中定义了 help,  croot, m, mm, mmm 等 function

之后在当前目录下执行help 可以发现它给出的信息和此前见过linux 下面help 的信息不一样了:

  1. Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:  
  2. - croot:   Changes directory to the top of the tree.  
  3. - m:       Makes from the top of the tree.  
  4. - mm:      Builds all of the modules in the current directory.  
  5. - mmm:     Builds all of the modules in the supplied directories.  
  6. - cgrep:   Greps on all local C/C++ files.  
  7. - jgrep:   Greps on all local Java files.  
  8. - resgrep: Greps on all local res/*.xml files.  
  9. - godir:   Go to the directory containing a file.  

其中對模組的編譯有輔助說明的是tapas、m、mm、mmm這幾個指令

其中mmm后面要跟模組的根目錄,不是所有的目錄下都有子模組,那些含有Android.mk檔案目錄才是模組的根目錄,模組名可以從Android.mk的LOCAL_MODULE或者LOCAL_PACKAGE_NAME變數中得到。

單獨編譯某模組,需要在mmm后面指定模組路徑,例如編譯external 中的jpeg

root@ubuntu:/home/android/src# mmm external/jpeg/
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
make: Entering directory `/home/android/src'
Target buildinfo: out/target/product/generic/root/default.prop
Target buildinfo: out/target/product/generic/system/build.prop
Copy: out/target/product/generic/system/etc/apns-conf.xml
make: Leaving directory `/home/android/src'
root@ubuntu:/home/android/src#


或者可用 mm 再欲編譯的模組目錄下執行
root@ubuntu:/home/android/src/external/jpeg# mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
make: Entering directory `/home/android/src'
Copy: out/target/product/generic/system/etc/apns-conf.xml
make: Leaving directory `/home/android/src'
root@ubuntu:/home/android/src/external/jpeg#


或者可用 m 編譯全部的模組
root@ubuntu:/home/android/src# m

你也可以在src目錄下直接執行make module name:

打開看 ./external/jpeg/Android.mk

看到裡面模組名稱為 libjpeg

LOCAL_MODULE:= libjpeg

這樣你就可以直接打模組名稱編譯

cd ~/android/src
make libjpeg

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

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


10-25 16:00
查看更多