mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
316 lines
13 KiB
Groovy
316 lines
13 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
plugins {
|
|
id 'net.ltgt.errorprone' version '0.0.8'
|
|
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '1.2'
|
|
}
|
|
|
|
allprojects {
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
}
|
|
|
|
ext.buildArm = !project.hasProperty('skipArm')
|
|
ext.includeJava = !project.hasProperty('skipJava')
|
|
|
|
if (hasProperty('makeDesktop')) {
|
|
println 'Making desktop classifier jar. NOTE: This desktop version should only be used for local testing.' +
|
|
'It will only support the current platform, and will override fetching the latest development version from' +
|
|
' the maven repo until you manually delete it!'
|
|
}
|
|
|
|
ext.getPlatformPath2 = { targetPlatform ->
|
|
if (targetPlatform.architecture.arm) {
|
|
return 'Linux/arm'
|
|
} else if (targetPlatform.operatingSystem.linux) {
|
|
if (targetPlatform.architecture.amd64) {
|
|
return 'Linux/amd64'
|
|
} else {
|
|
return 'Linux/' + targetPlatform.architecture.name
|
|
}
|
|
} else if (targetPlatform.operatingSystem.windows) {
|
|
if (targetPlatform.architecture.amd64) {
|
|
return 'Windows/amd64'
|
|
} else {
|
|
return 'Windows/' + targetPlatform.architecture.name
|
|
}
|
|
} else if (targetPlatform.operatingSystem.macOsX) {
|
|
if (targetPlatform.architecture.amd64) {
|
|
return 'Mac OS X/x86_64'
|
|
} else {
|
|
return 'Mac OS X/' + targetPlatform.architecture.name
|
|
}
|
|
} else {
|
|
return targetPlatform.operatingSystem.name + '/' + targetPlatform.architecture.name
|
|
}
|
|
}
|
|
|
|
ext.getPlatformPath = { binary ->
|
|
return getPlatformPath2(binary.targetPlatform)
|
|
}
|
|
|
|
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 = 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.addWpiUtilLibraryLinks = { 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"
|
|
}
|
|
}
|
|
}
|
|
|
|
ext.getOpenCvPlatformPackage = { targetPlatform ->
|
|
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.architecture.arm) {
|
|
linker.args "${openCvNativesFolder}/libopencv_calib3d.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_core.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_features2d.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_flann.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_highgui.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_imgcodecs.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_imgproc.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_ml.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_objdetect.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_photo.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_shape.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_stitching.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_superres.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_video.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_videoio.so"
|
|
linker.args "${openCvNativesFolder}/libopencv_videostab.so"
|
|
linker.args "-ldl"
|
|
linker.args "-lz"
|
|
} else if (targetPlatform.operatingSystem.windows) {
|
|
linker.args "${openCvNativesFolder}/opencv_core.lib"
|
|
} else {
|
|
linker.args "${openCvNativesFolder}/libopencv_calib3d.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_core.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_features2d.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_flann.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_highgui.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_imgcodecs.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_imgproc.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_ml.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_objdetect.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_photo.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_shape.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_stitching.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_superres.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_video.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_videoio.a"
|
|
linker.args "${openCvNativesFolder}/libopencv_videostab.a"
|
|
linker.args "-ldl"
|
|
linker.args "-lz"
|
|
}
|
|
}
|
|
}
|
|
|
|
ext.setupDefines = { project, binaries ->
|
|
binaries.all {
|
|
if (project.hasProperty('debug')) {
|
|
project.setupDebugDefines(cppCompiler, linker)
|
|
} else {
|
|
project.setupReleaseDefines(cppCompiler, linker)
|
|
}
|
|
tasks.withType(CppCompile) {
|
|
project.addWpiUtilLibraryLinks(it, linker, targetPlatform)
|
|
project.addOpenCvLibraryLinks(it, linker, targetPlatform)
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: "cameraserver.gradle"
|
|
|
|
// Empty task for build so that cameraserverSourceZip will be
|
|
// built when running ./gradlew build
|
|
task build
|
|
|
|
build.dependsOn cameraserverSourceZip
|
|
|
|
apply from: 'publish.gradle'
|
|
|
|
task wrapper(type: Wrapper) {
|
|
gradleVersion = '3.0'
|
|
}
|