mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
This PR updates everything for 2027. This includes removing GradleRIO, simplifying our wpilib version defintion, updating APIs, updating to Java 21, and more. Note that photonlibpy is failing because robotpy has not been fully updated yet. Examples are omitted because they need to be updated for our new PhotonPoseEstimator API and still need some changes from WPILIB. photonlib windows build is failing because we're waiting for some upstream changes. Finally, images are failing since they don't have Java 21 yet.
192 lines
7.1 KiB
Groovy
192 lines
7.1 KiB
Groovy
ext {
|
|
nativeName = "photontargeting"
|
|
}
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'c'
|
|
apply plugin: 'google-test-test-suite'
|
|
apply plugin: 'org.wpilib.NativeUtils'
|
|
apply plugin: 'org.photonvision.tools.WpilibTools'
|
|
apply plugin: 'org.wpilib.GradleJni'
|
|
|
|
ext.licenseFile = file("$rootDir/LICENSE")
|
|
apply from: "${rootDir}/shared/config.gradle"
|
|
apply from: "${rootDir}/shared/javacommon.gradle"
|
|
|
|
apply from: "${rootDir}/versioningHelper.gradle"
|
|
|
|
nativeUtils {
|
|
exportsConfigs {
|
|
"${nativeName}" {}
|
|
}
|
|
}
|
|
|
|
sourceSets.main.java.srcDir "${projectDir}/src/generated/main/java"
|
|
|
|
model {
|
|
components {
|
|
"${nativeName}"(NativeLibrarySpec) {
|
|
sources {
|
|
c {
|
|
source {
|
|
srcDirs 'src/main/native/cpp', "$buildDir/generated/source/proto/main/cpp", "$buildDir/generated/native/cpp"
|
|
include '**/*.c'
|
|
}
|
|
}
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/native/cpp', "$buildDir/generated/source/proto/main/cpp", 'src/generated/main/native/cpp'
|
|
include '**/*.cpp', '**/*.cc'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/main/native/include', 'src/generated/main/native/include', "$buildDir/generated/source/proto/main/cpp", 'src/generated/main/native/include'
|
|
if (project.hasProperty('generatedHeaders')) {
|
|
srcDir generatedHeaders
|
|
}
|
|
include "**/*.h"
|
|
}
|
|
}
|
|
}
|
|
|
|
binaries.all {
|
|
it.tasks.withType(CppCompile) {
|
|
it.dependsOn generateProto
|
|
}
|
|
}
|
|
|
|
nativeUtils.useRequiredLibrary(it, "wpiutil_shared")
|
|
nativeUtils.useRequiredLibrary(it, "datalog_shared")
|
|
nativeUtils.useRequiredLibrary(it, "wpimath_shared")
|
|
nativeUtils.useRequiredLibrary(it, "wpinet_shared")
|
|
nativeUtils.useRequiredLibrary(it, "ntcore_shared")
|
|
nativeUtils.useRequiredLibrary(it, "apriltag_shared")
|
|
nativeUtils.useRequiredLibrary(it, "opencv_shared")
|
|
}
|
|
"${nativeName}JNI"(JniNativeLibrarySpec) {
|
|
|
|
enableCheckTask project.hasProperty('doJniCheck')
|
|
javaCompileTasks << compileJava
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.systemcore)
|
|
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64)
|
|
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/main/native/jni'
|
|
include '**/*.cpp', '**/*.cc'
|
|
}
|
|
}
|
|
}
|
|
|
|
binaries.all {
|
|
lib library: nativeName, linkage: 'shared'
|
|
}
|
|
|
|
nativeUtils.useRequiredLibrary(it, "wpiutil_shared")
|
|
nativeUtils.useRequiredLibrary(it, "datalog_shared")
|
|
nativeUtils.useRequiredLibrary(it, "wpimath_shared")
|
|
nativeUtils.useRequiredLibrary(it, "wpinet_shared")
|
|
nativeUtils.useRequiredLibrary(it, "ntcore_shared")
|
|
nativeUtils.useRequiredLibrary(it, "cscore_shared")
|
|
nativeUtils.useRequiredLibrary(it, "opencv_shared")
|
|
}
|
|
}
|
|
testSuites {
|
|
"${nativeName}Test"(GoogleTestTestSuiteSpec) {
|
|
for(NativeComponentSpec c : $.components) {
|
|
if (c.name == nativeName) {
|
|
testing c
|
|
break
|
|
}
|
|
}
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs 'src/test/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/test/native/include', "$buildDir/generated/source/proto/main/cpp"
|
|
}
|
|
}
|
|
}
|
|
|
|
binaries.all {
|
|
lib library: nativeName, linkage: 'shared'
|
|
lib library: "${nativeName}JNI", linkage: 'shared'
|
|
it.tasks.withType(CppCompile) {
|
|
it.dependsOn generateProto
|
|
}
|
|
}
|
|
|
|
nativeUtils.useRequiredLibrary(it, "wpilib_shared")
|
|
nativeUtils.useRequiredLibrary(it, "googletest_static")
|
|
nativeUtils.useRequiredLibrary(it, "datalog_shared")
|
|
nativeUtils.useRequiredLibrary(it, "apriltag_shared")
|
|
nativeUtils.useRequiredLibrary(it, "cscore_shared")
|
|
nativeUtils.useRequiredLibrary(it, "opencv_shared")
|
|
}
|
|
}
|
|
|
|
tasks {
|
|
def c = $.testSuites
|
|
project.tasks.create('runCpp', Exec) {
|
|
description = "Run the photon-lib executable"
|
|
def found = false
|
|
def systemArch = getCurrentArch()
|
|
c.each {
|
|
if (it in GoogleTestTestSuiteSpec && it.name == "${nativeName}Test") {
|
|
it.binaries.each {
|
|
if (!found) {
|
|
def arch = it.targetPlatform.name
|
|
if (arch == systemArch) {
|
|
dependsOn it.tasks.install
|
|
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
|
|
def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib'
|
|
test.dependsOn it.tasks.install
|
|
test.systemProperty 'java.library.path', filePath
|
|
test.environment 'LD_LIBRARY_PATH', filePath
|
|
test.environment 'DYLD_LIBRARY_PATH', filePath
|
|
test.workingDir filePath
|
|
|
|
found = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/javacpp/publish.gradle"
|
|
|
|
// Add photon serde headers to our published sources
|
|
cppHeadersZip {
|
|
from('src/generated/main/native/include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
// setup wpilib bundled native libs
|
|
wpilibTools.deps.wpilibVersion = wpilibVersion
|
|
|
|
def nativeConfigName = 'wpilibNatives'
|
|
def nativeConfig = configurations.create(nativeConfigName)
|
|
|
|
def nativeTasks = wpilibTools.createExtractionTasks {
|
|
configurationName = nativeConfigName
|
|
}
|
|
|
|
nativeTasks.addToSourceSetResources(sourceSets.test)
|
|
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("datalog")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("hal")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("cscore")
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + openCVYear, openCVversion)
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag")
|