Home >Backend Development >C++ >How Can I Exclude Files from LOCAL_SRC_FILES in the NDK Gradle DSL?
Question:
Can LOCAL_SRC_FILES be defined within an NDK DSL block in Gradle?
Original Answer (Deprecated):
Currently, this feature is not supported by the Gradle plugin. Consider using the traditional Android.mk file.
Updated Answer:
With the release of Gradle plugin 0.4.0, this is now possible using exclusion patterns.
android.sources { main { jni.source { srcDirs = ["~/srcs/jni"] exclude "**/win.cpp" } } }
Alternative Solution with Static Library:
To exclude files from NDK builds without using LOCAL_SRC_FILES, a different approach can be taken.
model { android.ndk { moduleName = "hello-jni" abiFilters += "$appAbi".toString() ldFlags += "$staticLib".toString() ldLibs += "log" cppFlags += "-std=c++11" } }
LOCAL_MODULE := staticLib LOCAL_SRC_FILES := HelloJni.cpp LOCAL_CPPFLAGS += -std=c++11 include $(BUILD_STATIC_LIBRARY)
This approach effectively excludes the specified files from regular NDK builds and ensures the necessary symbols are available for debugging.
Note: Remember to trigger a "Build/Clean" after modifying the exclusion settings.
The above is the detailed content of How Can I Exclude Files from LOCAL_SRC_FILES in the NDK Gradle DSL?. For more information, please follow other related articles on the PHP Chinese website!