Skip to content

Commit

Permalink
[photon-targeting] Move C++ targeting classes to photon-targetting (#…
Browse files Browse the repository at this point in the history
…1009)

* add classes to targeting and update gradle

* rename me

* Finish cleanup

* Formatting fixes

* just use common.gradle

* Update build.gradle

* Update config.gradle

* remove typo

* simplify

* Add Packet Headers

* move simulation classes into simulation folder

* draw in dependency

* fix

* Everything working minus tests cause im lazy

* formatting fixes

REMEMBER TO REMOVE UNUSED IMPORTS, IM JUST TOO LAZY TO CHECK RN

* move packet test to targeting

* Formatting fixes

* remove TargetCorner from c++

im not 100% sure but just doing std::pair<double, double> is sufficient and shouldnt conflict with protobuf

* think i added packet

* fix namespace issue

* organize imports in photon-targeting

* Formatting fixes

* remove ctors

* fix typo

* Add PNP and Multitag packet tests

* revert TargetCorner class

* Add Test placeholders

* remove annoying print

* Reorganize build and publish process

channeling inner Thad

* add targeting as flag

* Update config.gradle

* fix issue with platform binaries not building

* Update photonlib.json.in

casing still needs to be checked

* add minimum level back

* add back UTF-8 encoding of javadoc

* simplify publish model for photon-lib

* fix windows symbol generation

* formatting fixes

* move task from main gradle to config

* Update config.gradle
  • Loading branch information
srimanachanta authored Nov 19, 2023
1 parent 308fd80 commit 994ea1e
Show file tree
Hide file tree
Showing 50 changed files with 1,127 additions and 905 deletions.
147 changes: 54 additions & 93 deletions photon-lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,111 +1,73 @@
plugins {
id "java"
id 'cpp'
id "google-test-test-suite"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
}

apply plugin: "edu.wpi.first.NativeUtils"

import java.nio.file.Path

apply plugin: "edu.wpi.first.NativeUtils"
ext {
nativeName = "photonlib"
includePhotonTargeting = true
}

apply from: "${rootDir}/shared/config.gradle"
apply from: "${rootDir}/shared/setupBuild.gradle"
apply from: "${rootDir}/versioningHelper.gradle"

test {
useJUnitPlatform()
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
wpilibTools.deps.wpilibVersion = wpi.versions.wpilibVersion.get()

def nativeConfigName = 'wpilibNatives'
def nativeConfig = configurations.create(nativeConfigName)

def nativeTasks = wpilibTools.createExtractionTasks {
configurationName = nativeConfigName
}

wpilibTools.deps.wpilibVersion = wpi.versions.wpilibVersion.get()
println("Building for WPILib ${wpilibTools.deps.wpilibVersion}")
nativeTasks.addToSourceSetResources(sourceSets.main)

nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath")
nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet")
nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil")
nativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore")
nativeConfig.dependencies.add wpilibTools.deps.wpilib("cscore")
nativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag")
nativeConfig.dependencies.add wpilibTools.deps.wpilib("hal")
nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get())

// Apply Java configuration
dependencies {
implementation project(":photon-targeting")

// WPILib deps
implementation wpilibTools.deps.wpilibJava("wpiutil")
implementation wpilibTools.deps.wpilibJava("cameraserver")
implementation wpilibTools.deps.wpilibJava("cscore")
implementation wpilibTools.deps.wpilibJava("wpimath")
implementation wpilibTools.deps.wpilibJava("wpinet")
implementation wpilibTools.deps.wpilibJava("hal")
implementation wpilibTools.deps.wpilibJava("wpimath")
implementation wpilibTools.deps.wpilibJava("ntcore")
implementation wpilibTools.deps.wpilibJava("hal")
implementation wpilibTools.deps.wpilibJava("wpilibj")
implementation wpilibTools.deps.wpilibJava("apriltag")
implementation wpilibTools.deps.wpilibOpenCvJava("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get())

// Jackson
implementation group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: wpi.versions.jacksonVersion.get()
implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: wpi.versions.jacksonVersion.get()
implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: wpi.versions.jacksonVersion.get()

implementation group: "org.ejml", name: "ejml-simple", version: wpi.versions.ejmlVersion.get()
implementation group: "us.hebi.quickbuf", name: "quickbuf-runtime", version: wpi.versions.quickbufVersion.get()

// Junit
testImplementation wpilibTools.deps.wpilibJava("cscore")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
implementation group: "us.hebi.quickbuf", name: "quickbuf-runtime", version: wpi.versions.quickbufVersion.get();
}

// Set up exports properly
nativeUtils {
exportsConfigs {
// Main library is just default empty. This will export everything
Photon {
}
}
}

model {
components {
Photon(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "src/main/native/cpp"
include "**/*.cpp"
}
exportedHeaders {
srcDirs "src/main/native/include"
srcDirs "src/generate/native/include"
}
}
}
nativeUtils.useRequiredLibrary(it, "wpilib_shared")
nativeUtils.useRequiredLibrary(it, "apriltag_shared")
nativeUtils.useRequiredLibrary(it, "opencv_shared")
}
}
testSuites {
cppTest(GoogleTestTestSuiteSpec) {
testing $.components.Photon

sources.cpp {
source {
srcDir "src/test/native/cpp"
include "**/*.cpp"
}
}

nativeUtils.useRequiredLibrary(it, "wpilib_executable_shared")
nativeUtils.useRequiredLibrary(it, "apriltag_shared")
nativeUtils.useRequiredLibrary(it, "googletest_static")
nativeUtils.useRequiredLibrary(it, "opencv_shared")
}
cppHeadersZip {
from('src/generate/native/include') {
into '/'
}
}

def photonlibFileInput = file("src/generate/photonlib.json.in")
ext.photonlibFileOutput = file("$buildDir/generated/vendordeps/photonlib.json")

def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))

task generateVendorJson() {
description = "Generates the vendor JSON file"
group = "PhotonVision"
Expand Down Expand Up @@ -141,29 +103,28 @@ task writeCurrentVersion {

build.mustRunAfter writeCurrentVersion

tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
}

apply from: "publish.gradle"

def testNativeConfigName = 'wpilibTestNatives'
def testNativeConfig = configurations.create(testNativeConfigName)
model {
components {
all {
it.sources.each {
it.exportedHeaders {
srcDirs "src/main/native/include"
srcDirs "src/generate/native/include"
}
}
}
}

def folder = project.layout.buildDirectory.dir('NativeTest')
// Publish the vendordep json
publishing {
publications {
vendorjson(MavenPublication) {
artifact vendorJson

def testNativeTasks = wpilibTools.createExtractionTasks {
taskPostfix = "Test"
configurationName = testNativeConfigName
rootTaskFolder.set(folder)
artifactId = "${nativeName}-json"
groupId = "org.photonvision"
version "1.0"
}
}
}
}

testNativeTasks.addToSourceSetResources(sourceSets.test)

testNativeConfig.dependencies.add wpilibTools.deps.wpilib("cscore")
testNativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore")
testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet")
testNativeConfig.dependencies.add wpilibTools.deps.wpilib("hal")
testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil")
testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath")
testNativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get())
Loading

0 comments on commit 994ea1e

Please sign in to comment.