查询地址:http://android.cloudchou.com/build/core/base_rules.php#LOCAL_INSTALLED_MODULE
base_rules.mk里定义了生成某种目标的方式
目标类型:主机上的可执行程序,设备上的可执行程序,apk程序,Java运行库,动态链接库等等
Android编译系统里每一种目标的生成方式对应一个makefile,
示例:如果某个模块需要编译成手机上的二进制程序,它需要include $(BUILD_EXECUTABLE)
而BUILD_EXECUTABLE指向的是$(BUILD_SYSTEM)/executable.mk
所有生成方式对应的makefile都将包含base_rules.mk
每个模块都在Android.mk里定义,表示模块所在目录
LOCAL_MODULE表示模块的名称
LOCAL_MODULE将在每个模块的makefile里定义,如果未定义,编译系统会报错
表示该模块生成的目标是否在主机上运行,
若定义了 LOCAL_IS_HOST_MODULE 为true,那么my_prefix:=HOST_,否则 my_prefix:=TARGET_
若定义了 LOCAL_IS_HOST_MODULE 为true,那么 my_host:=host-,否则 my_host:=
表示该模块是否安装至手机,像sdk文档模块不会被安装至手机,因此LOCAL_UNINSTALLABLE_MODULE为true
模块的tag,为debug eng tests optional samples shell_ash shell_mksh等tag的组合,一个模块可有多个Tag,
注意现在模块现在不能使用user作为模块的Tag,
以前如果使用user做为tag,那么这个模块将被自动安装,
如果想定义自动安装的模块,需要在PRODUCT_PACKAGES变量里添加该模块,
该变量在build/target/product/base.mk和build/target/product/core.mk里有赋值,这是所有产品都将继承的基础配置
另外每个设备可在自己的产品配置文件device_*.mk里设置该变量,添加更多的模块
如果当前目录或者父目录有*_GPL*的文件,那么将自动添加gnu的tag
user: 指该模块只在user版本下才编译
eng: 指该模块只在eng版本下才编译
tests: 指该模块只在tests版本下才编译
optional:指该模块在所有版本下都编译
将用于决定编译时的中间文件存放的位置
LOCAL_MODULE_CLASS在定义目标生成方式的makefile文件里定义,
比如executable.mk里定义LOCAL_MODULE_CLASS := EXECUTABLES
在recovery模块的Android.mk里定义的LOCAL_MODULE_CLASS有:
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_CLASS := UTILITY_EXECUTABLES
其它的LOCAL_MODULE_CLASS有
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_CLASS := FAKE
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_CLASS := APPS
对应 Cyanogenmod/target/product/m7ul/obj 的目录
比如说若 LOCAL_MODULE_CLASS := ETC
那么该模块编译的中间文件将存放于
Cyanogenmod/target/product/m7ul/obj/ETC
如果是主机模块,partition_tag将为空,否则如果是设备专有模块,partition_tag:=_VENDOR
否则如果是安装到系统的模块,那么partition_tag将为空(test模块生成的目标只安装至data目录)
否则partition_tag:=_DATA
是否是设备专有模块
表示模块生成的目标将最终存放的目录
recovery模块的Android.mk里有
LOCAL_MODULE := nandroid-md5.sh
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
说明:nandroid-md5.sh 将存放于out/Cyanogenmod/target/product/m7ul/recovery/root/sbin
如果模块的Android.mk里未定义LOCAL_MODULE_PATH
那么LOCAL_MODULE_PATH := $($(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS))
在recovery模块里recovery可执行文件相关变量如下:
比如my_prefix为TARGET_,partition_tag为空,LOCAL_MODULE_CLASS为EXECUTABLES
那么LOCAL_MODULE_PATH为$(TARGET_OUT_EXECUTABLES),
值应该为
out/Cyanogenmod/target/product/m7ul/system/bin
用于确保每个模块都是唯一的
module_id := MODULE.$(if \
$(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(LOCAL_MODULE)
如果$(module_id)已经定义过,那会提示用户出错
recovery模块的Android.mk里针对recovery可执行文件:
module_id := MODULE.TARGET.EXECUTABLES.RECOVERY
$(MODULE.TARGET.EXECUTABLES.RECOVERY)=$(LOCAL_PATH)
即当前模块路径
intermediates := $(call local-intermediates-dir)
例: recovery模块Android.mk里编译Recovery可执行文件:
out/target/product/find5/obj/EXECUTABLES/recovery_intermediates
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
例: recovery模块Android.mk里编译Recovery可执行文件:
out/target/common/obj/EXECUTABLES/recovery_intermediates
表示编译链接后的目标文件的文件名,不带后缀
LOCAL_MODULE_STEM := $(strip $(LOCAL_MODULE_STEM))
ifeq ($(LOCAL_MODULE_STEM),)
LOCAL_MODULE_STEM := $(LOCAL_MODULE)
endif
例:
recovery模块编译recovery可执行文件:
LOCAL_MODULE_STEM:=recovery
表示编译链接后的目标文件的后缀
表示要安装的目标文件的文件名,带后缀
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE_STEM)$(LOCAL_MODULE_SUFFIX)
例:
recovery模块编译recovery可执行文件:
LOCAL_INSTALLED_MODULE_STEM:=recovery
表示编译链接后的目标文件的文件名,带后缀
LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
ifeq ($(LOCAL_BUILT_MODULE_STEM),)
LOCAL_BUILT_MODULE_STEM := $(LOCAL_INSTALLED_MODULE_STEM)
endif
例:
recovery模块编译recovery可执行文件:
LOCAL_INSTALLED_MODULE_STEM:=recovery
只有内部动态链接库模块可以使用OVERRIDE_BUILT_MODULE_PATH
OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
ifdef OVERRIDE_BUILT_MODULE_PATH
ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
$(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
endif
built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
else
built_module_path := $(intermediates)
endif
参见OVERRIDE_BUILT_MODULE_PATH
表示编译链接后的目标文件(文件路径+文件名)
LOCAL_BUILT_MODULE := $(built_module_path)/$(LOCAL_BUILT_MODULE_STEM)
比如recovery:
LOCAL_BUILT_MODULE 路径;
out/Cyanogenmod/target/product/m7ul/obj/EXECUTABLES/recovery_intermediates/recovery
表示模块的安装路径+文件名
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
LOCAL_INSTALLED_MODULE := $(LOCAL_MODULE_PATH)/$(LOCAL_INSTALLED_MODULE_STEM)
endif
示例:
out/Cyanogenmod/target/product/m7ul/system/bin/recovery
Assemble the list of targets to create PRIVATE_ variables for.
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
将所有目标添加到变量LOCAL_INTERMEDIATE_TARGETS里
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
表示所有源代码中的aidl文件
aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
如果想编译aidl,只需将aidl加入LOCAL_SRC_FILES即可,
frameworks/base/Android.mk里有将aidl文件加入LOCAL_SRC_FILES变量
LOCAL_SRC_FILES += \
core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \
core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl \
core/java/android/accounts/IAccountManager.aidl \
core/java/android/accounts/IAccountManagerResponse.aidl \
core/java/android/accounts/IAccountAuthenticator.aidl \
如果没有定义 TARGET_BUILD_APPS 变量,说明要编译framework.jar,那么将
LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
在base_rules里定义了如何将aidl文件编译成java文件的方式,包括文件依赖
表示源代码中的logtags文件
frameworks/base/Android.mk里有将logtas文件加入LOCAL_SRC_FILES变量
LOCAL_SRC_FILES += \
core/java/android/content/EventLogTags.logtags \
core/java/android/speech/tts/EventLogTags.logtags \
core/java/android/webkit/EventLogTags.logtags \
在base_rules里定义了如何将logtag文件编译成java文件的方式,包括文件依赖
logtags文件最终会被logcat程序使用到
表示源代码中的proto文件
在definitions里定义了all-proto-files-under方法添加所有proto文件
在./hardware/ril/mock-ril/Android.mk里有调用该方法
在base_rules里定义了如何将.proto文件编译成java文件的方式,包括文件依赖
表示编译生成的源文件存放目录
LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
例:out/target/common/obj/EXECUTABLES/recovery_intermediates/src
java资源文件所在目录
所有Java源代码
Compile .java files to .class
java库用的manifest
示例:
inputmethods/LatinIME/tools/maketext/Android.mk:20:LOCAL_JAR_MANIFEST := etc/manifest.txt
inputmethods/LatinIME/tools/dicttool/Android.mk:29:LOCAL_JAR_MANIFEST := etc/manifest.txt
编译为java静态库
定义一个模块的清除目标,如:recovery模块,有对应的clean-recovery
如果在编译时用mka clean-recovery,将清除编译recovery时产生的文件,
包括编译中间文件和编译目标文件
需要检查的模块
ifndef LOCAL_CHECKED_MODULE
ifndef LOCAL_SDK_VERSION
LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
endif
endif
如果定义了该变量,那么模块将不被检查
ifdef LOCAL_DONT_CHECK_MODULE
LOCAL_CHECKED_MODULE :=
endif
所有的(LOCAL_MODULE)都会被加入ALL_MODULES变量
ALL_MODULES += $(LOCAL_MODULE)
将LOCAL_MODULE_CLASS加入到ALL_MODULES.$(LOCAL_MODULE).CLASS管理,
这样可以得到所有模块的所有CLASS
ALL_MODULES.$(LOCAL_MODULE).CLASS := \
$(ALL_MODULES.$(LOCAL_MODULE).CLASS) $(LOCAL_MODULE_CLASS)
示例:
ALL_MODULES.recovery.CLASS = EXECECUTABLE
一个模块可能既编译为手机上的可执行程序,又编译为电脑上的可执行程序
故此ALL_MODULES.recovery.CLASS 可能由多个CLASS组合
所有模块路径
ALL_MODULES.$(LOCAL_MODULE).PATH := \
$(ALL_MODULES.$(LOCAL_MODULE).PATH) $(LOCAL_PATH)
示例:
ALL_MODULES.recovery.PATH bootable/recovery
所有模块的所有TAGS
ALL_MODULES.$(LOCAL_MODULE).TAGS := \
$(ALL_MODULES.$(LOCAL_MODULE).TAGS) $(LOCAL_MODULE_TAGS)
示例:
ALL_MODULES.recovery.TAGS eng
所有模块的所有是否被检查属性
ALL_MODULES.$(LOCAL_MODULE).CHECKED := \
$(ALL_MODULES.$(LOCAL_MODULE).CHECKED) $(LOCAL_CHECKED_MODULE)
示例:
ALL_MODULES.recovery.CHECKED
out/Cyanogenmod/target/product/m7ul/obj/EXECUTABLES/recovery_intermediates/recovery
所有模块的所有生成路径
ALL_MODULES.$(LOCAL_MODULE).BUILT := \
$(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
示例:
out/Cyanogenmod/target/product/m7ul/obj/EXECUTABLES/recovery_intermediates/recovery
所有模块的各自安装路径
ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
$(strip $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE))
示例:
out/Cyanogenmod/target/product/m7ul/system/bin/recovery
所有模块的各自依赖模块
ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
$(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
binary.mk:
LOCAL_REQUIRED_MODULES += $(installed_shared_library_module_names)
所有模块的EVENT_LOG_TAGS
ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
$(ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS) $(event_log_tags)
event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
所有模块的生成代码的目录集合
ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR := \
$(ALL_MODULES.$(LOCAL_MODULE).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
所有模块各自的makefile集合
ALL_MODULES.$(LOCAL_MODULE).MAKEFILE := \
$(ALL_MODULES.$(LOCAL_MODULE).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
举例:
bootable/recovery/Android.mk
所有模块各自的OWNER
ifdef LOCAL_MODULE_OWNER
ALL_MODULES.$(LOCAL_MODULE).OWNER := \
$(sort $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
endif
三星glaxsy2有定义LOCAL_MODULE_OWNER变量
./vendor/samsung/galaxys2-common/proprietary/Android.mk:21:LOCAL_MODULE_OWNER := samsung
所有模块各自安装的名字
INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
例子:
INSTALLABLE_FILES.out/Cyanogenmod/target/product/m7ul/system/bin/recovery.MODULE:=recovery
所有模块的所有TAGS
ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(LOCAL_MODULE_TAGS))
例:
ALL_MODULE_TAGS debug eng tests optional samples shell_ash shell_mksh
每个Tag对应的模块安装路径集合
$(foreach tag,$(LOCAL_MODULE_TAGS),\
$(eval ALL_MODULE_TAGS.$(tag) := \
$(ALL_MODULE_TAGS.$(tag)) \
$(LOCAL_INSTALLED_MODULE)))
每个TAG对应的模块集合
$(foreach tag,$(LOCAL_MODULE_TAGS),\
$(eval ALL_MODULE_NAME_TAGS.$(tag) += $(LOCAL_MODULE)))
定义了公共的编译系统变量ALL_*,
还定义了很多命令用来编译各种各样的目标,
其它地方用来构建最终目标,build/core/main.mk,build/core/Makefile将用到这些变量
所有文档的全路径
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.$(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
所有默认要安装的模块,在build/core/main.mk和build/core/makfile里设置
Full paths to targets that should be added to the "make droid" set of installed targets.
droid目标将安装的所有模块的集合
使用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_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
安装在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
将会被拷贝的预编译文件的安装全路径的集合
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
某些工具生成的源代码文件的集合,比如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
所有asm,c,c++,以及lex和yacc生成的c代码文件的全路径
这些都对拷贝的头文件有一个按序的依赖关系
没有被优化,也没有被压缩的动态链接库
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
将会放在sdk的文件
These files go into the SDK
主要赋值:development/build/Android.mk
dalvik虚拟机需要的文件
Files for dalvik. This is often build without building the rest of the OS
在dalvik/dx/src/Android.mk dalvik/dx/Android.mk中有赋值
所有findbugs程序用的xml文件
build/core/java.mk:400:ALL_FINDBUGS_FILES += $(findbugs_xml)
All findbugs xml 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 资源文件生成的java代码编译后的类的类型
ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
在build/core/static_java_library.mk中有用到,用于排除某些文件,使其不被打包至lib文件
Debugging; prints a variable list to stdout
用于打印变量的值
$(1): variable name list, not variable values
如果参数含有true,则返回true,否则返回空
$(1) 要测试的变量
返回当前makefile所在目录
获取某个目录下及子目录的所有Android.mk
$(1):需要提取Android.mk的目录
在某个目录下的所有子目录中查找Android.mk,不包括当前目录
$(1):要搜索的目录
查找当前目录及子目录下的所有Android.mk
在当前目录下的一组子目录下查找Android.mk
$(1): List of directories to look for under this directory
找出当前makefile所在目录的指定子目录里的所有java文件
$(1) 指定子目录
使用范例:SRC_FILES := $(call all-java-files-under,src tests)
从当前目录查找所有java文件
使用范例: SRC_FILES := $(call all-subdir-java-files)
在指定子目录下找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: 指定子目录名称
查找当前目录所有子目录的c代码文件
Find all of the c files from here. Meant to be used like:
SRC_FILES := $(call all-subdir-c-files)
在指定子目录下查找所有类似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: 指定子目录名称
在$(LOCAL_PATH)下查找所有I*.aidl代码文件
Find all of the "I*.aidl" files under $(LOCAL_PATH).
在指定子目录下查找所有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:指定子目录名称
在指定子目录下查找所有.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:指定子目录名称
在指定子目录下查找所有.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:指定子目录名称
在指定子目录下查找所有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:指定子目录名称
在当前目录的子目录里查找所有html文件
Find all of the html files from here. Meant to be used like:
SRC_FILES := $(call all-subdir-html-files)
根据find命令的规则查找所有文件
Find all of the files matching pattern
SRC_FILES := $(call find-subdir-files, )
$1 find命令的匹配规则
在指定子目录下根据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 过滤的文件
查找所有不是软链且文件名不带后缀的文件
SRC_FILES := $(call find-subdir-assets)
$1 要进入并查找的目录
在$(LOCAL_PATH)里根据find命令的匹配规则查找java文件
$1 find命令的匹配规则
在$(LOCAL_PATH)里根据find命令的匹配规则查找html文件
$1 find命令的匹配规则
在$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 we can evaluate to introduce a dynamic dependency
$1 需要依赖其它东东的目标
$2 被依赖的东东
Set up the dependencies for a prebuilt target
$(call add-prebuilt-file, srcfile, [targetclass])
$(1): srcfile
$(2): target class
domultipleprebuilts
$(calltargetclass,files...)
$(1)targetclass
$(2)srcfiles
使用举例:
gdbserver/Android.mk:$(calladd-prebuilt-files,EXECUTABLES,$(prebuilt_files))
查找中间目录并返回
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
利用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
将"path/to/libXXX.so"转为 -lXXX
Convert "path/to/libXXX.so" to "-lXXX".
Any "path/to/libXXX.a" elements pass through unchanged.
参见normalize-libraries,和之类似
参见normalize-libraries,和之类似
将模块名字转为它们对应的编译生成路径
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
将模块名字转为它们对应的安装路径
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
将模块名字转为它们要作为公共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
为文档模块转为timestamp为文件,这个文件是添加依赖时会用到的
Evaluates to the timestamp file for a doc module, which
is the dependency that should be used.
$(1): doc module
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
多个javalib.jar
$(1): library name list
$(2): Non-empty if IS_HOST_MODULE
Run rot13 on a string rot13 是一种简易的置换暗码
$(1): the string. Must be one line.
Returns true if $(1) and $(2) are equal. Returns
the empty string if they are not equal.
Convert "a b c" into "a:b:c"
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...
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.
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.
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
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
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
Append a leaf to a base path. Properly deals with
base paths ending in /.
$(1): base path
$(2): leaf path
Packagefiltering
#Givenalistofinstalledmodules(shortorlongnames)
#returnalistofthepackages(yes,.apkpackages,not
#modulesingeneral)thatareoverriddenbythislistand,
#therefore,shouldnotbeinstalled.
#$(1):mixedlistofinstalledmodules
#TODO:Thisisfragile;findareliablewaytogetthisinformation.
Output the command lines, or not
如果编译时传递了添加了showcommands参数,调用pretty会打印正在执行的命令
如果没有传递showcommand参数,则不会打印正在执行的命令
Dump the variables that are associated with targets
打印编译时的一些参数
主要是一些PRIVATE变量,例如PRIVATE_YACCFLAGS
Commands for using sed to replace given variable values
CommandsformungingthedependencyfilesGCCgenerates
$(1):theinput.dfile
$(2):theoutput.Pfile
参见 transform-d-to-p-args
Commands for running lex
举例:
ifneq ($(strip $(lex_cpps)),)
$(lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
$(TOPDIR)$(LOCAL_PATH)/%.l
$(transform-l-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)"
Commands to compile RenderScript
Commands for running aidl
Commands for running java-event-log-tags.py
Commands for running protoc to compile .proto into .java
Commands for running protoc to compile .proto into .pb.cc and .pb.h
Commands for running gcc to compile a C++ file
Commands for running gcc to compile a C file
# $(1): extra flags
编译c文件至目标文件,无依赖的编译
# $(1): extra flags
编译汇编文件至目标文件,无依赖的编译
$(1): extra flags
编译c文件至目标文件
# $(1): extra flags 编译参数
编译汇编文件至目标文件
$(1): extra flags,编译参数
Commands for running gcc to compile an Objective-C file
This should never happen for target builds but this
will error at build time.
编译objet c文件至目标文件
$(1): extra flags,编译参数
Commands for running gcc to compile a host C++ file
编译cpp文件,目标代码将在主机上运行
$(1): extra flags
Commands for running gcc to compile a host C file
编译c代码或者汇编代码,目标代码将在主机上运行,无依赖的编译
$(1): extra flags
Commands for running gcc to compile a host C file
编译c代码,目标代码将在主机上运行,无依赖的编译
$(1): extra flags
编译汇编代码,目标代码将在主机上运行,无依赖的编译
$(1): extra flags
编译c代码,目标代码将在主机上运行
$(1): extra flags
编译汇编代码,目标代码将在主机上运行
$(1): extra flags
Commands for running gcc to compile a host Objective-C file
编译object c代码,目标代码将在主机上运行,无依赖编译
$(1): extra flags
Commands for running gcc to compile a host Objective-C file
编译object c代码,目标代码将在主机上运行,
$(1): extra flags
Commands for running ar
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
$(1): the full path of the source static library.
Explicitly delete the archive first so that ar doesn't
try to add to an existing archive.
将目标代码打包成静态库
Commands for running host ar
$(1): the full path of the source static library.
静态库将在主机上运行
将目标代码打包成在主机上运行的静态库
静态库将在主机上运行
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.
将目标代码打包成在主机上运行的动态库或者包
参见transform-host-o-to-shared-lib-inner
参见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.
将目标代码打包成在目标机上运行的动态库
参见transform-o-to-shared-lib-inner
参见transform-o-to-shared-lib-inner
Commands for filtering a target executable or library
Commandsforrunninggcctolinkanexecutable
编译成可执行文件
参见transform-o-to-executable-inner
Commandsforrunninggcctolinkastaticallylinked
executable.Inpractice,weonlyusethisonarm,so
theotherplatformsdon'thavethe
transform-o-to-static-executabledefined
参见transform-o-to-static-executable-inner
Commands for running gcc to link a host executable
参见transform-host-o-to-executable-inner
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.
emit-line,,
dump-words-to-file,,
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
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
将java编译并打包成classes.jar
emma代码覆盖率测试
将classes.jar转化为dex
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.
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
将jni 动态库打包到package
将dex打包到package
Add java resources added by the current module.
Add java resources carried by static Java libraries.
Sign a package using the specified key/cert.
Align STORED entries of a package on 4-byte boundaries
to make them easier to mmap.
安装debug版本的dex文件
TODO(joeo):Ifwecaneverupgradetopost3.81makeandgetthe
newprebuiltrulestowork,weshouldchangethistocopythe
resourcestotheoutdirectoryandthencopytheresources.
Note:weintentionallydon'tcleanPRIVATE_CLASS_INTERMEDIATES_DIR
intransform-java-to-classesforthesakeofvm-tests.
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
混淆代码
Commands for copying files
Define a rule to copy a header. Used via $(eval) by copy_headers.make.
$(1): source header
$(2): destination header
Define a rule to copy a file. For use via $(eval).
$(1): source file
$(2): destination file
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)
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.
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.
The same as copy-file-to-target, but use the local
cp command instead of acp.
The same as copy-file-to-target, but use the zipalign tool to do so.
The same as copy-file-to-target, but strip out "# comment"-style
comments (for config files and such).
The same as copy-file-to-target, but don't preserve
the old modification time.
The same as copy-file-to-new-target, but use the local
cp command instead of acp.
Copy a prebuilt file to a target location.
Copyaprebuiltfiletoatargetlocation,usingzipalignonit.
Copy a prebuilt file to a target location, stripping "# comment" comments.
Onsomeplatforms(MacOS),aftercopyingastatic
library,ranlibmustberuntoupdateaninternal
timestamp!?!?!
Commands to call Proguard
Command to copy the file with acp, if proguard is disabled.
Command to copy the file with acp, if proguard is disabled.
Figure out the proguard dictionary file of the module that is instrumentationed for.
将jar混淆
Stuffsourcegeneratedfromone-offtools
将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
确保文件大小不超过某个数值
$(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.
确保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.
添加radio包
Define device-specific radio files
Copy a radio image file to the output location, and add it to
INSTALLED_RADIOIMAGE_TARGET.
$(1): filename
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")
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.
To be used with inherit-package above
Evalutes to true if the package was overridden
参见inherit-package
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).
API Check
eval 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