mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
146 lines
3.8 KiB
Groovy
146 lines
3.8 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
plugins {
|
|
id 'c'
|
|
id 'cpp'
|
|
id 'maven-publish'
|
|
}
|
|
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
|
|
apply from: '../shared/config.gradle'
|
|
|
|
def symbolFile = project.file("src/main/native/symbols.txt")
|
|
|
|
nativeUtils {
|
|
privateExportsConfigs {
|
|
ntcoreffi {
|
|
exportsFile = symbolFile
|
|
performStripAllSymbols = true
|
|
}
|
|
}
|
|
}
|
|
|
|
def generatedHeaders = file("$buildDir/generated/headers")
|
|
def generatedFile = file("$buildDir/generated/headers/ExportedSymbols.h")
|
|
|
|
def generateSymbols = tasks.register('generateFfiSymbols') {
|
|
inputs.file(symbolFile)
|
|
outputs.file(generatedFile)
|
|
|
|
doLast {
|
|
def symbolText = symbolFile as String[]
|
|
symbolText = symbolText.collect {
|
|
"AddFunctionToLink(${it});"
|
|
}.join('\n')
|
|
symbolText += '\n'
|
|
generatedFile.text = symbolText
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
ntcoreffi(NativeLibrarySpec) {
|
|
sources {
|
|
c {
|
|
source {
|
|
srcDirs = ['src/main/native/c']
|
|
includes = ['**/*.c']
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
srcDir generatedHeaders
|
|
}
|
|
}
|
|
cpp {
|
|
source {
|
|
srcDirs = ['src/main/native/cpp']
|
|
includes = ['**/*.cpp']
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
srcDir generatedHeaders
|
|
}
|
|
}
|
|
}
|
|
binaries.all { binary ->
|
|
if (binary instanceof StaticLibraryBinarySpec) {
|
|
binary.buildable = false
|
|
return
|
|
}
|
|
binary.tasks.withType(AbstractNativeSourceCompileTask) {
|
|
it.dependsOn generateSymbols
|
|
}
|
|
project(':ntcore').addNtcoreDependency(binary, 'static')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def nativeName = 'ntcoreffi'
|
|
def baseArtifactId = nativeName
|
|
def artifactGroupId = "edu.wpi.first.${nativeName}"
|
|
def zipBaseName = "_GROUP_edu_wpi_first_${nativeName}_ID_${nativeName}-cpp_CLS"
|
|
def outputsFolder = file("$project.buildDir/outputs")
|
|
|
|
evaluationDependsOn(':ntcore')
|
|
evaluationDependsOn(':wpiutil')
|
|
|
|
def cppProjectZips = []
|
|
cppProjectZips.add(project(':ntcore').cppHeadersZip)
|
|
cppProjectZips.add(project(':wpiutil').cppHeadersZip)
|
|
|
|
task cppHeadersZip(type: Zip) {
|
|
destinationDirectory = outputsFolder
|
|
archiveBaseName = zipBaseName
|
|
archiveClassifier = "headers"
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
ext.includeDirs = [
|
|
project.file('src/main/native/include'),
|
|
]
|
|
|
|
ext.includeDirs.each {
|
|
from(it) {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
cppProjectZips.each {
|
|
dependsOn it
|
|
from zipTree(it.archiveFile)
|
|
}
|
|
}
|
|
|
|
if (OperatingSystem.current().isWindows() && !project.hasProperty('ntcoreffibuild')) {
|
|
return
|
|
}
|
|
|
|
build.dependsOn cppHeadersZip
|
|
addTaskToCopyAllOutputs(cppHeadersZip)
|
|
|
|
model {
|
|
publishing {
|
|
def taskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat)
|
|
|
|
publications {
|
|
cpp(MavenPublication) {
|
|
taskList.each {
|
|
artifact it
|
|
}
|
|
artifact cppHeadersZip
|
|
|
|
artifactId = "${baseArtifactId}-cpp"
|
|
groupId = artifactGroupId
|
|
version = wpilibVersioning.version.get()
|
|
}
|
|
}
|
|
}
|
|
}
|