Skip to content

Commit

Permalink
Merge branch 'master' into popout
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 authored Nov 20, 2023
2 parents 16b11e2 + 586adeb commit c785504
Show file tree
Hide file tree
Showing 52 changed files with 1,129 additions and 907 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
path: build/html
build-photonlib-host:
env:
MACOSX_DEPLOYMENT_TARGET: 11
MACOSX_DEPLOYMENT_TARGET: 12
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "com.diffplug.spotless" version "6.22.0"
id "edu.wpi.first.NativeUtils" version "2024.2.0" apply false
id "edu.wpi.first.NativeUtils" version "2024.3.2" apply false
id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2"
id "edu.wpi.first.GradleRIO" version "2024.1.1-beta-3"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
Expand Down
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 c785504

Please sign in to comment.