【发布时间】:2017-11-02 09:19:38
【问题描述】:
我是 Gradle 新手,正在尝试为 C++ 项目创建跨平台构建脚本。
我希望使用自定义源目录。不是src/{ProjectName}/cpp 或header/{ProjectName}/cpp。
我的源文件位于与build.gradle 文件处于同一级别的名为src 和include 的文件夹中。
请看我的项目目录结构图片
如何仅链接到这些源文件夹? gradle cpp 库示例不包括这一点。 我制作的脚本成功构建但不生成 exe。我猜是因为它找不到 cpp 文件。
更好的是如何查看 gradle 使用的路径? options -"-info" 和 "--debug" 似乎没有输出使用的源路径。
以下是我的完整脚本……
apply plugin: 'cpp'
model {
buildTypes {
debug
release
}
platforms {
//osx_64 {
//architecture "x86_64"
//operatingSystem "osx"
//}
windows_x86 {
architecture "x86"
operatingSystem "windows"
}
windows_64 {
architecture "x86_64"
operatingSystem "windows"
}
}
repositories {
libs(PrebuiltLibraries) {
libcinder {
headers.srcDir "/../cinder/include/"
binaries.withType(StaticLibraryBinary) {
if (targetPlatform.operatingSystem.windows) {
if (targetPlatform == platforms.windows_x86) {
if(buildType == buildTypes.debug) {
staticLibraryFile = file("/../cinder/lib/msw/x86/Debug/v140/cinder.lib")
} else if(buildType == buildTypes.release) {
staticLibraryFile = file("/../cinder/lib/msw/x86/Release/v140/cinder.lib")
}
} else if(targetPlatform == platforms.windows_64) {
if(buildType == buildTypes.debug) {
staticLibraryFile = file("/../cinder/lib/msw/x64/Debug/v140/cinder.lib")
} else if(buildType == buildTypes.release) {
staticLibraryFile = file("/../cinder/lib/msw/x64/Release/v140/cinder.lib")
}
}
} //else if(targetPlatform.operatingSystem.o osx) {
//if (targetPlatform == platforms.osx_64) {
//if(buildType == buildTypes.debug) {
//staticLibraryFile = file("/../cinder/lib/macosx/Debug/libcinder.a")
//} else if(buildType == buildTypes.release) {
//staticLibraryFile = file("/../cinder/lib/macosx/Release/libcinder.a")
//}
//}
//}
}
}
}
}
components {
main(NativeExecutableSpec) {
sources {
cpp {
source {
srcDir "src"
include "include"
cpp.lib library: "libcinder", linkage: "static"
}
}
}
}
}
/*
components {
main(NativeExecutableSpec) {
sources {
cpp.lib library: "libcinder", linkage: "static"
}
}
}
*/
}
【问题讨论】:
标签: c++ gradle build.gradle gradlew