Files
allwpilib/ntcore.gradle
Thad House 5df78c520c Adds support for building separate armhf artifacts (#177)
Currently if using a separate compiler prefix, it would still get published
to the arm classifier. This modifies so a classifier suffix can be used to
disambiguate arm from armhf.
2017-01-03 19:12:47 -08:00

174 lines
5.3 KiB
Groovy

def ntcoreSetupModel = { project ->
project.model {
components {
ntcore(NativeLibrarySpec) {
if (project.isArm) {
targetPlatform 'arm'
} else {
targetPlatform 'x86'
targetPlatform 'x64'
}
setupDefines(project, binaries)
if (includeJava) {
project.setupJniIncludes(binaries)
project.checkNativeSymbols(project.getNativeJNISymbols)
binaries.all {
project.setupDef(linker, "${rootDir}/ntcore-jni.def")
}
} else {
binaries.all {
project.setupDef(linker, "${rootDir}/ntcore.def")
}
}
sources {
cpp {
source {
srcDirs = ["${rootDir}/src"]
if (includeJava) {
srcDirs "${rootDir}/java/lib"
}
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${rootDir}/include"]
if (includeJava) {
project.jniHeadersNetworkTables.outputs.files.each { file ->
srcDirs file.getPath()
}
}
includes = ['**/*.h']
}
if (project.isArm && project.hasProperty('compilerPrefix')) {
lib project: ':arm:wpiutil', library: 'wpiutil', linkage: 'static'
} else if (project.isArm) {
// If roboRIO, link shared
lib project: ':arm:wpiutil', library: 'wpiutil', linkage: 'shared'
} else {
lib project: ':native:wpiutil', library: 'wpiutil', linkage: 'static'
}
}
}
}
}
}
}
def ntcoreZipTask = { project ->
project.ext.ntcoreZip = project.tasks.create("ntcoreZip", Zip) {
description = 'Creates platform-specific zip of the desktop ntcore libraries.'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
if (project.isArm && project.hasProperty('compilerPrefix')
&& project.hasProperty('armSuffix')) {
classifier = "${project.buildPlatform}${project.armSuffix}"
} else {
classifier = "${project.buildPlatform}"
}
duplicatesStrategy = 'exclude'
from(file('include')) {
into 'include'
}
if (!project.hasProperty('skipJava')) {
project.jniHeadersNetworkTables.outputs.each {
from(it) {
into 'include'
}
}
}
project.model {
binaries {
withType(StaticLibraryBinarySpec) { binary ->
from(binary.staticLibraryFile) {
into getPlatformPath(binary)
}
}
withType(SharedLibraryBinarySpec) { binary ->
from(binary.sharedLibraryFile) {
into getPlatformPath(binary)
}
from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into getPlatformPath(binary)
}
}
}
}
}
project.build.dependsOn project.ntcoreZip
project.debugStripSetup()
project.tasks.whenTaskAdded { task ->
def name = task.name.toLowerCase()
if (name.contains("ntcoresharedlibrary") || name.contains("ntcorestaticlibrary") || name.contains("ntcoretest")) {
project.ntcoreZip.dependsOn task
}
}
}
if (buildArm) {
project(':arm:ntcore') {
apply plugin: 'cpp'
apply from: "${rootDir}/toolchains/arm.gradle"
if (includeJava) {
apply from: "${rootDir}/java/java.gradle"
}
ntcoreSetupModel(project)
ntcoreZipTask(project)
}
}
project(':native:ntcore') {
apply plugin: 'cpp'
apply from: "${rootDir}/toolchains/native.gradle"
if (!project.hasProperty("withoutTests")) {
apply from: "${rootDir}/test/tests.gradle"
}
if (includeJava) {
apply from: "${rootDir}/java/java.gradle"
}
ntcoreSetupModel(project)
ntcoreZipTask(project)
}
task ntcoreSourceZip(type: Zip) {
description = 'Creates a sources-zip of the ntcore source files'
group = 'WPILib'
destinationDir = project.buildDir
baseName = 'ntcore'
classifier = "sources"
duplicatesStrategy = 'exclude'
from('src') {
into 'src'
}
from('include') {
into 'include'
}
if (includeJava) {
from('java/lib') {
into 'src'
}
project(':native:ntcore').jniHeadersNetworkTables.outputs.each {
from(it) {
into 'include'
}
}
}
}