2015-09-24 23:32:55 -04:00
|
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
|
|
|
|
|
|
apply plugin: 'java'
|
|
|
|
|
|
|
|
|
|
def generatedJNIHeaderLoc = 'build/include'
|
|
|
|
|
|
|
|
|
|
sourceSets {
|
|
|
|
|
main {
|
|
|
|
|
java {
|
|
|
|
|
srcDirs = ['java/src']
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jar {
|
|
|
|
|
description = 'Generates NetworkTables jar, with the JNI shared libraries embedded'
|
2015-10-31 14:27:38 -04:00
|
|
|
baseName = 'ntcore'
|
2015-09-24 23:32:55 -04:00
|
|
|
|
|
|
|
|
if (buildPlatform == 'arm') {
|
|
|
|
|
dependsOn { ntcoreSharedLibrary }
|
|
|
|
|
} else {
|
|
|
|
|
dependsOn { x64NtcoreSharedLibrary }
|
|
|
|
|
dependsOn { x86NtcoreSharedLibrary }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dependsOn { classes }
|
|
|
|
|
binaries.withType(SharedLibraryBinary) { binary ->
|
|
|
|
|
from(file(binary.sharedLibraryFile)) {
|
|
|
|
|
into getPlatformPath(binary)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task networktablesJavaSource(type: Jar, dependsOn: classes) {
|
|
|
|
|
description = 'Generates the source jar for NetworkTables java'
|
|
|
|
|
group = 'WPILib'
|
|
|
|
|
classifier = 'source'
|
|
|
|
|
from sourceSets.main.allJava
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
task networktablesJavadoc(type: Jar, dependsOn: javadoc) {
|
|
|
|
|
description = 'Generates the javadoc jar for NetworkTables java'
|
|
|
|
|
group = 'WPILib'
|
|
|
|
|
classifier = 'javadoc'
|
|
|
|
|
from javadoc.destinationDir
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates the JNI headers
|
|
|
|
|
*/
|
|
|
|
|
task jniHeadersNetworkTables {
|
|
|
|
|
description = 'Generates JNI headers from edu.wpi.first.wpilibj.networktables.*'
|
|
|
|
|
group = 'WPILib'
|
|
|
|
|
def outputFolder = file(generatedJNIHeaderLoc)
|
|
|
|
|
inputs.files sourceSets.main.output
|
|
|
|
|
outputs.file outputFolder
|
|
|
|
|
doLast {
|
|
|
|
|
outputFolder.mkdirs()
|
|
|
|
|
exec {
|
|
|
|
|
executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah')
|
|
|
|
|
args '-d', outputFolder
|
|
|
|
|
args '-classpath', sourceSets.main.output.classesDir
|
|
|
|
|
args 'edu.wpi.first.wpilibj.networktables.NetworkTablesJNI'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clean {
|
|
|
|
|
delete generatedJNIHeaderLoc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compileJava {
|
|
|
|
|
options.compilerArgs << '-Xlint:unchecked'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
javadoc {
|
|
|
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This creates a lambda that the main build.gradle can access, which sets up the JNI includes for the
|
|
|
|
|
// target build platform. This lambda is exposed as a property in the main build.gradle.
|
|
|
|
|
ext.setupJniIncludes = { binaries ->
|
|
|
|
|
def platformSpecificIncludeFlag = { loc, cppCompiler ->
|
|
|
|
|
if (OperatingSystem.current().isWindows()) {
|
|
|
|
|
cppCompiler.args "/I$loc"
|
|
|
|
|
} else {
|
|
|
|
|
cppCompiler.args '-I', loc
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
binaries.all {
|
|
|
|
|
tasks.withType(CppCompile) {
|
|
|
|
|
if (buildPlatform == 'arm') {
|
|
|
|
|
cppCompiler.args '-I', file('java/arm-linux').absolutePath
|
|
|
|
|
cppCompiler.args '-I', file('java/arm-linux/linux').absolutePath
|
|
|
|
|
} else {
|
|
|
|
|
def jdkLocation = org.gradle.internal.jvm.Jvm.current().javaHome
|
|
|
|
|
platformSpecificIncludeFlag("${jdkLocation}/include", cppCompiler)
|
|
|
|
|
|
2015-10-31 18:46:49 -04:00
|
|
|
if (targetPlatform.operatingSystem.linux) {
|
2015-09-24 23:32:55 -04:00
|
|
|
platformSpecificIncludeFlag("${jdkLocation}/include/linux", cppCompiler)
|
|
|
|
|
} else if (targetPlatform.operatingSystem.windows) {
|
|
|
|
|
platformSpecificIncludeFlag("${jdkLocation}/include/win32", cppCompiler)
|
|
|
|
|
} else if (targetPlatform.operatingSystem.freeBSD) {
|
|
|
|
|
platformSpecificIncludeFlag("${jdkLocation}/include/freebsd", cppCompiler)
|
2015-10-31 18:46:49 -04:00
|
|
|
} else if (file("$jdkLocation/include/darwin").exists()) {
|
|
|
|
|
// TODO: As of Gradle 2.8, targetPlatform.operatingSystem.macOsX returns false
|
|
|
|
|
// on El Capitan. We therefore manually test for the darwin folder and include it
|
|
|
|
|
// if it exists
|
|
|
|
|
platformSpecificIncludeFlag("${jdkLocation}/include/darwin", cppCompiler)
|
2015-09-24 23:32:55 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jniHeadersNetworkTables.outputs.files.each { file ->
|
|
|
|
|
if (buildPlatform == 'arm') {
|
|
|
|
|
cppCompiler.args '-I', file.getPath()
|
|
|
|
|
} else {
|
|
|
|
|
platformSpecificIncludeFlag(file.getPath(), cppCompiler)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dependsOn jniHeadersNetworkTables
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|