Gradle C/Native 插件:目录结构、平台和风格

Gradle C/Native Plugin: Directory Structure, Platforms and Flavors

我有一个简单的 C 程序 (helloworld) 使用 Make 在我的 Windows 7 机器上编译和构建(通过 MinGW)。我现在想将我的构建系统切换为使用 Gradle(个人原因,没有对 Make 的不敬!)并试图将我的大脑围绕 Gradle Native Plugins(实际上是 C 插件)。

我有两个具体问题:

Gradle 中本机二进制文件的约定是将头文件放在 src/{componentName}/headers 中,将 C 源文件放在 src/{componentName}/c 中,其中 componentName 是您命名组件的任何名称(鉴于这个问题,我猜那将是 helloworld,但这取决于你如何声明它)。风味适用于构建的不同变体,就像您想要构建具有不同编译功能的版本一样。针对 x86 Linux 和 64 位 Windows 等不同目标的编译只需使用平台即可完成,如下所示:

model {
    platforms {
        linux32 {
            architecture "x86"
            operatingSystem "linux"
        }
        win64 {
            architecture "x86_64"
            operatingSystem "windows"
        }
    }
}

我假设您使用的是 Gradle 2.3,但在过去的几个版本中情况发生了很大变化。