1

这就是我在 JNI 文件夹中做通配符的方式

include $(CLEAR_VARS)
LOCAL_MODULE    := some_module_name
LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.cpp)) 
include $(BUILD_SHARED_LIBRARY)

现在我想将新的源文件夹添加到 JNI - some_src 与 foo.cpp 和 bar.cpp

include $(CLEAR_VARS)
LOCAL_MODULE    := some_module_name
FOLDER_PREFIX = some_scr
LOCAL_SRC_FILES := $(notdir $(wildcard $(LOCAL_PATH)/*.cpp)) $(FOLDER_PREFIX)/$(notdir $(wildcard $(LOCAL_PATH)/$(FOLDER_PREFIX)/*.cpp))
include $(BUILD_SHARED_LIBRARY)

但这只会将 $(FOLDER_PREFIX) 添加到 bar.cpp,foo.cpp 会被剥离路径 (jni/foo.cpp) 而不是构建。

如何解决?

4

1 回答 1

3
$(addprefix $(FOLDER_PREFIX),$(notdir $(wildcard $(LOCAL_PATH)/$(FOLDER_PREFIX)/*.cpp))`

或者甚至(你真的需要指定FOLDER_PREFIX吗?)

$(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*/*.cpp)))

第二种形式允许使用以下快捷方式:

LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/*/*.cpp)))
于 2012-10-10T20:34:25.027 回答