欢迎光临Software MyZone,有问题可留言或到站点论坛发帖,争取第一时间帮忙解决 || 站点论坛:火龙论坛 || 淘宝小店:应小心的易淘屋 【欢迎大家提建设性意见】

编写 android.mk 中 LOCAL_C_INCLUDES 的技巧 转

欢迎热爱编程的朋友们参与到cocos2d-x编程中,为了给大家提供良好的交流环境,网站以开启QQ群
Software MyZone:66202765(群号,欢迎加入,若满,请加1群)
Software MyZone 1群(2dx):286504621
【加群请写:Software MyZone或者是firedragonpzy】
淘宝店:【应小心的易淘屋】初次开店,大家多多支持……
群论坛:火龙论坛正试运营阶段,欢迎大家多提些建设性意见……
摘自:http://blog.ready4go.com/blog/2013/06/25/write-local-c-includes-skills-in-android-dot-mk/

在编写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" )

未测试,待定……

发表评论