Android.mk - 在一个目录中生成所有源文件 [英] Android.mk - build all source file in a directory

查看:441
本文介绍了Android.mk - 在一个目录中生成所有源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Andr​​oid NDK建立我cocos2dx项目,在Android.mk中,对于每个cpp文件中列出LOCAL_SRC_FILES的定义。每当我添加了一个新的源文件,我需要将其添加有作为......它看起来是这样的:

I am using Android NDK to build my cocos2dx project, within the Android.mk, there is a definition for LOCAL_SRC_FILES where each of the cpp file are listed. Whenever I added a new source file, I'd need to add it there as well... it looks like this:

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   hellocpp/myclass.cpp \
                   hellocpp/mynextclass.cpp \
                   ../../Classes/Screens/LaunchScreen.cpp \

头文件,但是,可以指定整个目录包括,它看起来是这样的:

the header file, however, can specify the entire directory to include, it looks like this:

LOCAL_C_INCLUDES := $(LOCAL_PATH)/hellocpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes/Screens

我已经试过各种方法,包括整个目录,而不是为 LOCAL_SRC_FILES 单独的文件,这样我不需要修改Android.mk构建脚本,每当我添加一个新的文件,但是,到目前为止,我所有的尝试都失败了。

I have tried various ways to include the whole directory instead of single file for the LOCAL_SRC_FILES so that I don't need to modify the Android.mk build script whenever I add a new file, however, so far all my attempts failed.

我已经试过这样:

#SRC_PATH_HELLOCPP := $(wildcard hellocpp/*.cpp)
#SRC_PATH_CLASSES += $(wildcard ../../Classes/*.cpp)

#LOCAL_SRC_FILES := $(SRC_PATH_HELLOCPP:$(LOCAL_PATH/%=%)
#LOCAL_SRC_FILES += $(SRC_PATH_CLASSES:$(LOCAL_PATH/%=%)

还有这样的:

as well as this:

#LOCAL_SRC_FILES += hellocpp/*.cpp
#LOCAL_SRC_FILES += ../../Classes/*.cpp

两者都没有工作...

both are not working...

我有另一个项目,与第一个选项效果很好,虽然,我真的不明白为什么它不会在cocos2dx项目工作......没有任何人知道为什么还是知道解决的办法?或者,也许我应该保留原样,并采取了麻烦,因为每个人都这样做,但它确实是麻烦的,希望有人能帮助使我们大家都可以更有效率。

I have another project that works well with the first option though, I really do not understand why it doesn't work in the cocos2dx project... does anybody know why or know the solution? Or maybe I should just leave it as is and take the trouble, since everybody is doing that., but it is really troublesome, hope somebody can help so that all of us can be more productive..

谢谢!

推荐答案

通配符适用于cocos2dx项目,以及。我使用它在我自己的,只是你的语法不正确

The wildcard works for cocos2dx projects as well. I am using it on my own, just that your syntax is incorrect

尝试:

HELLOCPP_FILES  := $(wildcard $(LOCAL_PATH)/hellocpp/*.cpp)
HELLOCPP_FILES  := $(HELLOCPP_FILES:$(LOCAL_PATH)/%=%)

CLASSES_FILES   := $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)
CLASSES_FILES   := $(CLASSES_FILES:$(LOCAL_PATH)/%=%)

LOCAL_SRC_FILES := $(HELLOCPP_FILES)
LOCAL_SRC_FILES += $(CLASSES_FILES)

这篇关于Android.mk - 在一个目录中生成所有源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆