mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
80 lines
2.9 KiB
Groovy
80 lines
2.9 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>' )
|
|
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"
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|