From 107a4cc1e29f99d798b684d0939533da78b76fd6 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 25 Sep 2016 16:47:49 -0700 Subject: [PATCH] Add wpiutil dependency. (#190) --- cppSettings.gradle | 51 ++++++++++++++++++++++++++-- ni-libraries/libwpi_2015.so | 2 +- wpilibc/athena.gradle | 6 +++- wpilibc/simulation.gradle | 4 +++ wpilibcIntegrationTests/build.gradle | 1 + 5 files changed, 60 insertions(+), 4 deletions(-) diff --git a/cppSettings.gradle b/cppSettings.gradle index 3e2514cc8e..de082a3155 100644 --- a/cppSettings.gradle +++ b/cppSettings.gradle @@ -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) } } diff --git a/ni-libraries/libwpi_2015.so b/ni-libraries/libwpi_2015.so index dbde0b3a6d..a369b497fb 100644 --- a/ni-libraries/libwpi_2015.so +++ b/ni-libraries/libwpi_2015.so @@ -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) ) diff --git a/wpilibc/athena.gradle b/wpilibc/athena.gradle index 8b3e7a8047..9994f350f6 100644 --- a/wpilibc/athena.gradle +++ b/wpilibc/athena.gradle @@ -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') diff --git a/wpilibc/simulation.gradle b/wpilibc/simulation.gradle index c051f2af5c..e66016404f 100644 --- a/wpilibc/simulation.gradle +++ b/wpilibc/simulation.gradle @@ -76,6 +76,10 @@ task wpilibcSimCopy(type: Copy, dependsOn: allcsim) { into "include" } + from ("$wpiUtilInclude"){ + into "include" + } + from ("../hal/include"){ into "include" } diff --git a/wpilibcIntegrationTests/build.gradle b/wpilibcIntegrationTests/build.gradle index 6a9485b2fc..86799fdb4e 100644 --- a/wpilibcIntegrationTests/build.gradle +++ b/wpilibcIntegrationTests/build.gradle @@ -1,6 +1,7 @@ apply plugin: 'cpp' defineNetworkTablesProperties() +defineWpiUtilProperties() ext.shared = "${project(':wpilibc').projectDir.getAbsolutePath()}/shared" ext.athena = "${project(':wpilibc').projectDir.getAbsolutePath()}/athena"