mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
This check is unnecessary and is run during task creation, so prevents the .debug file from being included the first time gradle is run.
233 lines
7.2 KiB
Groovy
233 lines
7.2 KiB
Groovy
def cameraserverSetupModel = { project ->
|
|
project.model {
|
|
components {
|
|
cameraserver(NativeLibrarySpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
binaries.all {
|
|
tasks.withType(CppCompile) {
|
|
project.addWpiUtilLibraryLinks(it, linker, targetPlatform)
|
|
}
|
|
}
|
|
|
|
if (includeJava) {
|
|
project.setupJniIncludes(binaries)
|
|
binaries.all {
|
|
project.setupDef(linker, "${rootDir}/cameraserver-jni.def")
|
|
}
|
|
} else {
|
|
binaries.all {
|
|
project.setupDef(linker, "${rootDir}/cameraserver.def")
|
|
}
|
|
}
|
|
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = ["${rootDir}/src"]
|
|
if (includeJava) {
|
|
srcDirs "${rootDir}/java/lib"
|
|
}
|
|
includes = ['**/*.cpp']
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ["${rootDir}/include", project.wpiUtilInclude, project.openCvInclude]
|
|
if (includeJava) {
|
|
project.jniHeadersCameraServer.outputs.files.each { file ->
|
|
srcDirs file.getPath()
|
|
}
|
|
}
|
|
includes = ['**/*.h']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def cameraserverSetupExamplesModel = { project ->
|
|
project.model {
|
|
components {
|
|
enum_usb(NativeExecutableSpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
binaries.all {
|
|
tasks.withType(CppCompile) {
|
|
project.addWpiUtilLibraryLinks(it, linker, targetPlatform)
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDir "${rootDir}/examples/enum_usb"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include"]
|
|
include '**/*.h'
|
|
}
|
|
lib library: 'cameraserver', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
|
|
usbstream(NativeExecutableSpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
binaries.all {
|
|
tasks.withType(CppCompile) {
|
|
project.addWpiUtilLibraryLinks(it, linker, targetPlatform)
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDir "${rootDir}/examples/usbstream"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include"]
|
|
include '**/*.h'
|
|
}
|
|
lib library: 'cameraserver', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def cameraserverZipTask = { project ->
|
|
project.ext.cameraserverZip = project.tasks.create("${project.isArm ? 'arm' : 'native'}CameraserverZip", Zip) {
|
|
description = 'Creates platform-specific zip of the desktop cameraserver libraries.'
|
|
group = 'WPILib'
|
|
destinationDir = project.buildDir
|
|
baseName = 'cameraserver'
|
|
classifier = "${project.buildPlatform}"
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(file('include')) {
|
|
into 'include'
|
|
}
|
|
|
|
if (!project.hasProperty('skipJava')) {
|
|
project.jniHeadersCameraServer.outputs.each {
|
|
from(it) {
|
|
into 'include'
|
|
}
|
|
}
|
|
}
|
|
|
|
project.model {
|
|
binaries {
|
|
withType(StaticLibraryBinarySpec) { binary ->
|
|
from(binary.staticLibraryFile) {
|
|
into getPlatformPath(binary)
|
|
}
|
|
}
|
|
withType(SharedLibraryBinarySpec) { binary ->
|
|
from(binary.sharedLibraryFile) {
|
|
into getPlatformPath(binary)
|
|
}
|
|
from (new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
|
|
into getPlatformPath(binary)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
project.build.dependsOn project.cameraserverZip
|
|
|
|
project.debugStripSetup()
|
|
|
|
project.tasks.whenTaskAdded { task ->
|
|
def name = task.name.toLowerCase()
|
|
if (name.contains("cameraserversharedlibrary") || name.contains("cameraserverstaticlibrary") || name.contains("cameraservertest")) {
|
|
project.cameraserverZip.dependsOn task
|
|
}
|
|
}
|
|
}
|
|
|
|
if (buildArm) {
|
|
project(':arm') {
|
|
apply plugin: 'cpp'
|
|
|
|
apply from: "${rootDir}/toolchains/arm.gradle"
|
|
if (includeJava) {
|
|
apply from: "${rootDir}/java/java.gradle"
|
|
}
|
|
|
|
cameraserverSetupModel(project)
|
|
cameraserverSetupExamplesModel(project)
|
|
cameraserverZipTask(project)
|
|
useWpiUtil(project)
|
|
useOpenCv(project)
|
|
}
|
|
}
|
|
|
|
project(':native') {
|
|
apply plugin: 'cpp'
|
|
|
|
apply from: "${rootDir}/toolchains/native.gradle"
|
|
|
|
//if (!project.hasProperty("withoutTests")) {
|
|
// apply from: "${rootDir}/test/tests.gradle"
|
|
//}
|
|
|
|
if (includeJava) {
|
|
apply from: "${rootDir}/java/java.gradle"
|
|
}
|
|
|
|
cameraserverSetupModel(project)
|
|
cameraserverSetupExamplesModel(project)
|
|
cameraserverZipTask(project)
|
|
useWpiUtil(project)
|
|
useOpenCv(project)
|
|
}
|
|
|
|
task cameraserverSourceZip(type: Zip) {
|
|
description = 'Creates a sources-zip of the cameraserver source files'
|
|
group = 'WPILib'
|
|
destinationDir = project.buildDir
|
|
baseName = 'cameraserver'
|
|
classifier = "sources"
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from('src') {
|
|
into 'src'
|
|
}
|
|
|
|
from('include') {
|
|
into 'include'
|
|
}
|
|
|
|
if (includeJava) {
|
|
from('java/lib') {
|
|
into 'src'
|
|
}
|
|
|
|
project(':native').jniHeadersCameraServer.outputs.each {
|
|
from(it) {
|
|
into 'include'
|
|
}
|
|
}
|
|
}
|
|
}
|