我们也说说Android.mk(6)
来源:互联网 发布:软件研发团队口号 编辑:程序博客网 时间:2024/05/13 02:45
https://yq.aliyun.com/articles/27602?spm=5176.100239.blogcont37401.12.bl6Pwq
摘要: 前面基础知识已经准备得差不多了,我们开始看几个例子巩固一下
我们也说说Android.mk(6) - 案例教程
userdata是如何生成的
我们先看看userdataimage的伪目标是如何定义的:
.PHONY: userdataimageuserdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))endif.PHONY: userdatatarballuserdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
INSTALLED_USERDATAIMAGE_TARGET
userdataimage依赖于INSTALLED_USERDATAIMAGE_TARGET,我们再看看INSTALLED_USERDATAIMAGE_TARGET是什么:
INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
BUILT_USERDATAIMAGE_TARGET
我们再继续看BUILT_USERDATAIMAGE_TARGET:
BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
OK,这一支明白了,就是userdata.img嘛。
# A global variable to remember all dist'ed src:dst pairs.# So if a src:dst is already dist'ed by another goal,# we should just establish the dependency and don't really call the# copy-one-dist-file to avoid multiple rules for the same target._all_dist_src_dst_pairs :=# Other parts of the system should use this function to associate# certain files with certain goals. When those goals are built# and "dist" is specified, the marked files will be copied to DIST_DIR.## $(1): a list of goals (e.g. droid, sdk, pdk, ndk)# $(2): the dist files to add to those goals. If the file contains ':',# the text following the colon is the name that the file is copied# to under the dist directory. Subdirs are ok, and will be created# at copy time if necessary.define dist-for-goals$(foreach file,$(2), \ $(eval fw := $(subst :,$(space),$(file))) \ $(eval src := $(word 1,$(fw))) \ $(eval dst := $(word 2,$(fw))) \ $(eval dst := $(if $(dst),$(dst),$(notdir $(src)))) \ $(if $(filter $(_all_dist_src_dst_pairs),$(src):$(dst)),\ $(eval $(call add-dependency,$(1),$(DIST_DIR)/$(dst))),\ $(eval $(call copy-one-dist-file,\ $(src),$(DIST_DIR)/$(dst),$(1)))\ $(eval _all_dist_src_dst_pairs += $(src):$(dst))\ )\)endef
userdata的中间文件
我们再来看看userdata的中间文件是如何生成的:
userdataimage_intermediates := \ $(call intermediates-dir-for,PACKAGING,userdata)
这个好,直接调用一个函数。所谓函数,就是一个大宏,我们看看它是如何定义的:
############################################################# The intermediates directory. Where object files go for## a given target. We could technically get away without## the "_intermediates" suffix on the directory, but it's## nice to be able to grep for that string to find out if## anyone's abusing the system.############################################################ $(1): target class, like "APPS"# $(2): target name, like "NotePad"# $(3): if non-empty, this is a HOST target.# $(4): if non-empty, force the intermediates to be COMMON# $(5): if non-empty, force the intermedistes to be for the 2nd archdefine intermediates-dir-for$(strip \ $(eval _idfClass := $(strip $(1))) \ $(if $(_idfClass),, \ $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \ $(eval _idfName := $(strip $(2))) \ $(if $(_idfName),, \ $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \ $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \ $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \ $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \ $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \ ,$(if $(filter $(_idfClass),SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP),\ $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \ ,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \ ) \ ) \ $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \)endef
虽然逻辑并不是一目了然,但是所用的特性,我们前面都讲过了。
本文为云栖社区原创内容,未经允许不得转载,如需转载请发送邮件至yqeditor@list.alibaba-inc.com;如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:yqgroup@service.aliyun.com 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
阅读全文
0 0
- 我们也说说Android.mk(6)
- 我们也说说Android.mk(3) - 宏
- 我们也说说Android.mk(1)
- 我们也说说Android.mk(3)
- 我们也说说Android.mk(4)
- 我们也说说Android.mk(5)
- 我们也说说Android.mk(1) - 从函数说起
- 我们也说说Android.mk(4) - 计算怎么办?
- 我们也说说Android.mk(5) - 案例教程
- 我们也说说Android.mk(2)-函数进阶教程
- 我们也说说Android.mk(2) - 函数进阶教程 - 分支、循环、子程序
- 我也说说Emacs吧(6)
- 也说说第一博客
- 我也说说房价
- 也说说代理模式
- 我也说说盗版
- 我也说说“商业模式”
- 我也说说“商业模式”
- java集合框架03--LinkedList和源码分析
- H3C-QoS实例一:基于ACL实现报文过滤
- 前端自适应http或https
- ListView加载实时数据闪烁的问题
- photoshop中图层叠加算法
- 我们也说说Android.mk(6)
- cordova 编译安卓的时候报sdk的问题
- Git的安装和使用
- 通过电阻色环识别(固定)电阻阻值的方法
- 安全芯片Z8IDA芯片介绍-身份认证加密芯片方案
- 异常类处理2
- Java基础--FileDescriptor sync方法
- C语言常见的list一些编程练习
- Android Architecture Component之ViewModel源码分析