mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Allows logging software and live data view to see results. Also removes the requirement for AScope to keep up with the packet serde schema and instead just use the Protobuf descriptor.
109 lines
3.0 KiB
Groovy
109 lines
3.0 KiB
Groovy
plugins {
|
|
id 'edu.wpi.first.WpilibTools' version '1.3.0'
|
|
}
|
|
|
|
apply plugin: "edu.wpi.first.NativeUtils"
|
|
|
|
import java.nio.file.Path
|
|
|
|
ext {
|
|
nativeName = "photonlib"
|
|
includePhotonTargeting = true
|
|
// Include the generated Version file
|
|
generatedHeaders = "src/generate/native/include"
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/javacpp/setupBuild.gradle"
|
|
apply from: "${rootDir}/versioningHelper.gradle"
|
|
|
|
// Include the version file in the distributed sources
|
|
cppHeadersZip {
|
|
from('src/generate/native/include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
def photonlibFileInput = file("src/generate/photonlib.json.in")
|
|
ext.photonlibFileOutput = file("$buildDir/generated/vendordeps/photonlib.json")
|
|
|
|
task generateVendorJson() {
|
|
description = "Generates the vendor JSON file"
|
|
group = "PhotonVision"
|
|
|
|
outputs.file photonlibFileOutput
|
|
inputs.file photonlibFileInput
|
|
|
|
println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput"
|
|
|
|
if (photonlibFileOutput.exists()) {
|
|
photonlibFileOutput.delete()
|
|
}
|
|
photonlibFileOutput.parentFile.mkdirs()
|
|
|
|
def read = photonlibFileInput.text
|
|
.replace('${photon_version}', pubVersion)
|
|
.replace('${frc_year}', frcYear)
|
|
photonlibFileOutput.text = read
|
|
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
build.mustRunAfter generateVendorJson
|
|
|
|
task writeCurrentVersion {
|
|
def versionFileIn = file("${rootDir}/shared/PhotonVersion.java.in")
|
|
writePhotonVersionFile(versionFileIn, Path.of("$projectDir", "src", "main", "java", "org", "photonvision", "PhotonVersion.java"),
|
|
versionString)
|
|
versionFileIn = file("${rootDir}/shared/PhotonVersion.h.in")
|
|
writePhotonVersionFile(versionFileIn, Path.of("$projectDir", "src", "generate", "native", "include", "PhotonVersion.h"),
|
|
versionString)
|
|
}
|
|
|
|
build.mustRunAfter writeCurrentVersion
|
|
cppHeadersZip.dependsOn writeCurrentVersion
|
|
|
|
// Building photon-lib requires photon-targeting to generate its proto files. This technically shouldn't be required but is needed for it to build.
|
|
model {
|
|
components {
|
|
all {
|
|
it.sources.each {
|
|
it.exportedHeaders {
|
|
srcDirs "src/main/native/include"
|
|
srcDirs "src/generate/native/include"
|
|
}
|
|
}
|
|
it.binaries.all {
|
|
it.tasks.withType(CppCompile) {
|
|
it.dependsOn ":photon-targeting:generateProto"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
testSuites {
|
|
all {
|
|
it.binaries.all {
|
|
it.tasks.withType(CppCompile) {
|
|
it.dependsOn ":photon-targeting:generateProto"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))
|
|
|
|
model {
|
|
// Publish the vendordep json
|
|
publishing {
|
|
publications {
|
|
vendorjson(MavenPublication) {
|
|
artifact vendorJson
|
|
|
|
artifactId = "${nativeName}-json"
|
|
groupId = "org.photonvision"
|
|
version "1.0"
|
|
}
|
|
}
|
|
}
|
|
}
|