android编译之解析main.mk
来源:互联网 发布:ubuntu 开机脚本 编辑:程序博客网 时间:2024/05/19 23:02
上篇博客讲了android的基本的make脚本文件格式,虽然android的mk脚本很复杂,但我们可以把它拆解成基本格式来看。下面我我们来一步一步的解析android的make文件流程。
首先是根目录的makefile文件
### DO NOT EDIT THIS FILE ###include build/core/main.mk### DO NOT EDIT THIS FILE ###
好简单额,意思很直观明了。就是包含了 build/core/main.mk文件。那么我们接下来将解析大头,就是main.mk文件。由于main.mk很大,我们一步一步的来解析它,当然我们只解析关键的步骤,因为android的脚本文件里含有丰富的注释(这是一个好习惯)。所以我只是解析下关键部分。
# This is the default target. It must be the first declared target..PHONY: droidDEFAULT_GOAL := droid$(DEFAULT_GOAL):这里设定了一个默认的target名称droid。当用户直接调用make命令的时候,生成的target就为droid。但是这里并没有定义编译条件。
# Set up various standard variables based on configuration# and host information.include $(BUILD_SYSTEM)/config.mk# This allows us to force a clean build - included after the config.make# environment setup is done, but before we generate any dependencies. This# file does the rm -rf inline so the deps which are all done below will# be generated correctlyinclude $(BUILD_SYSTEM)/cleanbuild.mkVERSION_CHECK_SEQUENCE_NUMBER := 2-include $(OUT_DIR)/versions_checked.mkifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))这里是包含了其它的mk文件。
后面有一大段是检测系统环境的,比如检测系统是否为windows(android只能在linux和苹果机上编译),java的版本。
ifneq ($(filter eng user userdebug,$(MAKECMDGOALS)),)$(info ***************************************************************)$(info ***************************************************************)$(info Don't pass '$(filter eng user userdebug tests,$(MAKECMDGOALS))' on \the make command line.)# XXX The single quote on this line fixes gvim's syntax highlighting.# Without which, the rest of this file is impossible to read.$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)$(info choosecombo.)$(info ***************************************************************)$(info ***************************************************************)$(error stopping)endif
检查product的类型,product只能为user,eng,userdebug,tests四种。
# Can't use first-makefiles-under here because# --mindepth=2 makes the prunes not work.subdir_makefiles := \$(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(subdirs) Android.mk)调用build/tools/findleaves.py脚本来遍历所有目录下的Android.mk文件,不包括out,repo和git目录。
include $(subdir_makefiles)将所查找到的Android.mk包含进来。
接下来大部分就是定义了一下其它的target。
# All the droid stuff, in directories.PHONY: filesfiles: prebuilt \ $(modules_to_install) \ $(modules_to_check) \ $(INSTALLED_ANDROID_INFO_TXT_TARGET)
比如files就是编译过程中生成的一些临时文件等等。至此。main.mk的大致流程算上讲完了。后续将继续分析如何增加一个product
- android编译之解析main.mk
- Android编译系统分析---main.mk
- Android编译系统分析---main.mk
- [笔记分享] [Build] Android编译系统源代码之main.mk
- Android.mk编译文件解析
- android编译之mk脚本
- android Main.mk分析
- Android 编译系统(三)Main.mk分析
- Android 编译系统框架分析及main.mk分析
- Android 编译系统(三)Main.mk分析
- 安卓main.mk解析
- JPEG源码Android编译之Android.mk
- Android编译之Android.mk语法规范
- Android编译系统之andrloid.mk文件
- cygwin 编译ffmpeg 之android.mk
- cocos2dx交叉编译之Android.mk修改
- 四、Android.mk之编译生成可执行文件
- jni开发之 Android.mk文件解析
- 1012 u Calculate e
- Linux基本命令:如何卸载Linux程序
- 一些简单数据结构算法的实现1
- centos6.0下如何卸载linux版google chrome [复制链接]
- DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Su
- android编译之解析main.mk
- Transport t=session.getTransport();
- 一些简单数据结构算法的实现2
- Linux rpm 命令参数使用详解[介绍和应用]
- Chrome(Google浏览器)中使用debug版的flash player
- php Class ‘mysqli’ not found 问题
- 一些简单数据结构算法的实现3
- Google Chrome常规浏览器设置: Adobe Flash Player
- 用栈来实现表达式求值【Java版】