mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
304 lines
9.5 KiB
Groovy
304 lines
9.5 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
def cscoreSetupModel = { project ->
|
|
project.model {
|
|
components {
|
|
cscore(NativeLibrarySpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
//targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
|
|
if (includeJava) {
|
|
project.setupJniIncludes(binaries)
|
|
binaries.all {
|
|
project.setupDef(linker, "${rootDir}/cscore-jni.def")
|
|
}
|
|
} else {
|
|
binaries.all {
|
|
project.setupDef(linker, "${rootDir}/cscore.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.jniHeadersCscore.outputs.files.each { file ->
|
|
srcDirs file.getPath()
|
|
}
|
|
}
|
|
includes = ['**/*.h']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def cscoreSetupExamplesModel = { project ->
|
|
project.model {
|
|
components {
|
|
enum_usb(NativeExecutableSpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
//targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDir "${rootDir}/examples/enum_usb"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include"]
|
|
include '**/*.h'
|
|
}
|
|
lib library: 'cscore', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
|
|
usbstream(NativeExecutableSpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
//targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDir "${rootDir}/examples/usbstream"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include"]
|
|
include '**/*.h'
|
|
}
|
|
lib library: 'cscore', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
|
|
usbcvstream(NativeExecutableSpec) {
|
|
if (project.isArm) {
|
|
targetPlatform 'arm'
|
|
} else {
|
|
//targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
}
|
|
setupDefines(project, binaries)
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDir "${rootDir}/examples/usbcvstream"
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ["${rootDir}/include", "${rootDir}/wpiutil/include", project.openCvInclude]
|
|
include '**/*.h'
|
|
}
|
|
lib library: 'cscore', linkage: 'static'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def cscoreZipTask = { project ->
|
|
project.ext.cscoreZip = project.tasks.create("${project.isArm ? 'arm' : 'native'}CscoreZip", Zip) {
|
|
description = 'Creates platform-specific zip of the desktop cscore libraries.'
|
|
group = 'WPILib'
|
|
destinationDir = project.buildDir
|
|
baseName = 'cscore'
|
|
classifier = "${project.buildPlatform}"
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(file('include')) {
|
|
into 'include'
|
|
}
|
|
|
|
if (!project.hasProperty('skipJava')) {
|
|
project.jniHeadersCscore.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.cscoreZip
|
|
|
|
project.debugStripSetup()
|
|
|
|
project.tasks.whenTaskAdded { task ->
|
|
def name = task.name.toLowerCase()
|
|
if (name.contains("cscoresharedlibrary") || name.contains("cscorestaticlibrary") || name.contains("cscoretest")) {
|
|
project.cscoreZip.dependsOn task
|
|
}
|
|
}
|
|
}
|
|
|
|
def cscoreAthenaUberZipTask = { pjt ->
|
|
if (pjt.isArm && !project.hasProperty('compilerPrefix')) {
|
|
pjt.ext.cscoreAthenaUberZip = pjt.tasks.create("athenaCscoreUberZip", Zip) {
|
|
description = 'Create athena zip of cscore libraries including opencv'
|
|
group = 'WPILib'
|
|
destinationDir = pjt.buildDir
|
|
baseName = 'cscore'
|
|
classifier = 'athena-uberzip'
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(file('include')) {
|
|
into 'include'
|
|
}
|
|
|
|
if (!pjt.hasProperty('skipJava')) {
|
|
pjt.jniHeadersCscore.outputs.each {
|
|
from(it) {
|
|
into 'include'
|
|
}
|
|
}
|
|
}
|
|
|
|
from(file("${pjt.openCvInclude}")) {
|
|
exclude 'META-INF'
|
|
into 'include'
|
|
}
|
|
|
|
pjt.model {
|
|
def openCvPlatform = pjt.getOpenCvPlatformPackage(targetPlatform)
|
|
from(file("${pjt.openCv}/${openCvPlatform}")) {
|
|
exclude 'META-INF'
|
|
into 'lib'
|
|
}
|
|
binaries {
|
|
withType(SharedLibraryBinarySpec) { binary ->
|
|
from(binary.sharedLibraryFile) {
|
|
into 'lib'
|
|
}
|
|
from (new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
|
|
into 'lib'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pjt.build.dependsOn pjt.cscoreAthenaUberZip
|
|
|
|
pjt.tasks.whenTaskAdded { task ->
|
|
def name = task.name.toLowerCase()
|
|
if (name.contains("cscoresharedlibrary") || name.contains("cscorestaticlibrary") || name.contains("cscoretest")) {
|
|
pjt.cscoreAthenaUberZip.dependsOn task
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (buildArm) {
|
|
project(':arm') {
|
|
apply plugin: 'cpp'
|
|
|
|
apply from: "${rootDir}/toolchains/arm.gradle"
|
|
if (includeJava) {
|
|
apply from: "${rootDir}/java/java.gradle"
|
|
}
|
|
|
|
cscoreSetupModel(project)
|
|
cscoreSetupExamplesModel(project)
|
|
cscoreZipTask(project)
|
|
useWpiUtil(project)
|
|
useOpenCv(project)
|
|
cscoreAthenaUberZipTask(project)
|
|
}
|
|
}
|
|
|
|
project(':native') {
|
|
if (!OperatingSystem.current().isWindows()) {
|
|
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"
|
|
}
|
|
|
|
cscoreSetupModel(project)
|
|
cscoreSetupExamplesModel(project)
|
|
cscoreZipTask(project)
|
|
useWpiUtil(project)
|
|
useOpenCv(project)
|
|
}
|
|
}
|
|
|
|
task cscoreSourceZip(type: Zip) {
|
|
description = 'Creates a sources-zip of the cscore source files'
|
|
group = 'WPILib'
|
|
destinationDir = project.buildDir
|
|
baseName = 'cscore'
|
|
classifier = "sources"
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from('src') {
|
|
into 'src'
|
|
}
|
|
|
|
from('include') {
|
|
into 'include'
|
|
}
|
|
|
|
if (includeJava) {
|
|
from('java/lib') {
|
|
into 'src'
|
|
}
|
|
if (!OperatingSystem.current().isWindows()) {
|
|
project(':native').jniHeadersCscore.outputs.each {
|
|
from(it) {
|
|
into 'include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|