mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-02 02:51:40 +00:00
[photon-targeting] Move C++ targeting classes to photon-targetting (#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
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
* regenerated any time the publish task is run, or when this file is deleted.
|
||||
*/
|
||||
|
||||
namespace photonlib {
|
||||
namespace photon {
|
||||
namespace PhotonVersion {
|
||||
const std::string versionString = "${version}";
|
||||
const std::string buildDate = "${date}";
|
||||
|
||||
@@ -37,6 +37,7 @@ dependencies {
|
||||
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
|
||||
@@ -84,7 +85,7 @@ tasks.register('generateJavaDocs', Javadoc) {
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.9"
|
||||
toolVersion = "0.8.10"
|
||||
reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir')
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ nativeUtils.wpi.configureDependencies {
|
||||
nativeUtils.wpi.addWarnings()
|
||||
nativeUtils.wpi.addWarningsAsErrors()
|
||||
|
||||
nativeUtils.setSinglePrintPerPlatform()
|
||||
|
||||
// Enable builds for all platforms.
|
||||
model {
|
||||
components {
|
||||
@@ -34,6 +36,18 @@ model {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
task copyAllOutputs(type: Copy) {
|
||||
def outputsFolder = file("$project.buildDir/outputs")
|
||||
destinationDir outputsFolder
|
||||
}
|
||||
|
||||
ext.addTaskToCopyAllOutputs = { task ->
|
||||
copyAllOutputs.dependsOn task
|
||||
copyAllOutputs.inputs.file task.archiveFile
|
||||
copyAllOutputs.from task.archiveFile
|
||||
}
|
||||
|
||||
// Add debug path to binaries.
|
||||
ext.appendDebugPathToBinaries = { binaries ->
|
||||
binaries.withType(StaticLibraryBinarySpec) {
|
||||
@@ -69,6 +83,8 @@ ext.appendDebugPathToBinaries = { binaries ->
|
||||
}
|
||||
}
|
||||
|
||||
def licenseFile = file("$rootDir/LICENCE")
|
||||
|
||||
// Create ZIP tasks for each component.
|
||||
ext.createComponentZipTasks = { components, names, base, type, project, func ->
|
||||
def stringNames = names.collect { it.toString() }
|
||||
|
||||
115
shared/javacommon.gradle
Normal file
115
shared/javacommon.gradle
Normal file
@@ -0,0 +1,115 @@
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'jacoco'
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
def baseArtifactId = nativeName
|
||||
def artifactGroupId = 'org.photonvision'
|
||||
def javaBaseName = "_GROUP_org_photonvision_${baseArtifactId}_ID_${baseArtifactId}-java_CLS"
|
||||
|
||||
def outputsFolder = file("$buildDir/outputs")
|
||||
|
||||
javadoc {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||
archiveClassifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
archiveClassifier = 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
task outputJar(type: Jar, dependsOn: classes) {
|
||||
archiveBaseName = javaBaseName
|
||||
destinationDirectory = outputsFolder
|
||||
from sourceSets.main.output
|
||||
}
|
||||
|
||||
task outputSourcesJar(type: Jar, dependsOn: classes) {
|
||||
archiveBaseName = javaBaseName
|
||||
destinationDirectory = outputsFolder
|
||||
archiveClassifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
task outputJavadocJar(type: Jar, dependsOn: javadoc) {
|
||||
archiveBaseName = javaBaseName
|
||||
destinationDirectory = outputsFolder
|
||||
archiveClassifier = 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
archives outputJar
|
||||
archives outputSourcesJar
|
||||
archives outputJavadocJar
|
||||
}
|
||||
|
||||
addTaskToCopyAllOutputs(outputSourcesJar)
|
||||
addTaskToCopyAllOutputs(outputJavadocJar)
|
||||
addTaskToCopyAllOutputs(outputJar)
|
||||
|
||||
build.dependsOn outputSourcesJar
|
||||
build.dependsOn outputJavadocJar
|
||||
build.dependsOn outputJar
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
java(MavenPublication) {
|
||||
artifact jar
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
|
||||
artifactId = "${baseArtifactId}-java"
|
||||
groupId artifactGroupId
|
||||
version pubVersion
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url ('https://maven.photonvision.org/repository/' + (isDev ? 'snapshots' : 'internal'))
|
||||
credentials {
|
||||
username 'ghactions'
|
||||
password System.getenv("ARTIFACTORY_API_KEY")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
|
||||
testLogging {
|
||||
events "failed"
|
||||
exceptionFormat "full"
|
||||
}
|
||||
finalizedBy jacocoTestReport
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.10"
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
reports {
|
||||
xml.required = true
|
||||
html.required = true
|
||||
}
|
||||
}
|
||||
81
shared/publish.gradle
Normal file
81
shared/publish.gradle
Normal file
@@ -0,0 +1,81 @@
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
def outputsFolder = file("$buildDir/outputs")
|
||||
|
||||
def baseArtifactId = nativeName
|
||||
def artifactGroupId = 'org.photonvision'
|
||||
def zipBaseName = "_GROUP_org_photonvision_${baseArtifactId}_ID_${baseArtifactId}-cpp_CLS"
|
||||
|
||||
def licenseFile = file("$rootDir/LICENCE")
|
||||
|
||||
task cppSourcesZip(type: Zip) {
|
||||
destinationDirectory = outputsFolder
|
||||
archiveBaseName = zipBaseName
|
||||
archiveClassifier = "sources"
|
||||
|
||||
from(licenseFile) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from('src/main/native/cpp') {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
|
||||
task cppHeadersZip(type: Zip) {
|
||||
destinationDirectory = outputsFolder
|
||||
archiveBaseName = zipBaseName
|
||||
archiveClassifier = "headers"
|
||||
|
||||
from(licenseFile) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
ext.includeDirs = [
|
||||
project.file('src/main/native/include')
|
||||
]
|
||||
|
||||
ext.includeDirs.each {
|
||||
from(it) {
|
||||
into '/'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives cppHeadersZip
|
||||
archives cppSourcesZip
|
||||
}
|
||||
|
||||
addTaskToCopyAllOutputs(cppSourcesZip)
|
||||
addTaskToCopyAllOutputs(cppHeadersZip)
|
||||
|
||||
model {
|
||||
publishing {
|
||||
def taskList = createComponentZipTasks($.components, [nativeName], zipBaseName, Zip, project, includeStandardZipFormat)
|
||||
|
||||
publications {
|
||||
cpp(MavenPublication) {
|
||||
taskList.each {
|
||||
artifact it
|
||||
}
|
||||
artifact cppHeadersZip
|
||||
artifact cppSourcesZip
|
||||
|
||||
artifactId = "${baseArtifactId}-cpp"
|
||||
groupId artifactGroupId
|
||||
version pubVersion
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url ('https://maven.photonvision.org/repository/' + (isDev ? 'snapshots' : 'internal'))
|
||||
credentials {
|
||||
username 'ghactions'
|
||||
password System.getenv("ARTIFACTORY_API_KEY")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
shared/setupBuild.gradle
Normal file
76
shared/setupBuild.gradle
Normal file
@@ -0,0 +1,76 @@
|
||||
apply plugin: 'cpp'
|
||||
apply plugin: 'google-test-test-suite'
|
||||
apply plugin: 'edu.wpi.first.NativeUtils'
|
||||
|
||||
apply from: "${rootDir}/shared/config.gradle"
|
||||
apply from: "${rootDir}/shared/javacommon.gradle"
|
||||
|
||||
// Windows specific functionality to export all symbols from a binary automatically
|
||||
nativeUtils {
|
||||
exportsConfigs {
|
||||
"${nativeName}" {}
|
||||
}
|
||||
}
|
||||
|
||||
model {
|
||||
components {
|
||||
"${nativeName}"(NativeLibrarySpec) {
|
||||
sources {
|
||||
cpp {
|
||||
source {
|
||||
srcDirs 'src/main/native/cpp'
|
||||
include '**/*.cpp'
|
||||
}
|
||||
exportedHeaders {
|
||||
srcDirs 'src/main/native/include'
|
||||
include "**/*.h"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(project.hasProperty('includePhotonTargeting')) {
|
||||
binaries.all {
|
||||
lib project: ':photon-targeting', library: 'photontargeting', linkage: 'shared'
|
||||
}
|
||||
}
|
||||
|
||||
nativeUtils.useRequiredLibrary(it, "wpilib_shared")
|
||||
nativeUtils.useRequiredLibrary(it, "apriltag_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', 'src/main/native/cpp'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(project.hasProperty('includePhotonTargeting')) {
|
||||
binaries.all {
|
||||
lib project: ':photon-targeting', library: 'photontargeting', linkage: 'shared'
|
||||
}
|
||||
}
|
||||
|
||||
nativeUtils.useRequiredLibrary(it, "wpilib_executable_shared")
|
||||
nativeUtils.useRequiredLibrary(it, "googletest_static")
|
||||
nativeUtils.useRequiredLibrary(it, "apriltag_shared")
|
||||
nativeUtils.useRequiredLibrary(it, "opencv_shared")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply from: "${rootDir}/shared/publish.gradle"
|
||||
Reference in New Issue
Block a user