| apply plugin: 'cpp' |
| apply plugin: 'c' |
| apply plugin: 'google-test-test-suite' |
| apply plugin: 'visual-studio' |
| apply plugin: 'edu.wpi.first.NativeUtils' |
| apply plugin: SingleNativeBuild |
| apply plugin: ExtraTasks |
| |
| ext { |
| nativeName = 'wpilibc' |
| } |
| |
| apply from: "${rootDir}/shared/config.gradle" |
| |
| def wpilibVersionFileInput = file("src/generate/WPILibVersion.cpp.in") |
| def wpilibVersionFileOutput = file("$buildDir/generated/cpp/WPILibVersion.cpp") |
| |
| task generateCppVersion() { |
| description = 'Generates the wpilib version class' |
| group = 'WPILib' |
| |
| outputs.file wpilibVersionFileOutput |
| inputs.file wpilibVersionFileInput |
| |
| if (WPILibVersion.releaseType.toString().equalsIgnoreCase('official')) { |
| outputs.upToDateWhen { false } |
| } |
| |
| // We follow a simple set of checks to determine whether we should generate a new version file: |
| // 1. If the release type is not development, we generate a new verison file |
| // 2. If there is no generated version number, we generate a new version file |
| // 3. If there is a generated build number, and the release type is development, then we will |
| // only generate if the publish task is run. |
| doLast { |
| println "Writing version ${WPILibVersion.version} to $wpilibVersionFileOutput" |
| |
| if (wpilibVersionFileOutput.exists()) { |
| wpilibVersionFileOutput.delete() |
| } |
| def read = wpilibVersionFileInput.text.replace('${wpilib_version}', WPILibVersion.version) |
| wpilibVersionFileOutput.write(read) |
| } |
| } |
| |
| gradle.taskGraph.addTaskExecutionGraphListener { graph -> |
| def willPublish = graph.hasTask(publish) |
| if (willPublish) { |
| generateCppVersion.outputs.upToDateWhen { false } |
| } |
| } |
| |
| ext { |
| sharedCvConfigs = [wpilibc : [], |
| wpilibcBase: [], |
| wpilibcDev : [], |
| wpilibcTest: []] |
| staticCvConfigs = [:] |
| useJava = false |
| useCpp = true |
| } |
| |
| apply from: "${rootDir}/shared/opencv.gradle" |
| |
| project(':').libraryBuild.dependsOn build |
| |
| ext { |
| staticGtestConfigs = [:] |
| } |
| |
| staticGtestConfigs["${nativeName}Test"] = [] |
| |
| apply from: "${rootDir}/shared/googletest.gradle" |
| |
| ext { |
| chipObjectComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(), |
| "${nativeName}Test".toString()] |
| netCommComponents = ["$nativeName".toString(), "${nativeName}Dev".toString(), "${nativeName}Base".toString(), |
| "${nativeName}Test".toString()] |
| useNiJava = false |
| } |
| |
| apply from: "${rootDir}/shared/nilibraries.gradle" |
| |
| model { |
| exportsConfigs { |
| wpilibc(ExportsConfig) { |
| x86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', |
| '_CT??_R0?AVbad_cast', |
| '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', |
| '_TI5?AVfailure'] |
| x64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure', |
| '_CT??_R0?AVbad_cast', |
| '_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure', |
| '_TI5?AVfailure'] |
| } |
| } |
| components { |
| "${nativeName}Base"(NativeLibrarySpec) { |
| sources { |
| cpp { |
| source { |
| srcDirs = ['src/main/native/cpp', "$buildDir/generated/cpp"] |
| include '**/*.cpp' |
| } |
| exportedHeaders { |
| srcDirs 'src/main/native/include' |
| } |
| } |
| } |
| binaries.all { |
| if (it instanceof SharedLibraryBinarySpec) { |
| it.buildable = false |
| return |
| } |
| lib project: ':ntcore', library: 'ntcore', linkage: 'shared' |
| lib project: ':cscore', library: 'cscore', linkage: 'shared' |
| project(':hal').addHalDependency(it, 'shared') |
| lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
| lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| } |
| } |
| "${nativeName}"(NativeLibrarySpec) { |
| sources { |
| cpp { |
| source { |
| srcDirs "${rootDir}/shared/singlelib" |
| include '**/*.cpp' |
| } |
| exportedHeaders { |
| srcDirs 'src/main/native/include' |
| } |
| } |
| } |
| binaries.all { |
| lib project: ':ntcore', library: 'ntcore', linkage: 'shared' |
| lib project: ':cscore', library: 'cscore', linkage: 'shared' |
| project(':hal').addHalDependency(it, 'shared') |
| lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
| lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| } |
| appendDebugPathToBinaries(binaries) |
| } |
| // By default, a development executable will be generated. This is to help the case of |
| // testing specific functionality of the library. |
| "${nativeName}Dev"(NativeExecutableSpec) { |
| targetBuildTypes 'debug' |
| sources { |
| cpp { |
| source { |
| srcDirs 'src/dev/native/cpp' |
| include '**/*.cpp' |
| lib library: 'wpilibc' |
| } |
| exportedHeaders { |
| srcDirs 'src/dev/native/include' |
| } |
| } |
| } |
| binaries.all { |
| lib project: ':ntcore', library: 'ntcore', linkage: 'shared' |
| lib project: ':cscore', library: 'cscore', linkage: 'shared' |
| project(':hal').addHalDependency(it, 'shared') |
| lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
| lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| } |
| } |
| } |
| testSuites { |
| "${nativeName}Test"(GoogleTestTestSuiteSpec) { |
| for(NativeComponentSpec c : $.components) { |
| if (c.name == nativeName) { |
| testing c |
| break |
| } |
| } |
| sources { |
| cpp { |
| source { |
| srcDirs 'src/test/native/cpp' |
| include '**/*.cpp' |
| } |
| exportedHeaders { |
| srcDirs 'src/test/native/include', 'src/main/native/cpp' |
| } |
| } |
| c { |
| source { |
| srcDirs 'src/test/native/c' |
| include '**/*.c' |
| } |
| exportedHeaders { |
| srcDirs 'src/test/native/include', 'src/main/native/c' |
| } |
| } |
| } |
| } |
| } |
| binaries { |
| all { |
| tasks.withType(CppCompile) { |
| dependsOn generateCppVersion |
| } |
| } |
| withType(GoogleTestTestSuiteBinarySpec) { |
| if (!project.hasProperty('onlyAthena') && !project.hasProperty('onlyRaspbian')) { |
| lib project: ':ntcore', library: 'ntcore', linkage: 'shared' |
| lib project: ':cscore', library: 'cscore', linkage: 'shared' |
| project(':hal').addHalDependency(it, 'shared') |
| lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared' |
| lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared' |
| lib library: nativeName, linkage: 'shared' |
| } else { |
| it.buildable = false |
| } |
| } |
| } |
| tasks { |
| def c = $.components |
| project.tasks.create('runCpp', Exec) { |
| def found = false |
| c.each { |
| if (it in NativeExecutableSpec && it.name == "${nativeName}Dev") { |
| it.binaries.each { |
| if (!found) { |
| def arch = it.targetPlatform.architecture.name |
| if (arch == 'x86-64' || arch == 'x86') { |
| dependsOn it.tasks.install |
| |
| found = true |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| tasks.withType(RunTestExecutable) { |
| args "--gtest_output=xml:test_detail.xml" |
| outputs.dir outputDir |
| } |
| |
| apply from: 'publish.gradle' |
| |
| def oldWpilibVersionFile = file('src/main/native/cpp/WPILibVersion.cpp') |
| |
| clean { |
| delete oldWpilibVersionFile |
| } |