编写 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)/../../Classes
LOCAL_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" )

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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。