设为首页 加入收藏

TOP

Android编译系统 - pathmap.mk
2014-11-24 08:22:46 来源: 作者: 【 】 浏览:1
Tags:Android 编译 系统 pathmap.mk

build/core/pathmap.mk 文件定义了一个列表pathmap_INCL列表中每项是"短名:路径"对。宏函数include-path-for将会使用这个列表,来通过短名获取相对于的路径


如:$(call include-path-for,短名)




#


# A mapping from shorthand names to include directories.


# "短名: 路径"对列表pathmap_INCL


pathmap_INCL := \


bluedroid:system/bluetooth/bluedroid/include \


bluez-libs:external/bluez/libs/include \


bluez-utils:external/bluez/utils \


bootloader:bootable/bootloader/legacy/include \


corecg:external/skia/include/core \


dbus:external/dbus \


frameworks-base:frameworks/base/include \


graphics:external/skia/include/core \


libc:bionic/libc/include \


libdrm1:frameworks/base/media/libdrm/mobile1/include \


libdrm2:frameworks/base/media/libdrm/mobile2/include \


libhardware:hardware/libhardware/include \


libhardware_legacy:hardware/libhardware_legacy/include \


libhost:build/libs/host/include \


libm:bionic/libm/include \


libnativehelper:dalvik/libnativehelper/include \


libpagemap:system/extras/libpagemap/include \


libril:hardware/ril/include \


libstdc++:bionic/libstdc++/include \


libthread_db:bionic/libthread_db/include \


mkbootimg:system/core/mkbootimg \


recovery:bootable/recovery \


system-core:system/core/include




#


# Returns the path to the requested module's include directory,


# relative to the root of the source tree. Does not handle external


# modules.


#


# $(1): a list of modules (or other named entities) to find the includes for


#


define include-path-for


$(foreach n,$(1),$(patsubst $(n):%,%,$(filter $(n):%,$(pathmap_INCL))))


endef



上面的宏函数include-path-for使用了3make内嵌函数:foreachpatsubstfilter



foreach


它是一个循环函数,类似于Linuxshell中的for语句,语法格式如下:


$(foreach VAR, LIST, TEXT)


include-path-for宏函数中:


VAR = n (是一个临时变量,只在foreach函数上下文中有效)


LIST = $(1) ( call include-path-for 时传递进来的参数,可以使很多空格隔开的字符串)


TEXT = $(patsubst $(n):%,%,$(filter $(n):%,$(pathmap_INCL))) (是每次循环时执行的表达式)


foreach函数和c语言中的如下格式的for循环类似:


for( int n, int i=0 ; i < number(LIST); i++)


{


n = LIST第一个字符串;


执行TEXT(引用n)表达式;


LIST丢掉第一个字符串


}



filter


过滤函数,$(filter PATTERN…,TEXT)


过滤掉字串“TEXT”中所有不符合模式“PATTERN”的单词,保留所有符合此模式的单词。可以使用多个模式。模式中一般需要包含模式字符“%”。存在多个模式时,模式表达式之间使用空格分割。


sources := foo.c bar.c baz.s ugh.h


foo: $(sources)


cc $(filter %.c %.s,$(sources)) -o foo


返回值为“foo.c bar.c baz.s”。


$(filter $(n):%,$(pathmap_INCL)), 滤除掉pathmap_INCL列表中不属于以:隔开的字符串模式的字符串。


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇交叉编译安装ffmpeg-0.6.1的配置.. 下一篇Android编译系统 - findleaves.sh

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Python 数据分析与可 (2025-12-26 21:51:20)
·从零开始学Python之 (2025-12-26 21:51:17)
·超长干货:Python实 (2025-12-26 21:51:14)
·为什么 Java 社区至 (2025-12-26 21:19:10)
·Java多线程阻塞队列 (2025-12-26 21:19:07)