Adds gradle task to fix NI libraries whenever new ones are added. (#325)

Generates genlinks, and modifies headers to make them self contained
This commit is contained in:
Thad House
2016-11-04 15:17:17 -07:00
committed by Peter Johnson
parent 81212d80c6
commit 861726cefa
26 changed files with 155 additions and 44 deletions

View File

@@ -47,6 +47,8 @@ subprojects {
apply from: 'cppSettings.gradle'
apply from: 'ni-libraries/ni-libraries.gradle'
task wrapper(type: Wrapper) {
gradleVersion = '3.0'
}

View File

@@ -24,11 +24,11 @@ model {
sources {
cpp {
source {
srcDirs = ["lib/athena", niLibraryHeadersChipObject, niLibraryHeadersRoot, "lib/shared"]
srcDirs = ["lib/athena", niLibraryHeadersRoot, "lib/shared"]
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["include", niLibraryHeadersChipObject, niLibraryHeadersRoot, wpiUtilInclude]
srcDirs = ["include", niLibraryHeadersRoot, wpiUtilInclude]
}
}
}
@@ -71,7 +71,7 @@ task halZip(type: Zip) {
def normalizedIt = it.toString().replace('/', '\\')
def normalizedWPIUtil = wpiUtilInclude.toString().replace('/', '\\')
// exclude the wpiUtil library, and any NI libraries (NI libraries grabbed later)
if (normalizedIt != normalizedWPIUtil && !it.toString().contains('ni-libraries') ) {
if (normalizedIt != normalizedWPIUtil) {
from(it) {
into 'include'
// We don't want to include any of the .cpp files that are in some of the header directories
@@ -89,17 +89,6 @@ task halZip(type: Zip) {
}
}
// Grab the NI headers excluding the ChipObject folder
from(project.file('../ni-libraries/include')) {
exclude 'FRC_FPGA_ChipObject/'
into 'include'
}
// Grab the ChipObject headers manually and put them in the right spot
from(project.file('../ni-libraries/include/FRC_FPGA_ChipObject')) {
into 'include'
}
// Finally, include all of the shared library objects from the ni directory
from(project.file('../ni-libraries/lib')) {
into 'lib'

View File

@@ -10,12 +10,6 @@
#pragma GCC diagnostic ignored "-Wpedantic"
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#include "FRC_FPGA_ChipObject/tDMAChannelDescriptor.h" // NOLINT
#include "FRC_FPGA_ChipObject/tDMAManager.h" // NOLINT
#include "FRC_FPGA_ChipObject/tInterruptManager.h" // NOLINT
#include "FRC_FPGA_ChipObject/tSystem.h" // NOLINT
#include "FRC_FPGA_ChipObject/tSystemInterface.h" // NOLINT
#include <stdint.h>
#include "FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h"
@@ -38,6 +32,11 @@
#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h"
#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSPI.h"
#include "FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tSysWatchdog.h"
#include "FRC_FPGA_ChipObject/tDMAChannelDescriptor.h"
#include "FRC_FPGA_ChipObject/tDMAManager.h"
#include "FRC_FPGA_ChipObject/tInterruptManager.h"
#include "FRC_FPGA_ChipObject/tSystem.h"
#include "FRC_FPGA_ChipObject/tSystemInterface.h"
namespace hal {
using namespace nFPGA;

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_AI_h__
#define __nFRC_2017_17_0_2_AI_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_AO_h__
#define __nFRC_2017_17_0_2_AO_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Accel_h__
#define __nFRC_2017_17_0_2_Accel_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Accumulator_h__
#define __nFRC_2017_17_0_2_Accumulator_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Alarm_h__
#define __nFRC_2017_17_0_2_Alarm_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_AnalogTrigger_h__
#define __nFRC_2017_17_0_2_AnalogTrigger_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_BIST_h__
#define __nFRC_2017_17_0_2_BIST_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Counter_h__
#define __nFRC_2017_17_0_2_Counter_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_DIO_h__
#define __nFRC_2017_17_0_2_DIO_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_DMA_h__
#define __nFRC_2017_17_0_2_DMA_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Encoder_h__
#define __nFRC_2017_17_0_2_Encoder_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Global_h__
#define __nFRC_2017_17_0_2_Global_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Interrupt_h__
#define __nFRC_2017_17_0_2_Interrupt_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_PWM_h__
#define __nFRC_2017_17_0_2_PWM_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Power_h__
#define __nFRC_2017_17_0_2_Power_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_Relay_h__
#define __nFRC_2017_17_0_2_Relay_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_SPI_h__
#define __nFRC_2017_17_0_2_SPI_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -4,7 +4,8 @@
#ifndef __nFRC_2017_17_0_2_SysWatchdog_h__
#define __nFRC_2017_17_0_2_SysWatchdog_h__
#include "tSystemInterface.h"
#include "../tSystem.h"
#include "../tSystemInterface.h"
namespace nFPGA
{

View File

@@ -14,8 +14,8 @@
#ifndef __FRC_COMM_H__
#define __FRC_COMM_H__
#ifdef WIN32
# include <vxWorks_compat.h>
#ifdef _WIN32
# include <windows.h>
#ifdef USE_THRIFT
# define EXPORT_FUNC
# else
@@ -33,7 +33,7 @@
#define ERR_FRCSystem_NetCommNotResponding -44049
#define ERR_FRCSystem_NoDSConnection -44018
#ifdef WIN32
#ifdef _WIN32
# define __DEPRECATED__ __declspec(deprecated)
#else
# define __DEPRECATED__ __attribute__((__deprecated__))
@@ -129,7 +129,7 @@ extern "C" {
int EXPORT_FUNC FRC_NetworkCommunication_sendError(int isError, int32_t errorCode, int isLVCode,
const char *details, const char *location, const char *callStack);
#ifdef WIN32
#ifdef _WIN32
void EXPORT_FUNC setNewDataSem(HANDLE);
#elif defined (__vxworks)
void EXPORT_FUNC setNewDataSem(SEM_ID);

View File

@@ -2,7 +2,7 @@
#ifndef __LoadOut_h__
#define __LoadOut_h__
#ifdef WIN32
#ifdef _WIN32
#include <vxWorks_compat.h>
#define EXPORT_FUNC __declspec(dllexport) __cdecl
#elif defined (__vxworks)

View File

@@ -2,7 +2,7 @@
#ifndef __UsageReporting_h__
#define __UsageReporting_h__
#ifdef WIN32
#ifdef _WIN32
#include <stdint.h>
#define EXPORT_FUNC __declspec(dllexport) __cdecl
#elif defined (__vxworks)

View File

@@ -0,0 +1,24 @@
@echo off
setlocal enabledelayedexpansion
mkdir tmp
for %%F in (lib*.so.*) do IF /i "%%~xF" NEQ ".so" (
set libout=%%~nF
del !libout!
echo OUTPUT_FORMAT^(elf32-littlearm^)> tmp\!libout!
echo GROUP ^( %%F ^)>> tmp\!libout!
)
REM Do a second round from the temp folder
cd tmp
for %%F in (lib*.so.*) do IF /i "%%~xF" NEQ ".so" (
set libout=%%~nF
del !libout!
echo OUTPUT_FORMAT^(elf32-littlearm^)> !libout!
echo GROUP ^( %%F ^)>> !libout!
)
cd ..

View File

@@ -0,0 +1,79 @@
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\"\r\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"
}
}
}
}