文章转自:http://android.cloudchou.com/build/core/definitions.php
build/core/definitions.mk
定义了公共的编译系统变量ALL_*,
还定义了很多命令用来编译各种各样的目标,
其它地方用来构建最终目标,build/core/main.mk,build/core/Makefile将用到这些变量
ALL_DOCS
所有文档的全路径
ALL_DOCS的赋值在droiddoc.mk里:
ALL_DOCS += $(full_target)
full_target := $(call doc-timestamp-for,$(LOCAL_MODULE))
ALL_DOCS示例:out/target/common/docs/api-stubs-timestamp out/target/common/docs/hidden-timestamp
如果某个模块要编译出文档,需要使用命令
include $(BUILD_DROIDDOC)
而BUILD_DROID_DOC变量的值是droiddoc.mk
ALL_MODULES
系统的所有模块的简单名字集合
编译系统还为每一个模块还定义了其它两个变量
ALL_MODULES.$(LOCAL_MODULE).BUILT 所有模块的生成路径
ALL_MODULES.$(LOCAL_MODULE).INSTALLED 所有模块的各自安装路径
例如:手机中将安装在system/bin/recovery,那么ALL_MODULES.recovery.INSTALLED为out/target/product/find5/system/bin/recovery
每个模块都会定义该模块生成的目标类型,可能生成二进制文件,也可能生成java静态库
这是由这个模块include $(BUILD_)决定的
比如build type若是EXCECUTABLE,,那么将include $(BUILD_EXECUTABLE),那么将include build/core/executable.mk
而该makefile对应生成的目标类型是在手机上的可执行程序
executable.mk里包含了binary.mk,而binary.mk包含了base_rules.mk
base_rules.mk里为变量ALL_MODULES,ALL_MODULES.$(target).BUILT,ALL_MODULES.$(target).INSTALLED赋值
代码:
ALL_MODULES += $(LOCAL_MODULE)
ALL_MODULES.$(LOCAL_MODULE).BUILT := \
$(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
$(strip $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE))
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
endif
LOCAL_MODULE_PATH := $(strip $(LOCAL_MODULE_PATH))
ifeq ($(LOCAL_MODULE_PATH),)
LOCAL_MODULE_PATH := $($(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS))
ifeq ($(strip $(LOCAL_MODULE_PATH)),)
$(error $(LOCAL_PATH): unhandled LOCAL_MODULE_CLASS "$(LOCAL_MODULE_CLASS)")
endif
endif
LOCAL_MODULE_PATH:表示要安装的位置,可由编译系统推算,也可由某个模块显示指定
示例:
ALL_MODULES:recvery applypatch applypatch_static imgdiff
对应的
$(built_module_path) : out/target/product/find5/obj/EXECUTABLES/recovery_intermediates
$(LOCAL_BUILT_MODULE_STEM) : recovery
$(LOCAL_MODULE_PATH): out/target/product/find5/system/bin
$(LOCAL_INSTALLED_MODULE_STEM): recovery
$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS):TARGET_OUT_EXECUTABLES
$(ALL_MODULES.recovery.BUILT) :out/target/product/find5/obj/EXECUTABLES/recovery_intermediates/recovery
$(ALL_MODULES.recovery.INSTALLED):out/target/product/find5/system/bin/recovery
ALL_DEFAULT_INSTALLED_MODULES
所有默认要安装的模块,在build/core/main.mk和build/core/makfile里设置
Full paths to targets that should be added to the "make droid" set of installed targets.
droid目标将安装的所有模块的集合
ALL_MODULE_TAGS
使用LOCAL_MODULE_TAGS定义的所有tag集合
每一个tag对应一个ALL_MODULE_TAGS.变量
例:
在recovery的Android.mk里定义了;
LOCAL_MODULE := recovery
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE := nandroid-md5.sh
LOCAL_MODULE_TAGS := optional
那么:ALL_MODULE_TAGS 将包含 eng,optional,
ALL_MODULE_TAGS.eng:out/target/product/find5/system/bin/recovery
ALL_MODULE_TAGS.optional: out/target/product/find5/recovery/root/sbin/nandroid-md5.sh
ALL_MODULE_NAME_TAGS
类似于ALL_MODULE_TAGS,但是它的值是 某个tag的所有模块的名称
例:
包含bootable/recovery/Android.mk后,
ALL_MODULE_NAME_TAGS.eng: recovery libbmlutils libdedupe utility_dedupe libcrecovery libmmcutils updater libapplypatch applypatch_static su.recovery
ALL_MODULE_NAME_TAGS.optional: nandroid-md5.sh killrecovery.sh dedupe libflashutils flash_image dump_image erase_image libflash_image libdump_image liberase_image
utility_dump_image utility_flash_image utility_erase_image libminui libminelf libminzip libminadbd libmtdutils edify libedify applypatch
imgdiff parted sdparted libminizip libmake_ext4fs install-su.sh run-su-daemon.sh
ALL_HOST_INSTALLED_FILES
安装在pc上的程序集合
例:
包含bootable/recovery/Android.mk后,
ALL_HOST_INSTALLED_FILES: /home/cloud/android/Cyanogenmod/out/host/linux-x86/bin/dedupe
/home/cloud/android/Cyanogenmod/out/host/linux-x86/bin/edify
/home/cloud/android/Cyanogenmod/out/host/linux-x86/bin/imgdiff
ALL_PREBUILT
将会被拷贝的预编译文件的安装全路径的集合
Full paths to all prebuilt files that will be copied (used to make the dependency on acp)
在system/core/Android.mk里大量使用了ALL_PREBUILT
ALL_PREBUILT += $(file)
ALL_PREBUILT += $(DIRS)
示例:
ALL_PREBUILT: out/target/product/find5/system/etc/dbus.conf out/target/product/find5/system/etc/hosts out/target/product/find5/system/etc/init.goldfish.sh
ALL_GENERATED_SOURCES
某些工具生成的源代码文件的集合,比如aidl会生成java源代码文件
Full path to all files that are made by some tool
./build/core/binary.mk:273:ALL_GENERATED_SOURCES += $(LOCAL_GENERATED_SOURCES)
./bionic/libc/Android.mk:735:ALL_GENERATED_SOURCES += $(GEN)
例:
ALL_GENERATED_SOURCES: out/target/product/find5/obj/SHARED_LIBRARIES/libRS_intermediates/rsgApiStructs.h
out/target/product/find5/obj/SHARED_LIBRARIES/libRS_intermediates/rsgApiFuncDecl.h
out/target/product/find5/obj/SHARED_LIBRARIES/libbt-vendor_intermediates/vnd_buildcfg.h
ALL_C_CPP_ETC_OBJECTS
所有asm,c,c++,以及lex和yacc生成的c代码文件的全路径
这些都对拷贝的头文件有一个按序的依赖关系
ALL_ORIGINAL_DYNAMIC_BINARIES
没有被优化,也没有被压缩的动态链接库
The list of dynamic binaries that haven't been stripped/compressed/etc
dynamic_binary.mk: ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
例:
ALL_ORIGINAL_DYNAMIC_BINARIES:out/target/product/find5/obj/EXECUTABLES/vold_intermediates/LINKED/vold
out/target/product/find5/obj/SHARED_LIBRARIES/libkeystore_intermediates/LINKED/libkeystore.so
ALL_SDK_FILES
将会放在sdk的文件
These files go into the SDK
主要赋值:development/build/Android.mk
INTERNAL_DALVIK_MODULES
dalvik虚拟机需要的文件
Files for dalvik. This is often build without building the rest of the OS
在dalvik/dx/src/Android.mk dalvik/dx/Android.mk中有赋值
ALL_FINDBUGS_FILES
所有findbugs程序用的xml文件
build/core/java.mk:400:ALL_FINDBUGS_FILES += $(findbugs_xml)
All findbugs xml files
ALL_GPL_MODULE_LICENSE_FILES
GPL module license files
GPL 模块的 许可文件
在build/core/base_rules.mk里有赋值
gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL*)
ifneq ($(gpl_license_file),)
LOCAL_MODULE_TAGS += gnu
ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
endif
ANDROID_RESOURCE_GENERATED_CLASSES
Android 资源文件生成的java代码编译后的类的类型
ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
在build/core/static_java_library.mk中有用到,用于排除某些文件,使其不被打包至lib文件
Function: print-vars
Debugging; prints a variable list to stdout
用于打印变量的值
$(1): variable name list, not variable values
Function: true-or-empty
如果参数含有true,则返回true,否则返回空
$(1) 要测试的变量
Function: my-dir
返回当前makefile所在目录
Function: all-makefiles-under
获取某个目录下及子目录的所有Android.mk
$(1):需要提取Android.mk的目录
Function: first-makefiles-under
在某个目录下的所有子目录中查找Android.mk,不包括当前目录
$(1):要搜索的目录
Function: all-subdir-makefiles
查找当前目录及子目录下的所有Android.mk
Function: all-named-subdir-makefiles
在当前目录下的一组子目录下查找Android.mk
$(1): List of directories to look for under this directory
Function: all-java-files-under
找出当前makefile所在目录的指定子目录里的所有java文件
$(1) 指定子目录
使用范例:SRC_FILES := $(call all-java-files-under,src tests)
Function: all-subdir-java-files
从当前目录查找所有java文件
使用范例: SRC_FILES := $(call all-subdir-java-files)
Function: all-c-files-under
在指定子目录下找C代码
Find all of the c files under the named directories.
Meant to be used like:
SRC_FILES := $(call all-c-files-under,src tests)
$1: 指定子目录名称
Function: all-subdir-c-files
查找当前目录所有子目录的c代码文件
Find all of the c files from here. Meant to be used like:
SRC_FILES := $(call all-subdir-c-files)
Function: all-Iaidl-files-under
在指定子目录下查找所有类似I*.aidl代码文件
Find all files named "I*.aidl" under the named directories,
which must be relative to $(LOCAL_PATH). The returned list
is relative to $(LOCAL_PATH).
$1: 指定子目录名称
Function: all-subdir-Iaidl-files
在$(LOCAL_PATH)下查找所有I*.aidl代码文件
Find all of the "I*.aidl" files under $(LOCAL_PATH).
Function: all-logtags-files-under
在指定子目录下查找所有logtags文件
Find all of the logtags files under the named directories.
Meant to be used like:
SRC_FILES := $(call all-logtags-files-under,src)
查找.logtag文件
$1:指定子目录名称
Function: all-proto-files-under
在指定子目录下查找所有.proto文件
Find all of the .proto files under the named directories.
Meant to be used like:
SRC_FILES := $(call all-proto-files-under,src)
查找.proto文件
$1:指定子目录名称
Function: all-renderscript-files-under
在指定子目录下查找所有.rs或者.fs文件
Find all of the RenderScript files under the named directories.
Meant to be used like:
SRC_FILES := $(call all-renderscript-files-under,src)
查找.rs .fs文件
$1:指定子目录名称
Function: all-html-files-under
在指定子目录下查找所有html文件
Find all of the html files under the named directories.
Meant to be used like:
SRC_FILES := $(call all-html-files-under,src tests)
查找.html文件
$1:指定子目录名称
Function: all-subdir-html-files
在当前目录的子目录里查找所有html文件
Find all of the html files from here. Meant to be used like:
SRC_FILES := $(call all-subdir-html-files)
Function: find-subdir-files
根据find命令的规则查找所有文件
Find all of the files matching pattern
SRC_FILES := $(call find-subdir-files, )
$1 find命令的匹配规则
Function: find-subdir-subdir-files
在指定子目录下根据find命令的规则查找文件
find the files in the subdirectory $1 of LOCAL_DIR
matching pattern $2, filtering out files $3
e.g.
SRC_FILES += $(call find-subdir-subdir-files, \
css, *.cpp, DontWantThis.cpp)
$1 LOCAL_DIR的子目录
$2 find命令的匹配规则
$3 过滤的文件
Function: find-subdir-assets
查找所有不是软链且文件名不带后缀的文件
SRC_FILES := $(call find-subdir-assets)
$1 要进入并查找的目录
Function: find-other-java-files
在$(LOCAL_PATH)里根据find命令的匹配规则查找java文件
$1 find命令的匹配规则
Function: find-other-html-files
在$(LOCAL_PATH)里根据find命令的匹配规则查找html文件
$1 find命令的匹配规则
Function: find-parent-file
在$1给出的目录及这个目录的父目录里查找$2,若找到返回该路径
Scan through each directory of $(1) looking for files
that match $(2) using $(wildcard). Useful for seeing if
a given directory or one of its parents contains
a particular file. Returns the first match found,
starting furthest from the root.
$1 要查找的目录集合
$2 要查找的文件
Function: add-dependency
添加依赖关系
Function we can evaluate to introduce a dynamic dependency
$1 需要依赖其它东东的目标
$2 被依赖的东东
Function: add-prebuilt-file
Set up the dependencies for a prebuilt target
$(call add-prebuilt-file, srcfile, [targetclass])
$(1): srcfile
$(2): target class
Function: add-prebuilt-files
domultipleprebuilts
$(calltargetclass,files...)
$(1)targetclass
$(2)srcfiles
使用举例:
gdbserver/Android.mk:$(calladd-prebuilt-files,EXECUTABLES,$(prebuilt_files))
Function: intermediates-dir-for
查找中间目录并返回
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 如果是host的common,则是out/host/common,如果是target的common,则是out/target/common
使用举例:
./development/build/Android.mk framework_res_package := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
./frameworks/base/core/res/Android.mk:37:framework_GENERATED_SOURCE_DIR := $(call intermediates-dir-for,JAVA_LIBRARIES,framework,,COMMON)/src
值: out/target/product/find5/obj/STATIC_LIBRARIES/libstdc++_intermediates
out/target/common/obj/JAVA_LIBRARIES/core_intermediates
out/target/common/obj/APPS/framework-res_intermediates
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates
Function: local-intermediates-dir
利用LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE决定中间目录
$(1): if non-empty, force the intermediates to be COMMON
例: LOCAL_MODULE_CLASS:EXECUTABLES
LOCAL_MODULE: recovery
LOCAL_IS_HOST_MODULE empty
$1 为空
那么返回out/target/product/find5/obj/EXECUTABLES/recovery_intermediates
Function: normalize-libraries
将"path/to/libXXX.so"转为 -lXXX
Convert "path/to/libXXX.so" to "-lXXX".
Any "path/to/libXXX.a" elements pass through unchanged.
Function: normalize-host-libraries
参见normalize-libraries,和之类似
Function: normalize-target-libraries
参见normalize-libraries,和之类似
Function: module-built-files
将模块名字转为它们对应的编译生成路径
Convert a list of short module names (e.g., "framework", "Browser")
into the list of files that are built for those modules.
NOTE: this won't return reliable results until after all
sub-makefiles have been included.
$(1): target list
Function: module-installed-files
将模块名字转为它们对应的安装路径
Convert a list of short modules names (e.g., "framework", "Browser")
into the list of files that are installed for those modules.
NOTE: this won't return reliable results until after all
sub-makefiles have been included.
$(1): target list
Function: module-stubs-files
将模块名字转为它们要作为公共API时链接的文件路径
Convert a list of short modules names (e.g., "framework", "Browser")
into the list of files that should be used when linking
against that module as a public API.
TODO: Allow this for more than JAVA_LIBRARIES modules
NOTE: this won't return reliable results until after all
sub-makefiles have been included.
$(1): target list
define module-stubs-files
$(foreach module,$(1),$(ALL_MODULES.$(module).STUBS))
endef
Function: doc-timestamp-for
为文档模块转为timestamp为文件,这个文件是添加依赖时会用到的
Evaluates to the timestamp file for a doc module, which
is the dependency that should be used.
$(1): doc module
Function: java-lib-files
Convert "core ext framework" to "out/.../javalib.jar ..."
out/target/common/JAVA_LIBRARIES/libname_indeterminates/classes.jar
out/host/common/JAVA_LIBRARIES/libname_indeterminates/classes.jar
$(1): library name list
$(2): Non-empty if IS_HOST_MODULE
Function: java-lib-deps
多个javalib.jar
$(1): library name list
$(2): Non-empty if IS_HOST_MODULE
Function: rot13
Run rot13 on a string rot13 是一种简易的置换暗码
$(1): the string. Must be one line.
Function: streq
Returns true if $(1) and $(2) are equal. Returns
the empty string if they are not equal.
Function: normalize-path-list
Convert "a b c" into "a:b:c"
Function: word-colon
Read the word out of a colon-separated list of words.
This has the same behavior as the built-in function
$(word n,str).
The individual words may not contain spaces.
将用":"分隔的字符串转化为词数组
$(1): 1 based index
$(2): value of the form a:b:c...
Function: collapse-pairs
Convert "a=b c= d e = f" into "a=b c=d e=f" ,注意空格
$(1): list to collapse
$(2): if set, separator word; usually "=", ":", or ":="
Defaults to "=" if not set.
Function: uniq-pairs-by-first-component
Given a list of pairs, if multiple pairs have the same
first components, keep only the first pair.
$(1): list of pairs
$(2): the separator word, such as ":", "=", etc.
Function: modules-for-tag-list
Given a list of pairs, if multiple pairs have the same
first components, keep only the first pair.
$(1): list of pairs
$(2): the separator word, such as ":", "=", etc.
ALL_MODULE_TAGS.eng:out/target/product/find5/system/bin/recovery
Function: module-names-for-tag-list
Given a list of tags, return the targets that specify
any of those tags.
$(1): tag list
ALL_MODULE_NAME_TAGS.eng: recovery libbmlutils libdedupe utility_dedupe libcrecovery libmmcutils updater libapplypatch applypatch_static su.recovery
Function: get-tagged-modules
Given an accept and reject list, find the matching set of targets. If a target has multiple tags and
any of them are rejected, the target is rejected.
Reject overrides accept.
$(1): list of tags to accept
$(2): list of tags to reject
Function: append-path
Append a leaf to a base path. Properly deals with
base paths ending in /.
$(1): base path
$(2): leaf path
Function: get-package-overrides
Packagefiltering
#Givenalistofinstalledmodules(shortorlongnames)
#returnalistofthepackages(yes,.apkpackages,not
#modulesingeneral)thatareoverriddenbythislistand,
#therefore,shouldnotbeinstalled.
#$(1):mixedlistofinstalledmodules
#TODO:Thisisfragile;findareliablewaytogetthisinformation.
Function: pretty
Output the command lines, or not
如果编译时传递了添加了showcommands参数,调用pretty会打印正在执行的命令
如果没有传递showcommand参数,则不会打印正在执行的命令
Function: dump-module-variables
Dump the variables that are associated with targets
打印编译时的一些参数
主要是一些PRIVATE变量,例如PRIVATE_YACCFLAGS
Function: transform-variables
Commands for using sed to replace given variable values
Function: transform-d-to-p-args
CommandsformungingthedependencyfilesGCCgenerates
$(1):theinput.dfile
$(2):theoutput.Pfile
Function: transform-d-to-p
参见 transform-d-to-p-args
Function: transform-l-to-cpp
Commands for running lex
举例:
ifneq ($(strip $(lex_cpps)),)
$(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
$(TOPDIR)$(LOCAL_PATH)/%.l
$(transform-l-to-cpp)
Function: transform-y-to-cpp
Commands for running yacc
Because the extension of c++ files can change, the
extension must be specified in $1.
E.g, "$(call transform-y-to-cpp,.cpp)"
Function: transform-renderscripts-to-java-and-bc
Commands to compile RenderScript
Function: transform-aidl-to-java
Commands for running aidl
Function: transform-logtags-to-java
Commands for running java-event-log-tags.py
Function: transform-proto-to-java
Commands for running protoc to compile .proto into .java
Function: transform-proto-to-cc
Commands for running protoc to compile .proto into .pb.cc and .pb.h
Function: transform-cpp-to-o
Commands for running gcc to compile a C++ file
Function: transform-c-or-s-to-o-no-deps
Commands for running gcc to compile a C file
# $(1): extra flags
Function: transform-c-to-o-no-deps
编译c文件至目标文件,无依赖的编译
# $(1): extra flags
Function: transform-s-to-o-no-deps
编译汇编文件至目标文件,无依赖的编译
$(1): extra flags
Function: transform-c-to-o
编译c文件至目标文件
# $(1): extra flags 编译参数
Function: transform-s-to-o
编译汇编文件至目标文件
$(1): extra flags,编译参数
Function: transform-m-to-o-no-deps
Commands for running gcc to compile an Objective-C file
This should never happen for target builds but this
will error at build time.
Function: transform-m-to-o
编译objet c文件至目标文件
$(1): extra flags,编译参数
Function: transform-host-cpp-to-o
Commands for running gcc to compile a host C++ file
编译cpp文件,目标代码将在主机上运行
$(1): extra flags
Function: transform-host-c-or-s-to-o-no-deps
Commands for running gcc to compile a host C file
编译c代码或者汇编代码,目标代码将在主机上运行,无依赖的编译
$(1): extra flags
Function: transform-host-c-to-o-no-deps
Commands for running gcc to compile a host C file
编译c代码,目标代码将在主机上运行,无依赖的编译
$(1): extra flags
Function: transform-host-s-to-o-no-deps
编译汇编代码,目标代码将在主机上运行,无依赖的编译
$(1): extra flags
Function: transform-host-c-to-o
编译c代码,目标代码将在主机上运行
$(1): extra flags
Function: transform-host-s-to-o
编译汇编代码,目标代码将在主机上运行
$(1): extra flags
Function: transform-host-m-to-o-no-deps
Commands for running gcc to compile a host Objective-C file
编译object c代码,目标代码将在主机上运行,无依赖编译
$(1): extra flags
Function: transform-host-m-to-o
Commands for running gcc to compile a host Objective-C file
编译object c代码,目标代码将在主机上运行,
$(1): extra flags
Function: _concat-if-arg2-not-empty
Commands for running ar
Function: split-long-arguments
Split long argument list into smaller groups and call the command repeatedly
Call the command at least once even if there are no arguments, as otherwise
the output file won't be created.
$(1): the command without arguments
$(2): the arguments
Function: extract-and-include-target-whole-static-libs
$(1): the full path of the source static library.
Function: transform-o-to-static-lib
Explicitly delete the archive first so that ar doesn't
try to add to an existing archive.
将目标代码打包成静态库
Function: extract-and-include-host-whole-static-libs
Commands for running host ar
$(1): the full path of the source static library.
静态库将在主机上运行
Function: transform-host-o-to-static-lib
将目标代码打包成在主机上运行的静态库
静态库将在主机上运行
Function: transform-host-o-to-shared-lib-inner
Commands for running gcc to link a shared library or package
ld just seems to be so finicky with command order that we allow
it to be overriden en-masse see combo/linux-arm.make for an example.
将目标代码打包成在主机上运行的动态库或者包
Function: transform-host-o-to-shared-lib
参见transform-host-o-to-shared-lib-inner
Function: transform-host-o-to-package
参见transform-host-o-to-shared-lib-inner
Function: transform-o-to-shared-lib-inner
Commands for running gcc to link a shared library or package
ld just seems to be so finicky with command order that we allow
it to be overriden en-masse see combo/linux-arm.make for an example.
将目标代码打包成在目标机上运行的动态库
Function: transform-o-to-shared-lib
参见transform-o-to-shared-lib-inner
Function: transform-o-to-package
参见transform-o-to-shared-lib-inner
Function: transform-to-stripped
Commands for filtering a target executable or library
Function: transform-o-to-executable-inner
Commandsforrunninggcctolinkanexecutable
编译成可执行文件
Function: transform-o-to-executable
参见transform-o-to-executable-inner
Function: transform-o-to-static-executable-inner
Commandsforrunninggcctolinkastaticallylinked
executable.Inpractice,weonlyusethisonarm,so
theotherplatformsdon'thavethe
transform-o-to-static-executabledefined
Function: transform-o-to-static-executable
参见transform-o-to-static-executable-inner
Function: transform-host-o-to-executable-inner
Commands for running gcc to link a host executable
Function: transform-host-o-to-executable
参见transform-host-o-to-executable-inner
Function: create-resource-java-files
Commandsforrunningjavactomake.classfiles
@echo"Sourceintermediatesdir:$(PRIVATE_SOURCE_INTERMEDIATES_DIR)"
@echo"Sourceintermediates:$$(find$(PRIVATE_SOURCE_INTERMEDIATES_DIR)-name'*.java')"
ThisrulecreatestheR.javaandManifest.javafiles,bothofwhich
arePRODUCT-neutral.Don'tpassPRIVATE_PRODUCT_AAPT_CONFIGtothisinvocation.
Function: emit-line
emit-line,,
Function: dump-words-to-file
dump-words-to-file,,
Function: unzip-jar-files
For a list of jar files, unzip them to a specified directory,
but make sure that no META-INF files come along for the ride.
$(1): files to unzip
$(2): destination directory
Function: compile-java
Common definition to invoke javac on the host and target.
Some historical notes:
- below we write the list of java files to java-source-list to avoid argument
list length problems with Cygwin
- we filter out duplicate java file names because eclipse's compiler
doesn't like them.
$(1): javac
$(2): bootclasspath
Function: transform-java-to-classes.jar
将java编译并打包成classes.jar
Function: transform-classes.jar-to-emma
emma代码覆盖率测试
Function: transform-classes.jar-to-dex
将classes.jar转化为dex
Function: create-empty-package
Create a mostly-empty .jar file that we'll add to later.
The MacOS jar tool doesn't like creating empty jar files,
so we need to give it something.
Function: add-assets-to-package
TODO: we kinda want to build different asset packages for
different configurations, then combine them later (or something).
Per-locale, etc.
A list of dynamic and static parameters;build layers for
dynamic params that lay over the static ones.
TODO: update the manifest to point to the package file
Note that the version numbers are given to aapt as simple default
values; applications can override these by explicitly stating
them in their manifest.
将资源文件打包到package
Function: add-jni-shared-libs-to-package
将jni 动态库打包到package
Function: add-dex-to-package
将dex打包到package
Function: add-java-resources-to-package
Add java resources added by the current module.
Function: add-carried-java-resources
Add java resources carried by static Java libraries.
Function: sign-package
Sign a package using the specified key/cert.
Function: align-package
Align STORED entries of a package on 4-byte boundaries
to make them easier to mmap.
Function: install-dex-debug
安装debug版本的dex文件
Function: transform-host-java-to-package
TODO(joeo):Ifwecaneverupgradetopost3.81makeandgetthe
newprebuiltrulestowork,weshouldchangethistocopythe
resourcestotheoutdirectoryandthencopytheresources.
Note:weintentionallydon'tcleanPRIVATE_CLASS_INTERMEDIATES_DIR
intransform-java-to-classesforthesakeofvm-tests.
Function: obfuscate-jar
Obfuscate a jar file
PRIVATE_KEEP_FILE is a file containing a list of classes
PRIVATE_INTERMEDIATES_DIR is a directory we can use for temporary files
The module using this must depend on
$(HOST_OUT_JAVA_LIBRARIES)/proguard-4.0.1.jar
混淆代码
Function: copy-one-header
Commands for copying files
Define a rule to copy a header. Used via $(eval) by copy_headers.make.
$(1): source header
$(2): destination header
Function: copy-one-file
Define a rule to copy a file. For use via $(eval).
$(1): source file
$(2): destination file
Function: copy-many-files
Copies many files.
$(1): The files to copy. Each entry is a ':' separated src:dst pair
Evaluates to the list of the dst files (ie suitable for a dependency list)
Function: copy-xml-file-checked
Copy the file only if it's a well-formed xml file. For use via $(eval).
$(1): source file
$(2): destination file, must end with .xml.
Function: copy-file-to-target
The -t option to acp and the -p option to cp is
required for OSX. OSX has a ridiculous restriction
where it's an error for a .a file's modification time
to disagree with an internal timestamp, and this
macro is used to install .a files (among other things).
Copy a single file from one place to another,
preserving permissions and overwriting any existing
file.
We disable the "-t" option for acp cannot handle
high resolution timestamp correctly on file systems like ext4.
Therefore copy-file-to-target is the same as copy-file-to-new-target.
Function: copy-file-to-target-with-cp
The same as copy-file-to-target, but use the local
cp command instead of acp.
Function: copy-file-to-target-with-zipalign
The same as copy-file-to-target, but use the zipalign tool to do so.
Function: copy-file-to-target-strip-comments
The same as copy-file-to-target, but strip out "# comment"-style
comments (for config files and such).
Function: copy-file-to-new-target
The same as copy-file-to-target, but don't preserve
the old modification time.
Function: copy-file-to-new-target-with-cp
The same as copy-file-to-new-target, but use the local
cp command instead of acp.
Function: transform-prebuilt-to-target
Copy a prebuilt file to a target location.
Function: transform-prebuilt-to-target-with-zipalign
Copyaprebuiltfiletoatargetlocation,usingzipalignonit.
Function: transform-prebuilt-to-target-strip-comments
Copy a prebuilt file to a target location, stripping "# comment" comments.
Function: transform-host-ranlib-copy-hack
Onsomeplatforms(MacOS),aftercopyingastatic
library,ranlibmustberuntoupdateaninternal
timestamp!?!?!
Function: proguard-disabled-commands
Commands to call Proguard
Command to copy the file with acp, if proguard is disabled.
Function: proguard-enabled-commands
Command to copy the file with acp, if proguard is disabled.
Function: get-instrumentation-proguard-flags
Figure out the proguard dictionary file of the module that is instrumentationed for.
Function: transform-generated-source
Stuffsourcegeneratedfromone-offtools
Function: image-size-from-data-size
将data分区大小(在/proc/mtd里存储)转为能够刷入该分区的img文件大小
Convert a partition data size (eg, as reported in /proc/mtd) to the
size of the image used to flash that partition (which includes a
spare area for each page).
$(1): the partition data size
Function: assert-max-file-size
确保文件大小不超过某个数值
$(1): The file(s) to check (often $@)
$(2): The maximum total image size, in decimal bytes
$(3): the type of filesystem "yaffs" or "raw"
If $(2) is empty, evaluates to "true"
Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks)
is left over after the image has been flashed. Round the 1% up to the
next whole flash block size.
Function: assert-max-image-size
确保image大小不超过某个数值
Like assert-max-file-size, but the second argument is a partition
size, which we'll convert to a max image size before checking it
against the files.
$(1): The file(s) to check (often $@)
$(2): The partition size.
Function: add-radio-file
添加radio包
Define device-specific radio files
Copy a radio image file to the output location, and add it to
INSTALLED_RADIOIMAGE_TARGET.
$(1): filename
Function: add-radio-file-checked
Version of add-radio-file that also arranges for the version of the
file to be checked against the contents of
$(TARGET_BOARD_INFO_FILE).
$(1): filename
$(2): name of version variable in board-info (eg, "version-baseband")
Function: inherit-package
Override the package defined in $(1), setting the
variables listed below differently.
$(1): The makefile to override (relative to the source
tree root)
$(2): Old LOCAL_PACKAGE_NAME value.
$(3): New LOCAL_PACKAGE_NAME value.
$(4): New LOCAL_MANIFEST_PACKAGE_NAME value.
$(5): New LOCAL_CERTIFICATE value.
$(6): New LOCAL_INSTRUMENTATION_FOR value.
$(7): New LOCAL_MANIFEST_INSTRUMENTATION_FOR value.
Note that LOCAL_PACKAGE_OVERRIDES is NOT cleared in
clear_vars.mk.
Function: set-inherited-package-variables
To be used with inherit-package above
Evalutes to true if the package was overridden
Function: keep-or-override
参见inherit-package
Function: expand-required-modules
Expand a module name list with REQUIRED modules
$(1): The variable name that holds the initial module name list.
the variable will be modified to hold the expanded results.
$(2): The initial module name list.
Returns empty string (maybe with some whitespaces).
Function: check-api
API Checkeval this to define a rule that runs apicheck.
Args:
$(1) target
$(2) stable api file
$(3) api file to be tested
$(4) arguments for apicheck
$(5) command to run if apicheck failed
$(6) target dependent on this api check
$(7) additional dependencies