Files
PhotonVision/photon-lib/build.gradle

109 lines
3.0 KiB
Groovy
Raw Normal View History

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()
2023-10-15 13:45:30 -04:00
def read = photonlibFileInput.text
.replace('${photon_version}', pubVersion)
.replace('${frc_year}', frcYear)
photonlibFileOutput.text = read
outputs.upToDateWhen { false }
}
2023-10-15 13:45:30 -04:00
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)
}
2023-10-15 13:45:30 -04:00
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"
}
}
}
}