mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
## Description Added systemcore to a couple of build files in order for `./gradlew publishToMavenLocal` to generate systemcore-compatible dependencies. Needed to support deploying photonlib to systemcore. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added --------- Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
180 lines
6.8 KiB
Groovy
180 lines
6.8 KiB
Groovy
// Configure Native-Utils WPI Plugin
|
|
nativeUtils.addWpiNativeUtils()
|
|
nativeUtils.withCrossLinuxArm32()
|
|
nativeUtils.withCrossLinuxArm64()
|
|
nativeUtils.withCrossSystemCore()
|
|
|
|
// Configure WPI dependencies.
|
|
nativeUtils.wpi.configureDependencies {
|
|
wpiVersion = wpilibVersion
|
|
wpimathVersion = wpimathVersion
|
|
opencvYear = 'frc'+openCVYear
|
|
opencvVersion = openCVversion
|
|
niLibVersion = "2026.1.0"
|
|
}
|
|
|
|
// Configure warnings and errors
|
|
nativeUtils.wpi.addWarnings()
|
|
nativeUtils.wpi.addWarningsAsErrors()
|
|
|
|
nativeUtils.setSinglePrintPerPlatform()
|
|
|
|
def externalLicensesFolder = file("$rootDir/ExternalLicenses")
|
|
|
|
// Enable builds for all platforms.
|
|
model {
|
|
components {
|
|
all {
|
|
nativeUtils.useAllPlatforms(it)
|
|
}
|
|
}
|
|
binaries {
|
|
withType(NativeBinarySpec).all {
|
|
nativeUtils.usePlatformArguments(it)
|
|
if (it.toolChain instanceof GccCompatibleToolChain) {
|
|
it.cppCompiler.args << "-Wno-deprecated-enum-enum-conversion"
|
|
|
|
if (project.hasProperty('withSanitizers')) {
|
|
println("Adding asan/usan/lsan to " + it)
|
|
it.cppCompiler.args << "-fsanitize=address,undefined,leak" << "-g"
|
|
it.linker.args << "-fsanitize=address,undefined,leak"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
task copyAllOutputs(type: Copy) {
|
|
def outputsFolder = file("$project.buildDir/outputs")
|
|
destinationDir = outputsFolder
|
|
}
|
|
|
|
ext.addTaskToCopyAllOutputs = { task ->
|
|
copyAllOutputs.dependsOn task
|
|
copyAllOutputs.inputs.file task.archiveFile
|
|
copyAllOutputs.from task.archiveFile
|
|
}
|
|
|
|
// Add debug path to binaries.
|
|
ext.appendDebugPathToBinaries = { binaries ->
|
|
binaries.withType(StaticLibraryBinarySpec) {
|
|
if (it.buildType.name.contains('debug')) {
|
|
def staticFileDir = it.staticLibraryFile.parentFile
|
|
def staticFileName = it.staticLibraryFile.name
|
|
def staticFileExtension = staticFileName.substring(staticFileName.lastIndexOf('.'))
|
|
staticFileName = staticFileName.substring(0, staticFileName.lastIndexOf('.'))
|
|
staticFileName = staticFileName + 'd' + staticFileExtension
|
|
def newStaticFile = new File(staticFileDir, staticFileName)
|
|
it.staticLibraryFile = newStaticFile
|
|
}
|
|
}
|
|
binaries.withType(SharedLibraryBinarySpec) {
|
|
if (it.buildType.name.contains('debug')) {
|
|
def sharedFileDir = it.sharedLibraryFile.parentFile
|
|
def sharedFileName = it.sharedLibraryFile.name
|
|
def sharedFileExtension = sharedFileName.substring(sharedFileName.lastIndexOf('.'))
|
|
sharedFileName = sharedFileName.substring(0, sharedFileName.lastIndexOf('.'))
|
|
sharedFileName = sharedFileName + 'd' + sharedFileExtension
|
|
def newSharedFile = new File(sharedFileDir, sharedFileName)
|
|
|
|
def sharedLinkFileDir = it.sharedLibraryLinkFile.parentFile
|
|
def sharedLinkFileName = it.sharedLibraryLinkFile.name
|
|
def sharedLinkFileExtension = sharedLinkFileName.substring(sharedLinkFileName.lastIndexOf('.'))
|
|
sharedLinkFileName = sharedLinkFileName.substring(0, sharedLinkFileName.lastIndexOf('.'))
|
|
sharedLinkFileName = sharedLinkFileName + 'd' + sharedLinkFileExtension
|
|
def newLinkFile = new File(sharedLinkFileDir, sharedLinkFileName)
|
|
|
|
it.sharedLibraryLinkFile = newLinkFile
|
|
it.sharedLibraryFile = newSharedFile
|
|
}
|
|
}
|
|
}
|
|
|
|
// Create ZIP tasks for each component.
|
|
ext.createComponentZipTasks = { components, names, base, type, project, func ->
|
|
def stringNames = names.collect { it.toString() }
|
|
def configMap = [:]
|
|
components.each {
|
|
if (it in NativeLibrarySpec && stringNames.contains(it.name)) {
|
|
it.binaries.each {
|
|
if (!it.buildable) return
|
|
def target = nativeUtils.getPublishClassifier(it)
|
|
if (configMap.containsKey(target)) {
|
|
configMap.get(target).add(it)
|
|
} else {
|
|
configMap.put(target, [])
|
|
configMap.get(target).add(it)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
def taskList = []
|
|
def outputsFolder = file("$project.buildDir/outputs")
|
|
configMap.each { key, value ->
|
|
def task = project.tasks.create(base + "-${key}", type) {
|
|
description = 'Creates component archive for platform ' + key
|
|
destinationDirectory = outputsFolder
|
|
archiveClassifier = key
|
|
archiveBaseName = base
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
from(externalLicensesFolder) {
|
|
into '/'
|
|
}
|
|
|
|
func(it, value)
|
|
}
|
|
taskList.add(task)
|
|
|
|
project.build.dependsOn task
|
|
|
|
// If the zip artifact matches the platform we're building for (either host or whatever the ArchOverride is), and it's a shared library built in release mode, add it to the list of artifacts the project exposes for use
|
|
if (key.contains(wpilibTools.getPlatformMapper().getWpilibClassifier()) && !key.contains("debug") && !key.contains("static")) {
|
|
// For more information, see https://docs.gradle.org/current/userguide/variant_model.html and the outgoingVariants task
|
|
project.artifacts.add("wpilibNatives", task)
|
|
} else {
|
|
project.artifacts {
|
|
task
|
|
}
|
|
}
|
|
addTaskToCopyAllOutputs(task)
|
|
}
|
|
return taskList
|
|
}
|
|
|
|
// Create the standard ZIP format for the dependencies.
|
|
ext.includeStandardZipFormat = { task, value ->
|
|
value.each { binary ->
|
|
if (binary.buildable) {
|
|
if (binary instanceof SharedLibraryBinarySpec) {
|
|
task.dependsOn binary.tasks.link
|
|
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
|
|
into nativeUtils.getPlatformPath(binary) + '/shared'
|
|
}
|
|
def sharedPath = binary.sharedLibraryFile.absolutePath
|
|
sharedPath = sharedPath.substring(0, sharedPath.length() - 4)
|
|
|
|
task.from(new File(sharedPath + '.pdb')) {
|
|
into nativeUtils.getPlatformPath(binary) + '/shared'
|
|
}
|
|
task.from(binary.sharedLibraryFile) {
|
|
into nativeUtils.getPlatformPath(binary) + '/shared'
|
|
}
|
|
task.from(binary.sharedLibraryLinkFile) {
|
|
into nativeUtils.getPlatformPath(binary) + '/shared'
|
|
}
|
|
} else if (binary instanceof StaticLibraryBinarySpec) {
|
|
task.dependsOn binary.tasks.createStaticLib
|
|
task.from(binary.staticLibraryFile) {
|
|
into nativeUtils.getPlatformPath(binary) + '/static'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|