Skip to content

Commit

Permalink
[build] Gradle Cleanup (#1021)
Browse files Browse the repository at this point in the history
Cleanup project-wide gradle configuration.

    removes native dependencies from java only projects
    increases readability
    Pass generated headers in setup instead of modifying model
  • Loading branch information
srimanachanta authored Nov 23, 2023
1 parent 5d93515 commit 773c635
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 293 deletions.
12 changes: 4 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ apply from: "versioningHelper.gradle"

ext {
wpilibVersion = "2024.1.1-beta-3"
wpimathVersion = wpilibVersion
openCVversion = "4.8.0-2"
joglVersion = "2.4.0-rc-20200307"
javalinVersion = "5.6.2"
Expand All @@ -36,16 +37,11 @@ ext {
if (nativeName == "macx64") nativeName = "osxx86-64";
if (nativeName == "macarm64") nativeName = "osxarm64";
jniPlatform = nativeName
println("Building for platform " + jniPlatform)
println("Building for platform: " + jniPlatform)
println("Using Wpilib: " + wpilibVersion)
println("Using OpenCV: " + openCVversion)
}

wpilibTools.deps.wpilibVersion = wpilibVersion

// Tell gradlerio what version of things to use (that we care about)
// See: https://github.com/wpilibsuite/GradleRIO/blob/main/src/main/java/edu/wpi/first/gradlerio/wpi/WPIVersionsExtension.java
wpi.getVersions().getOpencvVersion().convention(openCVversion);
wpi.getVersions().getWpilibVersion().convention(wpilibVersion);

spotless {
java {
target fileTree('.') {
Expand Down
18 changes: 2 additions & 16 deletions photon-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
plugins {
id 'edu.wpi.first.WpilibTools' version '1.3.0'
}

import java.nio.file.Path

apply from: "${rootDir}/shared/common.gradle"

dependencies {
implementation project(':photon-targeting')

implementation "io.javalin:javalin:$javalinVersion"

implementation 'org.msgpack:msgpack-core:0.9.0'
implementation 'org.msgpack:jackson-dataformat-msgpack:0.9.0'

// JOGL stuff (currently we only distribute for aarch64, which is Pi 4)
implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion"
implementation "org.jogamp.jogl:jogl-all:$joglVersion"

implementation "org.jogamp.gluegen:gluegen-rt:$joglVersion:natives-linux-aarch64"
implementation "org.jogamp.jogl:jogl-all:$joglVersion:natives-linux-aarch64"

// Zip
implementation 'org.zeroturnaround:zt-zip:1.14'

implementation wpilibTools.deps.wpilibJava("apriltag")

implementation "org.xerial:sqlite-jdbc:3.41.0.0"
}

task writeCurrentVersionJava {
task writeCurrentVersion {
def versionFileIn = file("${rootDir}/shared/PhotonVersion.java.in")
writePhotonVersionFile(versionFileIn, Path.of("$projectDir", "src", "main", "java", "org", "photonvision", "PhotonVersion.java"),
versionString)
}

build.dependsOn writeCurrentVersionJava
build.dependsOn writeCurrentVersion
63 changes: 6 additions & 57 deletions photon-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,14 @@ import java.nio.file.Path
ext {
nativeName = "photonlib"
includePhotonTargeting = true
// Include the generated Version file
generatedHeaders = "src/generate/native/include"
}

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


wpilibTools.deps.wpilibVersion = wpi.versions.wpilibVersion.get()

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

def nativeTasks = wpilibTools.createExtractionTasks {
configurationName = nativeConfigName
}

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())

dependencies {
implementation project(":photon-targeting")

implementation wpilibTools.deps.wpilibJava("wpiutil")
implementation wpilibTools.deps.wpilibJava("cameraserver")
implementation wpilibTools.deps.wpilibJava("cscore")
implementation wpilibTools.deps.wpilibJava("wpinet")
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())

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();
}

// Include the version file in the distributed sources
cppHeadersZip {
from('src/generate/native/include') {
into '/'
Expand All @@ -66,8 +26,6 @@ cppHeadersZip {
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 @@ -103,18 +61,9 @@ task writeCurrentVersion {

build.mustRunAfter writeCurrentVersion

model {
components {
all {
it.sources.each {
it.exportedHeaders {
srcDirs "src/main/native/include"
srcDirs "src/generate/native/include"
}
}
}
}
def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))

model {
// Publish the vendordep json
publishing {
publications {
Expand Down
53 changes: 0 additions & 53 deletions photon-lib/src/main/driver/cpp/VendorJNI.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions photon-lib/src/main/driver/cpp/driversource.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions photon-lib/src/main/driver/include/driverheader.h

This file was deleted.

4 changes: 0 additions & 4 deletions photon-lib/src/main/driver/symbols.txt

This file was deleted.

34 changes: 10 additions & 24 deletions photon-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,20 @@ plugins {
id 'edu.wpi.first.WpilibTools' version '1.3.0'
}

evaluationDependsOn(':photon-core')

mainClassName = 'org.photonvision.Main'

group 'org.photonvision'
version versionString + (project.hasProperty('pionly') ? "-raspi" : "")

apply from: "${rootDir}/shared/common.gradle"

dependencies {
implementation project(':photon-core')
implementation project(':photon-targeting')

implementation "io.javalin:javalin:$javalinVersion"
// Needed for Javalin Runtime Logging
implementation "org.slf4j:slf4j-simple:2.0.7"
}

implementation wpilibTools.deps.wpilibJava("wpiutil")
implementation wpilibTools.deps.wpilibJava("wpimath")
implementation wpilibTools.deps.wpilibJava("wpinet")
implementation wpilibTools.deps.wpilibJava("hal")
implementation wpilibTools.deps.wpilibJava("ntcore")
implementation wpilibTools.deps.wpilibJava("wpilibj")
implementation wpilibTools.deps.wpilibOpenCv("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get())
group 'org.photonvision'
version versionString + (project.hasProperty('pionly') ? "-raspi" : "")

implementation "org.msgpack:msgpack-core:0.9.0"
implementation "org.msgpack:jackson-dataformat-msgpack:0.9.0"
application {
mainClass = 'org.photonvision.Main'
}

shadowJar {
Expand All @@ -43,7 +31,6 @@ shadowJar {
]
}


node {
nodeProjectDir = file("${projectDir}/../photon-client")
}
Expand All @@ -58,6 +45,10 @@ tasks.register("buildAndCopyUI") {
finalizedBy "copyClientUIToResources"
}

run {
environment "PATH_PREFIX", "../"
}

run {
if (project.hasProperty("profile")) {
jvmArgs=[
Expand All @@ -70,7 +61,6 @@ run {
}
}


remotes {
pi {
host = 'photonvision.local'
Expand Down Expand Up @@ -119,10 +109,6 @@ task findDeployTarget {
}
}

run {
environment "PATH_PREFIX", "../"
}

task deploy {
dependsOn findDeployTarget
dependsOn assemble
Expand Down
Loading

0 comments on commit 773c635

Please sign in to comment.