mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Currently if using a separate compiler prefix, it would get published to the arm classifier. This modifies so the output suffix can now be specified (e.g. "hf" for armhf).
231 lines
9.8 KiB
Groovy
231 lines
9.8 KiB
Groovy
ext.useWpiUtil = { project ->
|
|
project.tasks.create(name: "downloadWpiUtil") {
|
|
description = 'Downloads the wpiutil maven dependency.'
|
|
group = 'WPILib'
|
|
def depFolder = "${project.buildDir}/dependencies"
|
|
def utilZip = file("${depFolder}/wpiutil.zip")
|
|
outputs.file(utilZip)
|
|
def wpiUtil
|
|
|
|
doFirst {
|
|
def wpiUtilDependency
|
|
if (project.isArm && project.hasProperty('compilerPrefix') && project.hasProperty('armSuffix')) {
|
|
wpiUtilDependency = project.dependencies.create("edu.wpi.first.wpilib:wpiutil:+:arm${project.armSuffix}@zip")
|
|
} else {
|
|
wpiUtilDependency = project.dependencies.create("edu.wpi.first.wpilib:wpiutil:+:${project.isArm ? 'arm' : 'desktop'}@zip")
|
|
}
|
|
|
|
def wpiUtilConfig = project.configurations.detachedConfiguration(wpiUtilDependency)
|
|
wpiUtilConfig.setTransitive(false)
|
|
wpiUtil = wpiUtilConfig.files[0].canonicalFile
|
|
}
|
|
|
|
doLast {
|
|
copy {
|
|
from wpiUtil
|
|
rename 'wpiutil(.+)', 'wpiutil.zip'
|
|
into depFolder
|
|
}
|
|
}
|
|
}
|
|
|
|
def wpiUtilUnzipLocation = "${project.buildDir}/wpiutil"
|
|
|
|
// Create a task that will unzip the wpiutil files into a temporary build directory
|
|
project.tasks.create(name: "unzipWpiUtil", type: Copy) {
|
|
description = 'Unzips the wpiutil maven dependency so that the include files and libraries can be used'
|
|
group = 'WPILib'
|
|
dependsOn project.tasks.downloadWpiUtil
|
|
from zipTree(project.tasks.downloadWpiUtil.outputs.files.singleFile)
|
|
into wpiUtilUnzipLocation
|
|
}
|
|
|
|
project.ext.wpiUtil = wpiUtilUnzipLocation
|
|
project.ext.wpiUtilInclude = "$wpiUtilUnzipLocation/include"
|
|
|
|
project.ext.addWpiUtilStaticLibraryLinks = { compileTask, linker, targetPlatform ->
|
|
compileTask.dependsOn project.tasks.unzipWpiUtil
|
|
String path = project.getPlatformPath2(targetPlatform)
|
|
if (targetPlatform.operatingSystem.windows) {
|
|
linker.args "${project.wpiUtil}/${path}/wpiutil.lib"
|
|
} else {
|
|
linker.args "${project.wpiUtil}/${path}/libwpiutil.a"
|
|
}
|
|
}
|
|
|
|
project.ext.addWpiUtilSharedLibraryLinks = { compileTask, linker, targetPlatform ->
|
|
compileTask.dependsOn project.tasks.unzipWpiUtil
|
|
String path = project.getPlatformPath2(targetPlatform)
|
|
if (targetPlatform.operatingSystem.windows) {
|
|
linker.args "${project.wpiUtil}/${path}/wpiutil.dll"
|
|
} else {
|
|
linker.args "${project.wpiUtil}/${path}/libwpiutil.so"
|
|
}
|
|
}
|
|
}
|
|
|
|
ext.getOpenCvPlatformPackage = { targetPlatform ->
|
|
if (targetPlatform.architecture.arm && project.hasProperty('compilerPrefix') && project.hasProperty('armSuffix')) {
|
|
return "linux-arm${project.armSuffix}"
|
|
} else if (targetPlatform.architecture.arm) {
|
|
return 'linux-arm'
|
|
} else if (targetPlatform.operatingSystem.linux) {
|
|
if (targetPlatform.architecture.amd64) {
|
|
return 'linux-x86_64'
|
|
} else {
|
|
return 'linux-' + targetPlatform.architecture.name
|
|
}
|
|
} else if (targetPlatform.operatingSystem.windows) {
|
|
if (targetPlatform.architecture.amd64) {
|
|
return 'windows-x86_64'
|
|
} else {
|
|
return 'windows-' + targetPlatform.architecture.name
|
|
}
|
|
} else if (targetPlatform.operatingSystem.macOsX) {
|
|
if (targetPlatform.architecture.amd64) {
|
|
return 'osx-x86_64'
|
|
} else {
|
|
return 'osx-' + targetPlatform.architecture.name
|
|
}
|
|
} else {
|
|
return targetPlatform.operatingSystem.name + '-' + targetPlatform.architecture.name
|
|
}
|
|
}
|
|
|
|
task downloadOpenCvHeaders() {
|
|
description = 'Downloads the OpenCV Headers maven dependency.'
|
|
group = 'WPILib'
|
|
def depFolder = "${buildDir}/dependencies"
|
|
def openCvHeadersZip = file("${depFolder}/opencv-headers.zip")
|
|
outputs.file(openCvHeadersZip)
|
|
def openCvHeaders
|
|
|
|
doFirst {
|
|
def openCvHeadersDependency = project.dependencies.create("org.opencv:opencv-headers:3.1.0@jar")
|
|
def openCvHeadersConfig = project.configurations.detachedConfiguration(openCvHeadersDependency)
|
|
openCvHeadersConfig.setTransitive(false)
|
|
openCvHeaders = openCvHeadersConfig.files[0].canonicalFile
|
|
}
|
|
|
|
doLast {
|
|
copy {
|
|
from openCvHeaders
|
|
rename 'opencv-headers(.+)', 'opencv-headers.zip'
|
|
into depFolder
|
|
}
|
|
}
|
|
}
|
|
|
|
ext.useOpenCv = { project ->
|
|
def openCvUnzipLocation = "${project.buildDir}/opencv"
|
|
|
|
project.tasks.create(name: "unzipOpenCvHeaders", type: Copy) {
|
|
description = 'Unzips the OpenCV maven dependency so that the include files and libraries can be used'
|
|
group = 'OpenCv'
|
|
dependsOn downloadOpenCvHeaders
|
|
from zipTree(downloadOpenCvHeaders.outputs.files.singleFile)
|
|
into "${openCvUnzipLocation}/include"
|
|
}
|
|
|
|
project.ext.openCv = openCvUnzipLocation
|
|
project.ext.openCvInclude = "$openCvUnzipLocation/include"
|
|
|
|
project.ext.addOpenCvLibraryLinks = { compileTask, linker, targetPlatform ->
|
|
def openCvPlatform = project.getOpenCvPlatformPackage(targetPlatform)
|
|
def openCvNativesFolder = "${project.openCv}/${openCvPlatform}"
|
|
|
|
if (project.tasks.findByPath("unzipOpenCvNatives_${openCvPlatform}") == null) {
|
|
project.tasks.create(name: "downloadOpenCvNatives_${openCvPlatform}") {
|
|
description = 'Downloads the OpenCV natives maven dependency.'
|
|
group = 'OpenCv'
|
|
def depFolder = "${project.buildDir}/dependencies"
|
|
def openCvNativesZip = file("${depFolder}/opencv-natives-${openCvPlatform}.zip")
|
|
outputs.file(openCvNativesZip)
|
|
def openCvNatives
|
|
|
|
doFirst {
|
|
def openCvNativesDependency = project.dependencies.create("org.opencv:opencv-natives:3.1.0:${openCvPlatform}@jar")
|
|
def openCvNativesConfig = project.configurations.detachedConfiguration(openCvNativesDependency)
|
|
openCvNativesConfig.setTransitive(false)
|
|
openCvNatives = openCvNativesConfig.files[0].canonicalFile
|
|
}
|
|
|
|
doLast {
|
|
copy {
|
|
from openCvNatives
|
|
rename 'opencv-natives(.+)', "opencv-natives-${openCvPlatform}.zip"
|
|
into depFolder
|
|
}
|
|
}
|
|
}
|
|
|
|
project.tasks.create(name: "unzipOpenCvNatives_${openCvPlatform}", type: Copy) {
|
|
description = 'Unzips the OpenCV maven dependency so that the include files and libraries can be used'
|
|
group = 'OpenCv'
|
|
dependsOn "downloadOpenCvNatives_${openCvPlatform}"
|
|
from zipTree(project.tasks["downloadOpenCvNatives_${openCvPlatform}"].outputs.files.singleFile)
|
|
into openCvNativesFolder
|
|
exclude '**/MANIFEST.MF'
|
|
}
|
|
}
|
|
|
|
if (project.includeJava && project.tasks.findByPath("unzipOpenCvJni_${openCvPlatform}") == null) {
|
|
project.tasks.create(name: "downloadOpenCvJni_${openCvPlatform}") {
|
|
description = 'Downloads the OpenCV JNI maven dependency.'
|
|
group = 'OpenCv'
|
|
def depFolder = "${project.buildDir}/dependencies"
|
|
def openCvJniZip = file("${depFolder}/opencv-jni-${openCvPlatform}.zip")
|
|
outputs.file(openCvJniZip)
|
|
def openCvJni
|
|
|
|
doFirst {
|
|
def openCvJniDependency = project.dependencies.create("org.opencv:opencv-jni:3.1.0:${openCvPlatform}@jar")
|
|
def openCvJniConfig = project.configurations.detachedConfiguration(openCvJniDependency)
|
|
openCvJniConfig.setTransitive(false)
|
|
openCvJni = openCvJniConfig.files[0].canonicalFile
|
|
}
|
|
|
|
doLast {
|
|
copy {
|
|
from openCvJni
|
|
rename 'opencv-jni(.+)', "opencv-jni-${openCvPlatform}.zip"
|
|
into depFolder
|
|
}
|
|
}
|
|
}
|
|
|
|
project.tasks.create(name: "unzipOpenCvJni_${openCvPlatform}", type: Copy) {
|
|
description = 'Unzips the OpenCV maven dependency so that the include files and libraries can be used'
|
|
group = 'OpenCv'
|
|
dependsOn "downloadOpenCvJni_${openCvPlatform}"
|
|
from zipTree(project.tasks["downloadOpenCvJni_${openCvPlatform}"].outputs.files.singleFile)
|
|
into openCvNativesFolder
|
|
exclude '**/MANIFEST.MF'
|
|
}
|
|
}
|
|
|
|
compileTask.dependsOn "unzipOpenCvHeaders", "unzipOpenCvNatives_${openCvPlatform}"
|
|
if (project.includeJava) {
|
|
compileTask.dependsOn "unzipOpenCvJni_${openCvPlatform}"
|
|
}
|
|
if (targetPlatform.operatingSystem.windows) {
|
|
linker.args new String("${openCvNativesFolder}\\opencv.lib").replace('/', '\\')
|
|
linker.args new String("${openCvNativesFolder}\\Release\\libjpeg.lib").replace('/', '\\')
|
|
linker.args new String("${openCvNativesFolder}\\Release\\libpng.lib").replace('/', '\\')
|
|
linker.args new String("${openCvNativesFolder}\\Release\\zlib.lib").replace('/', '\\')
|
|
linker.args "kernel32.lib"
|
|
linker.args "user32.lib"
|
|
linker.args "gdi32.lib"
|
|
linker.args "Ole32.lib"
|
|
linker.args "OleAut32.lib"
|
|
linker.args "comdlg32.lib"
|
|
linker.args "advapi32.lib"
|
|
linker.args "Vfw32.lib"
|
|
} else {
|
|
linker.args "-L${openCvNativesFolder}"
|
|
linker.args "-lopencv"
|
|
linker.args "-ldl"
|
|
}
|
|
}
|
|
}
|