Add wpiutil dependency. (#190)

This commit is contained in:
Peter Johnson
2016-09-25 16:47:49 -07:00
committed by GitHub
parent 35d51d68f7
commit 107a4cc1e2
5 changed files with 60 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ armConfig.setTransitive(false)
def armNetTables = armConfig.files[0].canonicalFile
def desktopNetTables
if (project.hasProperty('makeSim')){
if (project.hasProperty('makeSim')) {
def desktopNtDependency =
project.dependencies.create("edu.wpi.first.wpilib.networktables.cpp:NetworkTables:3.0.0-SNAPSHOT:desktop@zip")
def desktopConfig = project.configurations.detachedConfiguration(desktopNtDependency)
@@ -40,13 +40,41 @@ def netTablesUnzipLocation = "$buildDir/networktables"
task unzipNetworkTables(type: Copy) {
description = 'Unzips the networktables maven dependency so that the include files and libraries can be used'
group = 'WPILib'
if (project.hasProperty('makeSim')){
if (project.hasProperty('makeSim')) {
from zipTree(desktopNetTables)
}
from zipTree(armNetTables)
into netTablesUnzipLocation
}
def armWpiUtilDependency =
project.dependencies.create("edu.wpi.first.wpilib:wpiutil:1.0.0-SNAPSHOT:arm@zip")
def armWpiUtilConfig = project.configurations.detachedConfiguration(armWpiUtilDependency)
armWpiUtilConfig.setTransitive(false)
def armWpiUtil = armWpiUtilConfig.files[0].canonicalFile
def desktopWpiUtil
if (project.hasProperty('makeSim')) {
def desktopWpiUtilDependency =
project.dependencies.create("edu.wpi.first.wpilib:wpiutil:1.0.0-SNAPSHOT:desktop@zip")
def desktopWpiUtilConfig = project.configurations.detachedConfiguration(desktopWpiUtilDependency)
desktopWpiUtilConfig.setTransitive(false)
desktopWpiUtil = desktopWpiUtilConfig.files[0].canonicalFile
}
def wpiUtilUnzipLocation = "$buildDir/wpiutil"
// Create a task that will unzip the wpiutil files into a temporary build directory
task unzipWpiUtil(type: Copy) {
description = 'Unzips the wpiutil maven dependency so that the include files and libraries can be used'
group = 'WPILib'
if (project.hasProperty('makeSim')) {
from zipTree(desktopWpiUtil)
}
from zipTree(armWpiUtil)
into wpiUtilUnzipLocation
}
task clean(type: Delete) {
description = "Deletes the build directory"
group = "Build"
@@ -55,6 +83,24 @@ task clean(type: Delete) {
subprojects {
plugins.withType(CppPlugin).whenPluginAdded {
ext.defineWpiUtilProperties = {
ext.wpiUtil = wpiUtilUnzipLocation
ext.wpiUtilInclude = "$wpiUtilUnzipLocation/include"
ext.wpiUtilLibArmLocation = "$wpiUtilUnzipLocation/Linux/arm"
if (project.hasProperty('makeSim')) {
ext.wpiUtilLibDesktopLocation = "$wpiUtilUnzipLocation/Linux/amd64"
}
ext.wpiUtilStaticLib = "$wpiUtilLibArmLocation/libwpiutil.a"
ext.addWpiUtilLibraryLinks = { compileTask, linker, targetPlatform ->
compileTask.dependsOn project(':').unzipWpiUtil
String architecture = targetPlatform.architecture
if (architecture.contains('arm')) {
linker.args wpiUtilStaticLib
}
}
}
// This defines a project property that projects depending on network tables can use to setup that dependency.
ext.defineNetworkTablesProperties = {
ext.netTables = netTablesUnzipLocation
@@ -72,6 +118,7 @@ subprojects {
if (architecture.contains('arm')) {
linker.args netStaticLib
}
addWpiUtilLibraryLinks(compileTask, linker, targetPlatform)
}
}

View File

@@ -1,3 +1,3 @@
/* GNU ld script */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( AS_NEEDED ( -lwpilib_nonshared -lHALAthena -lntcore -lFRC_NetworkCommunication -li2c -lni_emb -lNiFpgaLv -lNiFpga -lnirio_emb_can -lNiRioSrv -lni_rtlog -lRoboRIO_FRC_ChipObject -lspi -lvisa -ldl -lpthread -lrt -lGCBase_gcc-4.4-arm_v2_3 -lGenApi_gcc-4.4-arm_v2_3 -lLog_gcc-4.4-arm_v2_3 -lMathParser_gcc-4.4-arm_v2_3 -llog4cpp_gcc-4.4-arm_v2_3 -lniimaqdx -lnivision -lnivissvc -lnipalu) )
GROUP ( AS_NEEDED ( -lwpilib_nonshared -lHALAthena -lntcore -lwpiutil -lFRC_NetworkCommunication -li2c -lni_emb -lNiFpgaLv -lNiFpga -lnirio_emb_can -lNiRioSrv -lni_rtlog -lRoboRIO_FRC_ChipObject -lspi -lvisa -ldl -lpthread -lrt -lGCBase_gcc-4.4-arm_v2_3 -lGenApi_gcc-4.4-arm_v2_3 -lLog_gcc-4.4-arm_v2_3 -lMathParser_gcc-4.4-arm_v2_3 -llog4cpp_gcc-4.4-arm_v2_3 -lniimaqdx -lnivision -lnivissvc -lnipalu) )

View File

@@ -1,4 +1,5 @@
defineNetworkTablesProperties()
defineWpiUtilProperties()
def ntSourceDir = "$buildDir/ntSources"
@@ -19,7 +20,7 @@ model {
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ["${project.shared}/include", "${project.athena}/include", netTablesInclude]
srcDirs = ["${project.shared}/include", "${project.athena}/include", netTablesInclude, wpiUtilInclude]
includes = ['**/*.h']
}
lib project: ':hal', library: 'HALAthena', linkage: 'static'
@@ -83,6 +84,9 @@ task wpilibcZip(type: Zip) {
from(netStaticLib) {
into 'lib'
}
from(wpiUtilStaticLib) {
into 'lib'
}
// We rename the libHALAthena.so object to libHALAthena_shared.so, and the same for libntcore.so
rename('(libHALAthena)(.so)', '$1_shared$2')

View File

@@ -76,6 +76,10 @@ task wpilibcSimCopy(type: Copy, dependsOn: allcsim) {
into "include"
}
from ("$wpiUtilInclude"){
into "include"
}
from ("../hal/include"){
into "include"
}

View File

@@ -1,6 +1,7 @@
apply plugin: 'cpp'
defineNetworkTablesProperties()
defineWpiUtilProperties()
ext.shared = "${project(':wpilibc').projectDir.getAbsolutePath()}/shared"
ext.athena = "${project(':wpilibc').projectDir.getAbsolutePath()}/athena"