Android编译中m、mm、mmm的区别

来源:互联网 发布:mac u盘装系统 编辑:程序博客网 时间:2024/06/03 16:22

在AndroidSource Code中有envsetup.sh档案,当执行过此档案后,可以大幅将build的过程简单化、自动化

此档案在src(android source code 位置)/build/中

所以可以执行以下指令

[plain] view plaincopy
  1. cd /src/build/  
  2.   
  3. . envsetup.sh  

可以使用help来检示有哪些指令可以使用

[plain] view plaincopy
  1. Invoke ". build/envsetup.sh" from your shell to add thefollowing functions to your environment:  
  2.   
  3. - croot:   Changes directory to the top of the tree.  
  4. - m:       Makesfrom the top of the tree.  
  5. - mm:      Builds all of the modules in the currentdirectory.  
  6. - mmm:     Builds all of the modules in the supplieddirectories.  
  7. - cgrep:   Greps on all local C/C++ files.  
  8. - hgrep:   Greps on all local C/C++ header files.  
  9. - jgrep:   Greps on all local Java files.  
  10. - mkgrep:  Greps on all local make files.  
  11. - rcgrep:  Greps on all local .rc files.  
  12. - resgrep: Greps on all local res/*.xml files.  
  13. - shgrep:  Greps on all local .sh files.  
  14. - godir:   Go to the directory containing a file.  

其中对模块的编译有辅助说明的是tapas、m、mm、mmm这几个指令

其中mmm后面要跟模块的根目录,不是所有的目录下都有子模块,那些含有Android.mk档案目录才是模块的根目录,模块名可以从Android.mk的LOCAL_MODULE或者LOCAL_PACKAGE_NAME变数中得到。

1、单独编译某模块,需要在mmm后面指定模块路径,例如编译external 中的jpeg

[plain] view plaincopy
  1. root@ubuntu:/home/android/src# mmm external/jpeg/  
  2. ============================================  
  3. PLATFORM_VERSION_CODENAME=REL  
  4. PLATFORM_VERSION=2.1-update1  
  5. TARGET_PRODUCT=generic  
  6. TARGET_BUILD_VARIANT=eng  
  7. TARGET_SIMULATOR=  
  8. TARGET_BUILD_TYPE=release  
  9. TARGET_ARCH=arm  
  10. HOST_ARCH=x86  
  11. HOST_OS=linux  
  12. HOST_BUILD_TYPE=release  
  13. BUILD_ID=ECLAIR  
  14. ============================================  
  15. make: Entering directory `/home/android/src'  
  16. Target buildinfo: out/target/product/generic/root/default.prop  
  17. Target buildinfo: out/target/product/generic/system/build.prop  
  18. Copy: out/target/product/generic/system/etc/apns-conf.xml  
  19. make: Leaving directory `/home/android/src'  
  20. root@ubuntu:/home/android/src#  
2、或者可用 mm 再欲编译的模块目录下执行
[plain] view plaincopy
  1. root@ubuntu:/home/android/src/external/jpeg# mm  
  2. ============================================  
  3. PLATFORM_VERSION_CODENAME=REL  
  4. PLATFORM_VERSION=2.1-update1  
  5. TARGET_PRODUCT=generic  
  6. TARGET_BUILD_VARIANT=eng  
  7. TARGET_SIMULATOR=false  
  8. TARGET_BUILD_TYPE=release  
  9. TARGET_ARCH=arm  
  10. HOST_ARCH=x86  
  11. HOST_OS=linux  
  12. HOST_BUILD_TYPE=release  
  13. BUILD_ID=ECLAIR  
  14. ============================================  
  15. make: Entering directory `/home/android/src'  
  16. Copy: out/target/product/generic/system/etc/apns-conf.xml  
  17. make: Leaving directory `/home/android/src'  
  18. root@ubuntu:/home/android/src/external/jpeg#  
3、或者可用 m 编译全部的模块
[plain] view plaincopy
  1. root@ubuntu:/home/android/src# m  

你也可以在src目录下直接执行

[plain] view plaincopy
  1. make module name:  

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

看到里面模块名称为 libjpeg

[plain] view plaincopy
  1. LOCAL_MODULE:= libjpeg  

这样你就可以直接打模块名称编译

[plain] view plaincopy
  1. cd ~/android/src  
  2. make libjpeg  

也可以在登入时自动执行此 script,编辑 ~/.bashrc 或其他 shell 的 rc 檔,加入此script 即可

[plain] view plaincopy
  1. # invoke android envsetup.sh  
  2. source ~/android/build/envsetup.sh