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") task libZip(type: Zip) { destinationDir = outputsFolder baseName = 'nilibraries-classifier' classifier = "linuxathena" from('lib') { into '/linux/athena/shared/' } } task headersZip(type: Zip) { destinationDir = outputsFolder baseName = 'nilibraries-classifier' classifier = "headers" from('include') { into '/' } } task build() {} build.dependsOn headersZip build.dependsOn 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 ', '#include ') contents = contents.replaceAll('#include ', '#include ') 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" } } }