Brian Silverman | 890a32a | 2018-03-11 15:41:56 -0700 | [diff] [blame] | 1 | task downloadWpiUtil() { |
| 2 | description = 'Downloads the C++ ARM wpiutil maven dependency.' |
| 3 | group = 'WPILib' |
| 4 | def depFolder = "$buildDir/dependencies" |
| 5 | def utilZip = file("$depFolder/wpiutil.zip") |
| 6 | outputs.file(utilZip) |
| 7 | def armWpiUtil |
| 8 | |
| 9 | doFirst { |
| 10 | def armWpiUtilDependency = project.dependencies.create("edu.wpi.first.wpiutil:wpiutil-cpp:+:linuxathena@zip") |
| 11 | def armWpiUtilConfig = project.configurations.detachedConfiguration(armWpiUtilDependency) |
| 12 | armWpiUtilConfig.setTransitive(false) |
| 13 | armWpiUtil = armWpiUtilConfig.files[0].canonicalFile |
| 14 | } |
| 15 | |
| 16 | doLast { |
| 17 | copy { |
| 18 | from armWpiUtil |
| 19 | rename 'wpiutil(.+)', 'wpiutil.zip' |
| 20 | into depFolder |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | task downloadWpiUtilHeaders() { |
| 26 | description = 'Downloads the C++ ARM wpiutil maven dependency.' |
| 27 | group = 'WPILib' |
| 28 | def depFolder = "$buildDir/dependencies" |
| 29 | def utilZip = file("$depFolder/wpiutilHeaders.zip") |
| 30 | outputs.file(utilZip) |
| 31 | def armWpiUtilHeaders |
| 32 | |
| 33 | doFirst { |
| 34 | def armWpiUtilHeadersDependency = project.dependencies.create("edu.wpi.first.wpiutil:wpiutil-cpp:+:headers@zip") |
| 35 | def armWpiUtilHeadersConfig = project.configurations.detachedConfiguration(armWpiUtilHeadersDependency) |
| 36 | armWpiUtilHeadersConfig.setTransitive(false) |
| 37 | armWpiUtilHeaders = armWpiUtilHeadersConfig.files[0].canonicalFile |
| 38 | } |
| 39 | |
| 40 | doLast { |
| 41 | copy { |
| 42 | from armWpiUtilHeaders |
| 43 | rename 'wpiutil(.+)', 'wpiutilHeaders.zip' |
| 44 | into depFolder |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | def wpiUtilUnzipLocation = "$buildDir/wpiutil" |
| 50 | def wpiUtilUnzipHeadersLocation = "$buildDir/wpiutil/include" |
| 51 | |
| 52 | // Create a task that will unzip the wpiutil files into a temporary build directory |
| 53 | task unzipWpiUtil(type: Copy) { |
| 54 | description = 'Unzips the wpiutil maven dependency so that the include files and libraries can be used' |
| 55 | group = 'WPILib' |
| 56 | dependsOn downloadWpiUtil |
| 57 | |
| 58 | from zipTree(downloadWpiUtil.outputs.files.singleFile) |
| 59 | into wpiUtilUnzipLocation |
| 60 | } |
| 61 | |
| 62 | // Create a task that will unzip the wpiutil files into a temporary build directory |
| 63 | task unzipWpiUtilHeaders(type: Copy) { |
| 64 | description = 'Unzips the wpiutil maven dependency so that the include files and libraries can be used' |
| 65 | group = 'WPILib' |
| 66 | dependsOn downloadWpiUtilHeaders |
| 67 | |
| 68 | from zipTree(downloadWpiUtilHeaders.outputs.files.singleFile) |
| 69 | into wpiUtilUnzipHeadersLocation |
| 70 | } |
| 71 | |
| 72 | ext.defineWpiUtilProperties = { |
| 73 | ext.wpiUtil = wpiUtilUnzipLocation |
| 74 | ext.wpiUtilInclude = "$wpiUtilUnzipLocation/include" |
| 75 | ext.wpiUtilLibArmLocation = "$wpiUtilUnzipLocation/linux/athena/shared" |
| 76 | ext.wpiUtilSharedLib = "$wpiUtilLibArmLocation/libwpiutil.so" |
| 77 | ext.wpiUtilSharedLibDebug = "$wpiUtilLibArmLocation/libwpiutil.so.debug" |
| 78 | ext.addWpiUtilLibraryLinks = { compileTask, linker, targetPlatform -> |
| 79 | compileTask.dependsOn project(':').unzipWpiUtil |
| 80 | compileTask.dependsOn project(':').unzipWpiUtilHeaders |
| 81 | String architecture = targetPlatform.architecture |
| 82 | if (architecture.contains('arm')) { |
| 83 | // linker.args wpiUtilSharedLib |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | |
| 89 | |
| 90 | def NIUnzipHeadersLocation = "$buildDir/NI/include" |
| 91 | |
| 92 | task downloadNIHeaders() { |
| 93 | description = 'Downloads the NI headers.' |
| 94 | |
| 95 | group = 'WPILib' |
| 96 | def depFolder = "$buildDir/dependencies" |
| 97 | def libZip = file("$depFolder/NIHeaders.zip") |
| 98 | outputs.file(libZip) |
| 99 | def NIHeaders |
| 100 | |
| 101 | |
| 102 | doFirst { |
| 103 | def NIHeadersDependency = project.dependencies.create("edu.wpi.first.ni-libraries:ni-libraries:+:headers@zip") |
| 104 | def NIHeadersConfig = project.configurations.detachedConfiguration(NIHeadersDependency) |
| 105 | NIHeadersConfig.setTransitive(false) |
| 106 | NIHeaders = NIHeadersConfig.files[0].canonicalFile |
| 107 | } |
| 108 | |
| 109 | doLast { |
| 110 | copy { |
| 111 | from NIHeaders |
| 112 | rename 'ni-libraries(.+)', 'NIHeaders.zip' |
| 113 | into depFolder |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | task unzipNIHeaders(type: Copy) { |
| 119 | description = 'Unzips the NI include files so they can be used' |
| 120 | group = 'WPILib' |
| 121 | dependsOn downloadNIHeaders |
| 122 | |
| 123 | from zipTree(downloadNIHeaders.outputs.files.singleFile) |
| 124 | into NIUnzipHeadersLocation |
| 125 | } |
| 126 | |
| 127 | ext.defineNIProperties = { |
| 128 | ext.NI = NIUnzipHeadersLocation |
| 129 | ext.NIInclude = NIUnzipHeadersLocation |
| 130 | |
| 131 | ext.addNILibraryLinks = { compileTask, linker, targetPlatform -> |
| 132 | compileTask.dependsOn project(':').unzipNIHeaders |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | |
| 137 | |
| 138 | def halUnzipLocation = "$buildDir/hal" |
| 139 | def halUnzipHeadersLocation = "$buildDir/hal/include" |
| 140 | |
| 141 | task downloadHAL() { |
| 142 | description = 'Downloads the C++ ARM HAL maven dependency.' |
| 143 | |
| 144 | group = 'WPILib' |
| 145 | def depFolder = "$buildDir/dependencies" |
| 146 | def libZip = file("$depFolder/hal.zip") |
| 147 | outputs.file(libZip) |
| 148 | def armHal |
| 149 | |
| 150 | |
| 151 | doFirst { |
| 152 | def armHALDependency = project.dependencies.create("edu.wpi.first.hal:hal:+:linuxathena@zip") |
| 153 | def armHALConfig = project.configurations.detachedConfiguration(armHALDependency) |
| 154 | armHALConfig.setTransitive(false) |
| 155 | armHal = armHALConfig.files[0].canonicalFile |
| 156 | } |
| 157 | |
| 158 | doLast { |
| 159 | copy { |
| 160 | from armHal |
| 161 | rename 'hal(.+)', 'hal.zip' |
| 162 | into depFolder |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | task downloadHALHeaders() { |
| 168 | description = 'Downloads the C++ ARM HAL maven dependency.' |
| 169 | |
| 170 | group = 'WPILib' |
| 171 | def depFolder = "$buildDir/dependencies" |
| 172 | def libZip = file("$depFolder/halHeaders.zip") |
| 173 | outputs.file(libZip) |
| 174 | def armHalHeaders |
| 175 | |
| 176 | |
| 177 | doFirst { |
| 178 | def armHALHeadersDependency = project.dependencies.create("edu.wpi.first.hal:hal:+:headers@zip") |
| 179 | def armHALHeadersConfig = project.configurations.detachedConfiguration(armHALHeadersDependency) |
| 180 | armHALHeadersConfig.setTransitive(false) |
| 181 | armHalHeaders = armHALHeadersConfig.files[0].canonicalFile |
| 182 | } |
| 183 | |
| 184 | doLast { |
| 185 | copy { |
| 186 | from armHalHeaders |
| 187 | rename 'hal(.+)', 'halHeaders.zip' |
| 188 | into depFolder |
| 189 | } |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | // Create a task that will unzip the hal files into a temporary build directory |
| 194 | task unzipHAL(type: Copy) { |
| 195 | description = 'Unzips the hal maven dependency so that the include files and libraries can be used' |
| 196 | group = 'WPILib' |
| 197 | dependsOn downloadHAL |
| 198 | |
| 199 | from zipTree(downloadHAL.outputs.files.singleFile) |
| 200 | into halUnzipLocation |
| 201 | } |
| 202 | task unzipHALHeaders(type: Copy) { |
| 203 | description = 'Unzips the hal maven dependency so that the include files and libraries can be used' |
| 204 | group = 'WPILib' |
| 205 | dependsOn downloadHALHeaders |
| 206 | |
| 207 | from zipTree(downloadHALHeaders.outputs.files.singleFile) |
| 208 | into halUnzipHeadersLocation |
| 209 | } |
| 210 | |
| 211 | ext.defineHALProperties = { |
| 212 | ext.hal = halUnzipLocation |
| 213 | ext.halInclude = "$halUnzipLocation/include" |
| 214 | ext.halLocation = "$halUnzipLocation/linux/athena/shared" |
| 215 | ext.halSharedLib = "$halLocation/libwpiHal.so" |
| 216 | |
| 217 | ext.addHalLibraryLinks = { compileTask, linker, targetPlatform -> |
| 218 | compileTask.dependsOn project(':').unzipHAL |
| 219 | compileTask.dependsOn project(':').unzipHALHeaders |
| 220 | String architecture = targetPlatform.architecture |
| 221 | if (architecture.contains('arm')) { |
| 222 | // Grab all the shared libraries and link them |
| 223 | linker.args halSharedLib |
| 224 | // linker.args "$halLocation/libnilibraries.so" |
| 225 | |
| 226 | def libraryPath = halLocation |
| 227 | |
| 228 | linker.args << '-L' + libraryPath |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | task downloadNetworkTables() { |
| 234 | description = 'Downloads the C++ ARM NetworkTables maven dependency.' |
| 235 | group = 'WPILib' |
| 236 | def depFolder = "$buildDir/dependencies" |
| 237 | def ntZip = file("$depFolder/ntcore.zip") |
| 238 | outputs.file(ntZip) |
| 239 | def armNetTables |
| 240 | |
| 241 | doFirst { |
| 242 | def armNtDependency = project.dependencies.create('edu.wpi.first.ntcore:ntcore-cpp:+:linuxathena@zip') |
| 243 | def armConfig = project.configurations.detachedConfiguration(armNtDependency) |
| 244 | armConfig.setTransitive(false) |
| 245 | armNetTables = armConfig.files[0].canonicalFile |
| 246 | } |
| 247 | |
| 248 | doLast { |
| 249 | copy { |
| 250 | from armNetTables |
| 251 | rename 'ntcore(.+)', 'ntcore.zip' |
| 252 | into depFolder |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | task downloadNetworkTablesHeaders() { |
| 257 | description = 'Downloads the C++ ARM NetworkTables maven dependency.' |
| 258 | group = 'WPILib' |
| 259 | def depFolder = "$buildDir/dependencies" |
| 260 | def ntZip = file("$depFolder/ntcoreHeaders.zip") |
| 261 | outputs.file(ntZip) |
| 262 | def armNetTablesHeaders |
| 263 | |
| 264 | doFirst { |
| 265 | def armNtHeadersDependency = project.dependencies.create('edu.wpi.first.ntcore:ntcore-cpp:+:headers@zip') |
| 266 | def armHeadersConfig = project.configurations.detachedConfiguration(armNtHeadersDependency) |
| 267 | armHeadersConfig.setTransitive(false) |
| 268 | armNetTablesHeaders = armHeadersConfig.files[0].canonicalFile |
| 269 | } |
| 270 | |
| 271 | doLast { |
| 272 | copy { |
| 273 | from armNetTablesHeaders |
| 274 | rename 'ntcore(.+)', 'ntcoreHeaders.zip' |
| 275 | into depFolder |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | def netTablesUnzipLocation = "$buildDir/ntcore" |
| 281 | def netTablesHeadersUnzipLocation = "$buildDir/ntcore/include" |
| 282 | |
| 283 | // Create a task that will unzip the networktables files into a temporary build directory |
| 284 | task unzipNetworkTables(type: Copy) { |
| 285 | description = 'Unzips the networktables maven dependency so that the include files and libraries can be used' |
| 286 | group = 'WPILib' |
| 287 | dependsOn downloadNetworkTables |
| 288 | |
| 289 | from zipTree(downloadNetworkTables.outputs.files.singleFile) |
| 290 | into netTablesUnzipLocation |
| 291 | } |
| 292 | task unzipNetworkTablesHeaders(type: Copy) { |
| 293 | description = 'Unzips the networktables maven dependency so that the include files and libraries can be used' |
| 294 | group = 'WPILib' |
| 295 | dependsOn downloadNetworkTablesHeaders |
| 296 | |
| 297 | from zipTree(downloadNetworkTablesHeaders.outputs.files.singleFile) |
| 298 | into netTablesHeadersUnzipLocation |
| 299 | } |
| 300 | |
| 301 | // This defines a project property that projects depending on network tables can use to setup that dependency. |
| 302 | ext.defineNetworkTablesProperties = { |
| 303 | ext.netTables = netTablesUnzipLocation |
| 304 | ext.netTablesInclude = "$netTablesUnzipLocation/include" |
| 305 | ext.netLibArmLocation = "$netTablesUnzipLocation/linux/athena/shared" |
| 306 | ext.netSharedLib = "$netLibArmLocation/libntcore.so" |
| 307 | ext.netSharedLibDebug = "$netLibArmLocation/libntcore.so.debug" |
| 308 | |
| 309 | ext.addNetworkTablesLibraryLinks = { compileTask, linker, targetPlatform -> |
| 310 | compileTask.dependsOn project(':').unzipNetworkTables |
| 311 | compileTask.dependsOn project(':').unzipNetworkTablesHeaders |
| 312 | String architecture = targetPlatform.architecture |
| 313 | if (architecture.contains('arm')) { |
| 314 | linker.args netSharedLib |
| 315 | } |
| 316 | addWpiUtilLibraryLinks(compileTask, linker, targetPlatform) |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | |
| 321 | def wpilibUnzipLocation = "$buildDir/wpilib" |
| 322 | def wpilibHeadersUnzipLocation = "$buildDir/wpilib/include" |
| 323 | |
| 324 | task downloadWpilib() { |
| 325 | description = 'Downloads the C++ ARM wpilib maven dependency.' |
| 326 | |
| 327 | group = 'WPILib' |
| 328 | def depFolder = "$buildDir/dependencies" |
| 329 | def libZip = file("$depFolder/wpilibc.zip") |
| 330 | outputs.file(libZip) |
| 331 | def armWPILib |
| 332 | |
| 333 | |
| 334 | doFirst { |
| 335 | def armWpiLibDependency = project.dependencies.create("edu.wpi.first.wpilibc:wpilibc:+:linuxathena@zip") |
| 336 | def armWpiLibConfig = project.configurations.detachedConfiguration(armWpiLibDependency) |
| 337 | armWpiLibConfig.setTransitive(false) |
| 338 | armWPILib = armWpiLibConfig.files[0].canonicalFile |
| 339 | } |
| 340 | |
| 341 | doLast { |
| 342 | copy { |
| 343 | from armWPILib |
| 344 | rename 'wpilibc(.+)', 'wpilibc.zip' |
| 345 | into depFolder |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | task downloadWpilibHeaders() { |
| 350 | description = 'Downloads the C++ ARM wpilib maven dependency.' |
| 351 | |
| 352 | group = 'WPILib' |
| 353 | def depFolder = "$buildDir/dependencies" |
| 354 | def libZip = file("$depFolder/wpilibcHeaders.zip") |
| 355 | outputs.file(libZip) |
| 356 | def armWPILibHeaders |
| 357 | |
| 358 | |
| 359 | doFirst { |
| 360 | def armWpiLibHeadersDependency = project.dependencies.create("edu.wpi.first.wpilibc:wpilibc:+:headers@zip") |
| 361 | def armWpiLibHeadersConfig = project.configurations.detachedConfiguration(armWpiLibHeadersDependency) |
| 362 | armWpiLibHeadersConfig.setTransitive(false) |
| 363 | armWPILibHeaders = armWpiLibHeadersConfig.files[0].canonicalFile |
| 364 | } |
| 365 | |
| 366 | doLast { |
| 367 | copy { |
| 368 | from armWPILibHeaders |
| 369 | rename 'wpilibc(.+)', 'wpilibcHeaders.zip' |
| 370 | into depFolder |
| 371 | } |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | // Create a task that will unzip the wpilib files into a temporary build directory |
| 376 | task unzipWpilib(type: Copy) { |
| 377 | description = 'Unzips the wpilib maven dependency so that the include files and libraries can be used' |
| 378 | group = 'WPILib' |
| 379 | dependsOn downloadWpilib |
| 380 | |
| 381 | from zipTree(downloadWpilib.outputs.files.singleFile) |
| 382 | into wpilibUnzipLocation |
| 383 | } |
| 384 | task unzipWpilibHeaders(type: Copy) { |
| 385 | description = 'Unzips the wpilib maven dependency so that the include files and libraries can be used' |
| 386 | group = 'WPILib' |
| 387 | dependsOn downloadWpilibHeaders |
| 388 | |
| 389 | from zipTree(downloadWpilibHeaders.outputs.files.singleFile) |
| 390 | into wpilibHeadersUnzipLocation |
| 391 | } |
| 392 | |
| 393 | ext.defineWpiLibProperties = { |
| 394 | ext.wpilib = wpilibUnzipLocation |
| 395 | ext.wpilibInclude = "$wpilibUnzipLocation/include" |
| 396 | ext.wpilibLocation = "$wpilibUnzipLocation/linux/athena/shared" |
| 397 | ext.wpilibSharedLib = "$wpilibLocation/libwpilibc.so" |
| 398 | |
| 399 | ext.addWpilibLibraryLinks = { compileTask, linker, targetPlatform -> |
| 400 | compileTask.dependsOn project(':').unzipWpilib |
| 401 | compileTask.dependsOn project(':').unzipWpilibHeaders |
| 402 | String architecture = targetPlatform.architecture |
| 403 | if (architecture.contains('arm')) { |
| 404 | // Grab all the shared libraries and link them |
| 405 | linker.args wpilibSharedLib |
| 406 | |
| 407 | def libraryPath = wpilibLocation |
| 408 | |
| 409 | linker.args << '-L' + libraryPath |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | def cscoreUnzipLocation = "$buildDir/cscore" |
| 415 | |
| 416 | task downloadCsCore() { |
| 417 | description = 'Downloads the C++ ARM CsCore maven dependency.' |
| 418 | |
| 419 | group = 'WPILib' |
| 420 | def depFolder = "$buildDir/dependencies" |
| 421 | def libZip = file("$depFolder/cscore.zip") |
| 422 | outputs.file(libZip) |
| 423 | def armCsCore |
| 424 | |
| 425 | |
| 426 | doFirst { |
| 427 | def armCsDependency = project.dependencies.create("edu.wpi.cscore.cpp:cscore:+:athena-uberzip@zip") |
| 428 | def armCsConfig = project.configurations.detachedConfiguration(armCsDependency) |
| 429 | armCsConfig.setTransitive(false) |
| 430 | armCsCore = armCsConfig.files[0].canonicalFile |
| 431 | } |
| 432 | |
| 433 | doLast { |
| 434 | copy { |
| 435 | from armCsCore |
| 436 | rename 'cscore(.+)', 'cscore.zip' |
| 437 | into depFolder |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | // Create a task that will unzip the cscore files into a temporary build directory |
| 443 | task unzipCsCore(type: Copy) { |
| 444 | description = 'Unzips the cscore maven dependency so that the include files and libraries can be used' |
| 445 | group = 'WPILib' |
| 446 | dependsOn downloadCsCore |
| 447 | |
| 448 | from zipTree(downloadCsCore.outputs.files.singleFile) |
| 449 | into cscoreUnzipLocation |
| 450 | } |
| 451 | |
| 452 | ext.defineCsCoreProperties = { |
| 453 | ext.cscore = cscoreUnzipLocation |
| 454 | ext.cscoreInclude = "$cscoreUnzipLocation/include" |
| 455 | ext.cscoreLocation = "$cscoreUnzipLocation/lib" |
| 456 | ext.opencvSharedLib = "$cscoreLocation/libopencv.so" |
| 457 | ext.cscoreSharedLib = "$cscoreLocation/libcscore.so" |
| 458 | |
| 459 | ext.addCsCoreLibraryLinks = { compileTask, linker, targetPlatform -> |
| 460 | // compileTask.dependsOn project(':').unzipCsCore |
| 461 | String architecture = targetPlatform.architecture |
| 462 | if (architecture.contains('arm')) { |
| 463 | // Grab all the shared libraries and link them |
| 464 | linker.args opencvSharedLib |
| 465 | linker.args cscoreSharedLib |
| 466 | |
| 467 | def libraryPath = cscoreLocation |
| 468 | |
| 469 | linker.args << '-L' + libraryPath |
| 470 | } |
| 471 | } |
| 472 | } |