mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
251 lines
7.6 KiB
Groovy
251 lines
7.6 KiB
Groovy
import edu.wpi.first.nativeutils.NativeUtils
|
|
import org.gradle.api.file.FileCollection
|
|
import org.gradle.internal.os.OperatingSystem
|
|
import edu.wpi.first.nativeutils.tasks.JNIHeaders
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenLocal()
|
|
maven {
|
|
url "https://plugins.gradle.org/m2/"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath 'gradle.plugin.edu.wpi.first:native-utils:1.3.0'
|
|
classpath 'gradle.plugin.edu.wpi.first.wpilib.versioning:wpilib-version-plugin:2.0'
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
ext.getClassifier = { binary->
|
|
return NativeUtils.getClassifier(binary)
|
|
}
|
|
|
|
ext.getPlatformPath = { binary->
|
|
return NativeUtils.getPlatformPath(binary)
|
|
}
|
|
|
|
ext.getJNIHeadersClass = {
|
|
return JNIHeaders
|
|
}
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'google-test'
|
|
apply plugin: 'visual-studio'
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
apply plugin: 'java'
|
|
|
|
apply from: 'config.gradle'
|
|
|
|
if (project.hasProperty('onlyAthena')) {
|
|
test.enabled = false
|
|
}
|
|
|
|
sourceSets {
|
|
dev
|
|
}
|
|
|
|
task nativeTestFilesJar(type: Jar) {
|
|
destinationDir = project.buildDir
|
|
classifier = "nativeTestFiles"
|
|
|
|
project.model {
|
|
binaries {
|
|
withType(SharedLibraryBinarySpec) { binary ->
|
|
if (binary.component.name == 'ntcoreJNI') {
|
|
from(binary.sharedLibraryFile) {
|
|
into NativeUtils.getPlatformPath(binary)
|
|
}
|
|
dependsOn binary.buildTask
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task run(type: JavaExec) {
|
|
classpath = sourceSets.dev.runtimeClasspath
|
|
|
|
main = 'edu.wpi.first.ntcore.DevMain'
|
|
}
|
|
|
|
test.dependsOn nativeTestFilesJar
|
|
run.dependsOn nativeTestFilesJar
|
|
build.dependsOn devClasses
|
|
|
|
|
|
dependencies {
|
|
compile 'edu.wpi.first.wpiutil:wpiutil-java:3.+'
|
|
testCompile 'junit:junit:4.12'
|
|
testRuntime files(project(':').nativeTestFilesJar.archivePath)
|
|
devCompile 'edu.wpi.first.wpiutil:wpiutil-java:3.+'
|
|
devCompile sourceSets.main.output
|
|
devRuntime files(project(':').nativeTestFilesJar.archivePath)
|
|
}
|
|
|
|
|
|
model {
|
|
jniConfigs {
|
|
ntcore(JNIConfig) {
|
|
jniDefinitionClasses = [ "edu.wpi.first.networktables.NetworkTablesJNI" ]
|
|
jniArmHeaderLocations = [ all: file("${rootDir}/src/arm-linux-jni") ]
|
|
sourceSets = [ project.sourceSets.main ]
|
|
}
|
|
ntcoreJNI(JNIConfig) {
|
|
jniDefinitionClasses = [ "edu.wpi.first.networktables.NetworkTablesJNI" ]
|
|
jniArmHeaderLocations = [ all: file("${rootDir}/src/arm-linux-jni") ]
|
|
sourceSets = [ project.sourceSets.main ]
|
|
}
|
|
}
|
|
exportsConfigs {
|
|
ntcore(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' ]
|
|
}
|
|
ntcoreJNI(ExportsConfig) {
|
|
x86SymbolFilter = { symbols->
|
|
def retList = []
|
|
symbols.each { symbol->
|
|
if (symbol.startsWith('NT_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
|
|
retList << symbol
|
|
}
|
|
}
|
|
return retList
|
|
}
|
|
x64SymbolFilter = { symbols->
|
|
def retList = []
|
|
symbols.each { symbol->
|
|
if (symbol.startsWith('NT_') || symbol.startsWith('Java_') || symbol.startsWith('JNI_')) {
|
|
retList << symbol
|
|
}
|
|
}
|
|
return retList
|
|
}
|
|
}
|
|
}
|
|
dependencyConfigs {
|
|
wpiutil(DependencyConfig) {
|
|
groupId = 'edu.wpi.first.wpiutil'
|
|
artifactId = 'wpiutil-cpp'
|
|
headerClassifier = 'headers'
|
|
ext = 'zip'
|
|
version = '3.+'
|
|
sharedConfigs = [ ntcore: [],
|
|
ntcoreDev: [],
|
|
ntcoreTestingBaseTest: [] ]
|
|
staticConfigs = [ ntcoreJNI: [] ]
|
|
}
|
|
}
|
|
components {
|
|
ntcore(NativeLibrarySpec) {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ntcoreJNI(NativeLibrarySpec) {
|
|
baseName = 'ntcore'
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!project.hasProperty('skipTestExe')) {
|
|
ntcoreDev(NativeExecutableSpec) {
|
|
sources {
|
|
cpp {
|
|
lib library: "ntcore"
|
|
source {
|
|
srcDirs 'src/dev/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/dev/native/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ntcoreTestingBase(NativeLibrarySpec) { }
|
|
}
|
|
testSuites {
|
|
ntcoreTestingBaseTest {
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/test/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/test/native/include', 'src/main/native/cpp'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
binaries {
|
|
withType(StaticLibraryBinarySpec) {
|
|
if (it.component.name == 'ntcoreJNI') {
|
|
it.buildable = false
|
|
}
|
|
}
|
|
withType(GoogleTestTestSuiteBinarySpec) {
|
|
if (it.component.testedComponent.name.contains('TestingBase') && !project.hasProperty('onlyAthena')) {
|
|
lib project: ':gmock', library: 'gmock', linkage: 'static'
|
|
lib library: 'ntcore', 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 == 'ntcoreDev') {
|
|
it.binaries.each {
|
|
if (!found) {
|
|
def arch = it.targetPlatform.architecture.name
|
|
if (arch == 'x86-64' || arch == 'x86') {
|
|
dependsOn it.tasks.install
|
|
commandLine it.tasks.install.runScript
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
task wrapper(type: Wrapper) {
|
|
gradleVersion = '4.1'
|
|
}
|