mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
87 lines
3.2 KiB
Groovy
87 lines
3.2 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
import org.apache.tools.ant.filters.*;
|
|
|
|
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')
|
|
}
|
|
|
|
|
|
// Generate genlinks
|
|
exec {
|
|
workingDir "$rootDir/ni-libraries/lib"
|
|
if (OperatingSystem.current().isWindows()) {
|
|
commandLine "$rootDir/ni-libraries/lib/genlinks.bat"
|
|
} else {
|
|
executable "genlinks"
|
|
}
|
|
}
|
|
exec {
|
|
workingDir "$rootDir/ni-libraries/lib"
|
|
if (OperatingSystem.current().isWindows()) {
|
|
commandLine "$rootDir/ni-libraries/lib/genlinks.bat"
|
|
} else {
|
|
executable "genlinks"
|
|
}
|
|
}
|
|
exec {
|
|
workingDir "$rootDir/ni-libraries/lib"
|
|
if (OperatingSystem.current().isWindows()) {
|
|
commandLine "$rootDir/ni-libraries/lib/genlinks.bat"
|
|
} else {
|
|
executable "genlinks"
|
|
}
|
|
}
|
|
exec {
|
|
workingDir "$rootDir/ni-libraries/lib"
|
|
if (OperatingSystem.current().isWindows()) {
|
|
commandLine "$rootDir/ni-libraries/lib/genlinks.bat"
|
|
} else {
|
|
executable "genlinks"
|
|
}
|
|
}
|
|
exec {
|
|
workingDir "$rootDir/ni-libraries/lib"
|
|
if (OperatingSystem.current().isWindows()) {
|
|
commandLine "$rootDir/ni-libraries/lib/genlinks.bat"
|
|
} else {
|
|
executable "genlinks"
|
|
}
|
|
}
|
|
if (OperatingSystem.current().isWindows()) {
|
|
copy {
|
|
from "$rootDir/ni-libraries/lib/tmp"
|
|
into "$rootDir/ni-libraries/lib"
|
|
filter(FixCrLfFilter.class,
|
|
eol:FixCrLfFilter.CrLf.newInstance("lf"))
|
|
}
|
|
delete {
|
|
delete "$rootDir/ni-libraries/lib/tmp"
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|