mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
This also adds CMake capabilities to the command-based libraries as well as wpilibExamples.
256 lines
10 KiB
Groovy
256 lines
10 KiB
Groovy
import org.gradle.language.base.internal.ProjectLayout
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'c'
|
|
apply plugin: 'google-test-test-suite'
|
|
apply plugin: 'visual-studio'
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
apply plugin: ExtraTasks
|
|
|
|
evaluationDependsOn(':hal')
|
|
|
|
apply from: '../shared/config.gradle'
|
|
apply from: "${rootDir}/shared/googletest.gradle"
|
|
|
|
ext.examplesMap = [:]
|
|
ext.templatesMap = [:]
|
|
|
|
File examplesTree = file("$projectDir/src/main/cpp/examples")
|
|
examplesTree.list(new FilenameFilter() {
|
|
@Override
|
|
public boolean accept(File current, String name) {
|
|
return new File(current, name).isDirectory();
|
|
}
|
|
}).each {
|
|
examplesMap.put(it, [])
|
|
}
|
|
File templatesTree = file("$projectDir/src/main/cpp/templates")
|
|
templatesTree.list(new FilenameFilter() {
|
|
@Override
|
|
public boolean accept(File current, String name) {
|
|
return new File(current, name).isDirectory();
|
|
}
|
|
}).each {
|
|
templatesMap.put(it, [])
|
|
}
|
|
|
|
nativeUtils.platformConfigs.named(nativeUtils.wpi.platforms.roborio).configure {
|
|
cppCompiler.args.remove('-Wno-error=deprecated-declarations')
|
|
cppCompiler.args.add('-Werror=deprecated-declarations')
|
|
}
|
|
|
|
ext {
|
|
sharedCvConfigs = examplesMap + templatesMap + [commands: []]
|
|
staticCvConfigs = [:]
|
|
useJava = false
|
|
useCpp = true
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
model {
|
|
components {
|
|
commands(NativeLibrarySpec) {
|
|
binaries.all { binary ->
|
|
if (binary in StaticLibraryBinarySpec) {
|
|
binary.buildable = false
|
|
return
|
|
}
|
|
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
|
|
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(binary, 'shared')
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = ['src/main/cpp/commands']
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/cpp/commands'
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
examplesMap.each { key, value ->
|
|
"${key}"(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
binaries.all { binary ->
|
|
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
|
|
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(binary, 'shared')
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/cpp/examples/' + "${key}" + "/cpp"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/cpp/examples/' + "${key}" + "/include"
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
sources {
|
|
c {
|
|
source {
|
|
srcDirs 'src/main/cpp/examples/' + "${key}" + "/c"
|
|
include '**/*.c'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/cpp/examples/' + "${key}" + "/include"
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
templatesMap.each { key, value ->
|
|
"${key}"(NativeExecutableSpec) {
|
|
targetBuildTypes 'debug'
|
|
binaries.all { binary ->
|
|
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
|
|
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(binary, 'shared')
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
binary.tasks.withType(CppCompile) {
|
|
if (!(binary.toolChain in VisualCpp)) {
|
|
cppCompiler.args "-Wno-error=deprecated-declarations"
|
|
} else {
|
|
cppCompiler.args "/wd4996"
|
|
}
|
|
}
|
|
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/cpp/templates/' + "${key}" + "/cpp"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/cpp/templates/' + "${key}" + "/include"
|
|
include '**/*.h'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
testSuites {
|
|
examplesMap.each { key, value ->
|
|
def testFolder = new File("${rootDir}/wpilibcExamples/src/test/cpp/examples/${key}")
|
|
if (testFolder.exists()) {
|
|
"${key}Test"(GoogleTestTestSuiteSpec) {
|
|
for (NativeComponentSpec c : $.components) {
|
|
if (c.name == key) {
|
|
testing c
|
|
break
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs "src/test/cpp/examples/${key}/cpp"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs "src/test/cpp/examples/${key}/include"
|
|
}
|
|
}
|
|
c {
|
|
source {
|
|
srcDirs "src/test/cpp/examples/${key}/c"
|
|
include '**/*.c'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs "src/test/cpp/examples/${key}/include"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
binaries {
|
|
withType(GoogleTestTestSuiteBinarySpec) {
|
|
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
|
|
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
project(':hal').addHalDependency(it, 'shared')
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
|
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
|
}
|
|
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
|
|
|
|
it.cppCompiler.define('RUNNING_FRC_TESTS')
|
|
it.cCompiler.define('RUNNING_FRC_TESTS')
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
model {
|
|
tasks {
|
|
def c = $.components
|
|
project.tasks.register('buildDesktopCpp') { compileTask->
|
|
def systemArch = getCurrentArch()
|
|
c.each {
|
|
if (it in NativeExecutableSpec && it.name) {
|
|
it.binaries.each {
|
|
def arch = it.targetPlatform.name
|
|
if (arch == systemArch && it.buildType.name == 'debug') {
|
|
compileTask.dependsOn it.tasks.link
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ext {
|
|
templateDirectory = new File("$projectDir/src/main/cpp/templates/")
|
|
templateFile = new File("$projectDir/src/main/cpp/templates/templates.json")
|
|
exampleDirectory = new File("$projectDir/src/main/cpp/examples/")
|
|
exampleFile = new File("$projectDir/src/main/cpp/examples/examples.json")
|
|
commandDirectory = new File("$projectDir/src/main/cpp/commands/")
|
|
commandFile = new File("$projectDir/src/main/cpp/commands/commands.json")
|
|
}
|
|
|
|
ext {
|
|
isCppCommands = true
|
|
}
|
|
apply from: "${rootDir}/shared/examplecheck.gradle"
|