首页 > 代码库 > [转]编写 android.mk 中 LOCAL_C_INCLUDES 的技巧

[转]编写 android.mk 中 LOCAL_C_INCLUDES 的技巧

看原文请移步:编写 android.mk 中 LOCAL_C_INCLUDES 的技巧

在编写android.mk的过程中,免不了要修改LOCAL_C_INCLUDES来设置头文件的include目录, 一般写成这样

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes                     $(LOCAL_PATH)/../../Classes/game                     $(LOCAL_PATH)/../../Classes/logic                     $(LOCAL_PATH)/../../Classes/view                    

有一个目录就要写一行, 实在繁琐, 有没有写法可以把源码目录下的所有子目录都引入呢, 看下面

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../ClassesLOCAL_C_INCLUDES += $(shell ls -FR $(LOCAL_C_INCLUDES) | grep $(LOCAL_PATH)/$ )LOCAL_C_INCLUDES := $(LOCAL_C_INCLUDES:$(LOCAL_PATH)/%:=$(LOCAL_PATH)/%)

即可把$(LOCAL_PATH)/../../Classes目录和子目录全部包含进来

还有一种写法, 就是使用sed命令, 效果是一样的, 我对sed不是很熟悉, 简单写了一下

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_C_INCLUDES += $(shell ls -FR $(LOCAL_C_INCLUDES) | grep $(LOCAL_PATH)/$ | sed "s/:/ /g" )

这两行和上面三行的结果是一样的

[转]编写 android.mk 中 LOCAL_C_INCLUDES 的技巧