mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
## Description Added systemcore to a couple of build files in order for `./gradlew publishToMavenLocal` to generate systemcore-compatible dependencies. Needed to support deploying photonlib to systemcore. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --------- Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
193 lines
7.2 KiB
Groovy
193 lines
7.2 KiB
Groovy
ext {
|
|
nativeName = "photontargeting"
|
|
}
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'c'
|
|
apply plugin: 'google-test-test-suite'
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
|
apply plugin: 'org.photonvision.tools.WpilibTools'
|
|
apply plugin: 'edu.wpi.first.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.linuxarm32)
|
|
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_executable_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 = wpi.versions.wpilibVersion.get()
|
|
|
|
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, wpi.versions.opencvVersion.get())
|
|
nativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag")
|