2022-12-16 17:05:23 -08:00
|
|
|
plugins {
|
2023-10-25 20:27:56 -04:00
|
|
|
id 'edu.wpi.first.WpilibTools' version '1.3.0'
|
2022-12-16 17:05:23 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-19 15:16:22 -05:00
|
|
|
apply plugin: "edu.wpi.first.NativeUtils"
|
|
|
|
|
|
2021-10-18 22:31:18 -04:00
|
|
|
import java.nio.file.Path
|
|
|
|
|
|
2023-11-19 15:16:22 -05:00
|
|
|
ext {
|
|
|
|
|
nativeName = "photonlib"
|
|
|
|
|
includePhotonTargeting = true
|
2023-11-22 20:08:23 -05:00
|
|
|
// Include the generated Version file
|
|
|
|
|
generatedHeaders = "src/generate/native/include"
|
2023-11-19 15:16:22 -05:00
|
|
|
}
|
2021-01-16 20:41:47 -08:00
|
|
|
|
2023-11-22 20:08:23 -05:00
|
|
|
apply from: "${rootDir}/shared/javacpp/setupBuild.gradle"
|
2021-10-18 22:31:18 -04:00
|
|
|
apply from: "${rootDir}/versioningHelper.gradle"
|
2021-01-16 20:41:47 -08:00
|
|
|
|
2023-11-22 20:08:23 -05:00
|
|
|
// Include the version file in the distributed sources
|
2023-11-19 15:16:22 -05:00
|
|
|
cppHeadersZip {
|
|
|
|
|
from('src/generate/native/include') {
|
|
|
|
|
into '/'
|
2021-01-16 20:41:47 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def photonlibFileInput = file("src/generate/photonlib.json.in")
|
|
|
|
|
ext.photonlibFileOutput = file("$buildDir/generated/vendordeps/photonlib.json")
|
|
|
|
|
|
|
|
|
|
task generateVendorJson() {
|
2021-01-18 22:12:57 -05:00
|
|
|
description = "Generates the vendor JSON file"
|
|
|
|
|
group = "PhotonVision"
|
2021-01-16 20:41:47 -08:00
|
|
|
|
2021-01-18 22:12:57 -05:00
|
|
|
outputs.file photonlibFileOutput
|
|
|
|
|
inputs.file photonlibFileInput
|
2021-01-16 20:41:47 -08:00
|
|
|
|
2023-10-24 23:02:59 -04:00
|
|
|
println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput"
|
2021-01-16 20:41:47 -08:00
|
|
|
|
2023-10-24 23:02:59 -04:00
|
|
|
if (photonlibFileOutput.exists()) {
|
|
|
|
|
photonlibFileOutput.delete()
|
|
|
|
|
}
|
|
|
|
|
photonlibFileOutput.parentFile.mkdirs()
|
2023-10-15 13:45:30 -04:00
|
|
|
|
2023-10-24 23:02:59 -04:00
|
|
|
def read = photonlibFileInput.text
|
2023-10-15 12:17:40 -04:00
|
|
|
.replace('${photon_version}', pubVersion)
|
|
|
|
|
.replace('${frc_year}', frcYear)
|
2023-10-24 23:02:59 -04:00
|
|
|
photonlibFileOutput.text = read
|
2022-11-13 15:07:15 -05:00
|
|
|
|
|
|
|
|
outputs.upToDateWhen { false }
|
2021-01-16 20:41:47 -08:00
|
|
|
}
|
|
|
|
|
|
2023-10-15 13:45:30 -04:00
|
|
|
build.mustRunAfter generateVendorJson
|
2021-10-18 22:31:18 -04:00
|
|
|
|
2022-01-24 12:38:45 -05:00
|
|
|
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"),
|
2021-10-18 22:31:18 -04:00
|
|
|
versionString)
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-15 13:45:30 -04:00
|
|
|
build.mustRunAfter writeCurrentVersion
|
2021-10-18 22:31:18 -04:00
|
|
|
|
2023-11-22 20:08:23 -05:00
|
|
|
def vendorJson = artifacts.add('archives', file("$photonlibFileOutput"))
|
2022-12-16 17:05:23 -08:00
|
|
|
|
2023-11-22 20:08:23 -05:00
|
|
|
model {
|
2023-11-19 15:16:22 -05:00
|
|
|
// Publish the vendordep json
|
|
|
|
|
publishing {
|
|
|
|
|
publications {
|
|
|
|
|
vendorjson(MavenPublication) {
|
|
|
|
|
artifact vendorJson
|
2022-12-16 17:05:23 -08:00
|
|
|
|
2023-11-19 15:16:22 -05:00
|
|
|
artifactId = "${nativeName}-json"
|
|
|
|
|
groupId = "org.photonvision"
|
|
|
|
|
version "1.0"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-16 17:05:23 -08:00
|
|
|
}
|