mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
112 lines
3.3 KiB
Groovy
112 lines
3.3 KiB
Groovy
import edu.wpi.first.nativeutils.*
|
|
import org.gradle.internal.os.OperatingSystem
|
|
import org.apache.tools.ant.filters.*;
|
|
|
|
public class NiDependencySet implements NativeDependencySet {
|
|
private Project m_project
|
|
|
|
public NiDependencySet(Project project) {
|
|
m_project = project
|
|
}
|
|
|
|
public FileCollection getIncludeRoots() {
|
|
return m_project.files("${m_project.projectDir}/include")
|
|
}
|
|
|
|
private FileCollection getFiles() {
|
|
def f = m_project.fileTree("${m_project.projectDir}/lib").filter { it.isFile() }
|
|
return f
|
|
}
|
|
|
|
public FileCollection getLinkFiles() {
|
|
return getFiles()
|
|
}
|
|
|
|
public FileCollection getRuntimeFiles() {
|
|
return m_project.files()
|
|
}
|
|
}
|
|
|
|
ext.addNiLibrariesToLinker = { binary ->
|
|
if (binary.targetPlatform.architecture.name == 'athena') {
|
|
binary.lib(new NiDependencySet(project))
|
|
}
|
|
}
|
|
|
|
def outputsFolder = file("$project.buildDir/outputs")
|
|
|
|
def niLibBaseName = '_GROUP_edu_wpi_first_ni-libraries_ID_ni-libraries_CLS'
|
|
|
|
task libZip(type: Zip) {
|
|
destinationDir = outputsFolder
|
|
baseName = niLibBaseName
|
|
classifier = "linuxathena"
|
|
|
|
from('lib') {
|
|
into '/linux/athena/shared/'
|
|
}
|
|
}
|
|
|
|
task headersZip(type: Zip) {
|
|
destinationDir = outputsFolder
|
|
baseName = niLibBaseName
|
|
classifier = "headers"
|
|
|
|
from('include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
task build() {}
|
|
|
|
build.dependsOn headersZip
|
|
build.dependsOn libZip
|
|
|
|
addTaskToCopyAllOutputs(headersZip)
|
|
addTaskToCopyAllOutputs(libZip)
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
task patchNiLibraries() {
|
|
doLast {
|
|
// Patch ChipObject headers to be self contained
|
|
FileTree chipTree = fileTree(dir: "$rootDir/ni-libraries/include/FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace")
|
|
chipTree.each { File file ->
|
|
String contents = file.getText('UTF-8')
|
|
contents = contents.replaceAll('#include \"tSystemInterface.h\"', '#include \"../tSystem.h\"\n#include \"../tSystemInterface.h\"')
|
|
file.write(contents, 'UTF-8')
|
|
}
|
|
|
|
// Patch NetComm headers to work on Windows
|
|
FileTree netTree = fileTree(dir: "$rootDir/ni-libraries/include/FRC_NetworkCommunication")
|
|
netTree.each { File file ->
|
|
String contents = file.getText('UTF-8')
|
|
contents = contents.replaceAll('#ifdef WIN32', '#ifdef _WIN32')
|
|
contents = contents.replaceAll('# include <vxWorks_compat.h>', '#include <windows.h>')
|
|
contents = contents.replaceAll('#include <vxWorks_compat.h>', '#include <windows.h>')
|
|
file.write(contents, 'UTF-8')
|
|
}
|
|
|
|
FileTree allTree = fileTree(dir: "$rootDir/ni-libraries/include/")
|
|
allTree.each { File file ->
|
|
String contents = file.getText('UTF-8')
|
|
contents = contents.replaceAll('\r\n', '\n')
|
|
file.write(contents, 'UTF-8')
|
|
}
|
|
|
|
// Move UsageReporting header to the HAL, because it is necessary for our
|
|
// UsageReporting in WPILibC.
|
|
|
|
copy {
|
|
from("$rootDir/ni-libraries/include/FRC_NetworkCommunication") {
|
|
include 'UsageReporting.h'
|
|
}
|
|
into "$rootDir/hal/src/main/native/include/HAL"
|
|
}
|
|
|
|
delete {
|
|
delete "$rootDir/ni-libraries/include/FRC_NetworkCommunication/UsageReporting.h"
|
|
}
|
|
}
|
|
}
|