Squashed 'third_party/Phoenix-frc-lib/' content from commit 666d176

Change-Id: Ibaca2fc8ffb1177e786576cc1e4cc9f7a8c98f13
git-subtree-dir: third_party/Phoenix-frc-lib
git-subtree-split: 666d176a08151793044ab74e0005f13d3732ed96
diff --git a/wpi-dependencies-2017.gradle b/wpi-dependencies-2017.gradle
new file mode 100644
index 0000000..f2b06d3
--- /dev/null
+++ b/wpi-dependencies-2017.gradle
@@ -0,0 +1,284 @@
+task downloadWpiUtil() {
+    description = 'Downloads the C++ ARM wpiutil maven dependency.'
+    group = 'WPILib'
+    def depFolder = "$buildDir/dependencies"
+    def utilZip = file("$depFolder/wpiutil.zip")
+    outputs.file(utilZip)
+    def armWpiUtil
+
+    doFirst {
+        def armWpiUtilDependency = project.dependencies.create("edu.wpi.first.wpilib:wpiutil:+:arm@zip")
+        def armWpiUtilConfig = project.configurations.detachedConfiguration(armWpiUtilDependency)
+        armWpiUtilConfig.setTransitive(false)
+        armWpiUtil = armWpiUtilConfig.files[0].canonicalFile
+    }
+
+    doLast {
+        copy {
+            from armWpiUtil
+            rename 'wpiutil(.+)', 'wpiutil.zip'
+            into depFolder
+        }
+    }
+}
+
+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'
+    dependsOn downloadWpiUtil
+
+    from zipTree(downloadWpiUtil.outputs.files.singleFile)
+    into wpiUtilUnzipLocation
+}
+
+ext.defineWpiUtilProperties = {
+    ext.wpiUtil = wpiUtilUnzipLocation
+    ext.wpiUtilInclude = "$wpiUtilUnzipLocation/include"
+    ext.wpiUtilLibArmLocation = "$wpiUtilUnzipLocation/Linux/arm"
+    ext.wpiUtilSharedLib = "$wpiUtilLibArmLocation/libwpiutil.so"
+    ext.wpiUtilSharedLibDebug = "$wpiUtilLibArmLocation/libwpiutil.so.debug"
+    ext.addWpiUtilLibraryLinks = { compileTask, linker, targetPlatform ->
+        compileTask.dependsOn project(':').unzipWpiUtil
+        String architecture = targetPlatform.architecture
+        if (architecture.contains('arm')) {
+            linker.args wpiUtilSharedLib
+        }
+    }
+}
+
+ext.NIInclude = "$buildDir/NI/include"
+
+def halUnzipLocation = "$buildDir/hal"
+
+task downloadHAL() {
+    description = 'Downloads the C++ ARM HAL maven dependency.'
+
+    group = 'WPILib'
+    def depFolder = "$buildDir/dependencies"
+    def libZip = file("$depFolder/hal.zip")
+    outputs.file(libZip)
+    def armHal
+    
+
+    doFirst {
+        def armHALDependency = project.dependencies.create("edu.wpi.first.wpilib:hal:+@zip")
+        def armHALConfig = project.configurations.detachedConfiguration(armHALDependency)
+        armHALConfig.setTransitive(false)
+        armHal = armHALConfig.files[0].canonicalFile
+    }
+
+    doLast {
+        copy {
+            from armHal
+            rename 'hal(.+)', 'hal.zip'
+            into depFolder
+        }
+    }
+}
+
+// Create a task that will unzip the hal files into a temporary build directory
+task unzipHAL(type: Copy) {
+    description = 'Unzips the hal maven dependency so that the include files and libraries can be used'
+    group = 'WPILib'
+    dependsOn downloadHAL
+    
+    from zipTree(downloadHAL.outputs.files.singleFile)
+    into halUnzipLocation
+}
+
+ext.defineHALProperties = {
+    ext.hal = halUnzipLocation
+    ext.halInclude = "$halUnzipLocation/include"
+    ext.halLocation = "$halUnzipLocation/lib"
+    ext.halSharedLib = "$halLocation/libHALAthena.so"
+  
+    ext.addHalLibraryLinks = { compileTask, linker, targetPlatform ->
+        compileTask.dependsOn project(':').unzipHAL
+        String architecture = targetPlatform.architecture
+        if (architecture.contains('arm')) {
+            // Grab all the shared libraries and link them
+            linker.args halSharedLib      
+            linker.args "$halLocation/libnilibraries.so"
+
+            def libraryPath = halLocation
+
+            linker.args << '-L' + libraryPath
+        }
+    }
+}
+
+task downloadNetworkTables() {
+    description = 'Downloads the C++ ARM NetworkTables maven dependency.'
+    group = 'WPILib'
+    def depFolder = "$buildDir/dependencies"
+    def ntZip = file("$depFolder/ntcore.zip")
+    outputs.file(ntZip)
+    def armNetTables
+
+    doFirst {
+        def armNtDependency = project.dependencies.create('edu.wpi.first.wpilib.networktables.cpp:NetworkTables:+:arm@zip')
+        def armConfig = project.configurations.detachedConfiguration(armNtDependency)
+        armConfig.setTransitive(false)
+        armNetTables = armConfig.files[0].canonicalFile
+    }
+
+    doLast {
+        copy {
+            from armNetTables
+            rename 'NetworkTables(.+)', 'ntcore.zip'
+            into depFolder
+        }
+    }
+}
+
+def netTablesUnzipLocation = "$buildDir/networktables"
+
+// Create a task that will unzip the networktables files into a temporary build directory
+task unzipNetworkTables(type: Copy) {
+    description = 'Unzips the networktables maven dependency so that the include files and libraries can be used'
+    group = 'WPILib'
+    dependsOn downloadNetworkTables
+
+    from zipTree(downloadNetworkTables.outputs.files.singleFile)
+    into netTablesUnzipLocation
+}
+
+// This defines a project property that projects depending on network tables can use to setup that dependency.
+ext.defineNetworkTablesProperties = {
+    ext.netTables = netTablesUnzipLocation
+    ext.netTablesInclude = "$netTablesUnzipLocation/include"
+    ext.netLibArmLocation = "$netTablesUnzipLocation/Linux/arm"
+    ext.netSharedLib = "$netLibArmLocation/libntcore.so"
+    ext.netSharedLibDebug = "$netLibArmLocation/libntcore.so.debug"
+
+    ext.addNetworkTablesLibraryLinks = { compileTask, linker, targetPlatform ->
+        compileTask.dependsOn project(':').unzipNetworkTables
+        String architecture = targetPlatform.architecture
+        if (architecture.contains('arm')) {
+            linker.args netSharedLib
+        }
+        addWpiUtilLibraryLinks(compileTask, linker, targetPlatform)
+    }
+}
+
+
+def wpilibUnzipLocation = "$buildDir/wpilib"
+
+task downloadWpilib() {
+    description = 'Downloads the C++ ARM wpilib maven dependency.'
+
+    group = 'WPILib'
+    def depFolder = "$buildDir/dependencies"
+    def libZip = file("$depFolder/athena-wpilibc.zip")
+    outputs.file(libZip)
+    def armWPILib
+    
+
+    doFirst {
+        def armWpiLibDependency = project.dependencies.create("edu.wpi.first.wpilibc:athena:+@zip")
+        def armWpiLibConfig = project.configurations.detachedConfiguration(armWpiLibDependency)
+        armWpiLibConfig.setTransitive(false)
+        armWPILib = armWpiLibConfig.files[0].canonicalFile
+    }
+
+    doLast {
+        copy {
+            from armWPILib
+            rename 'athena(.+)', 'athena-wpilibc.zip'
+            into depFolder
+        }
+    }
+}
+
+// Create a task that will unzip the wpilib files into a temporary build directory
+task unzipWpilib(type: Copy) {
+    description = 'Unzips the wpilib maven dependency so that the include files and libraries can be used'
+    group = 'WPILib'
+    dependsOn downloadWpilib
+    
+    from zipTree(downloadWpilib.outputs.files.singleFile)
+    into wpilibUnzipLocation
+}
+
+ext.defineWpiLibProperties = {
+    ext.wpilib = wpilibUnzipLocation
+    ext.wpilibInclude = "$wpilibUnzipLocation/include"
+    ext.wpilibLocation = "$wpilibUnzipLocation/lib"
+    ext.wpilibSharedLib = "$wpilibLocation/libwpilibc.so"
+    
+    ext.addWpilibLibraryLinks = { compileTask, linker, targetPlatform ->
+        compileTask.dependsOn project(':').unzipWpilib
+        String architecture = targetPlatform.architecture
+        if (architecture.contains('arm')) {
+            // Grab all the shared libraries and link them
+            linker.args wpilibSharedLib
+
+            def libraryPath = wpilibLocation
+
+            linker.args << '-L' + libraryPath
+        }
+    }
+}
+
+def cscoreUnzipLocation = "$buildDir/cscore"
+
+task downloadCsCore() {
+    description = 'Downloads the C++ ARM CsCore maven dependency.'
+
+    group = 'WPILib'
+    def depFolder = "$buildDir/dependencies"
+    def libZip = file("$depFolder/cscore.zip")
+    outputs.file(libZip)
+    def armCsCore
+    
+
+    doFirst {
+        def armCsDependency = project.dependencies.create("edu.wpi.cscore.cpp:cscore:+:athena-uberzip@zip")
+        def armCsConfig = project.configurations.detachedConfiguration(armCsDependency)
+        armCsConfig.setTransitive(false)
+        armCsCore = armCsConfig.files[0].canonicalFile
+    }
+
+    doLast {
+        copy {
+            from armCsCore
+            rename 'cscore(.+)', 'cscore.zip'
+            into depFolder
+        }
+    }
+}
+
+// Create a task that will unzip the cscore files into a temporary build directory
+task unzipCsCore(type: Copy) {
+    description = 'Unzips the cscore maven dependency so that the include files and libraries can be used'
+    group = 'WPILib'
+    dependsOn downloadCsCore
+    
+    from zipTree(downloadCsCore.outputs.files.singleFile)
+    into cscoreUnzipLocation
+}
+
+ext.defineCsCoreProperties = {
+    ext.cscore = cscoreUnzipLocation
+    ext.cscoreInclude = "$cscoreUnzipLocation/include"
+    ext.cscoreLocation = "$cscoreUnzipLocation/lib"
+    ext.opencvSharedLib = "$cscoreLocation/libopencv.so"
+	ext.cscoreSharedLib = "$cscoreLocation/libcscore.so"
+    
+    ext.addCsCoreLibraryLinks = { compileTask, linker, targetPlatform ->
+        compileTask.dependsOn project(':').unzipCsCore
+        String architecture = targetPlatform.architecture
+        if (architecture.contains('arm')) {
+            // Grab all the shared libraries and link them
+            linker.args opencvSharedLib
+			linker.args cscoreSharedLib
+
+            def libraryPath = cscoreLocation
+
+            linker.args << '-L' + libraryPath
+        }
+    }
+}