mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
207 lines
7.2 KiB
Groovy
207 lines
7.2 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
nativeUtils.skipInstallPdb = project.hasProperty('buildServer')
|
|
|
|
if (project.hasProperty('ciDebugOnly')) {
|
|
toolchainsPlugin.registerReleaseBuildType = false
|
|
}
|
|
|
|
nativeUtils.addWpiNativeUtils()
|
|
nativeUtils.withCrossRoboRIO()
|
|
nativeUtils.withCrossLinuxArm32()
|
|
nativeUtils.withCrossLinuxArm64()
|
|
nativeUtils {
|
|
wpi {
|
|
configureDependencies {
|
|
wpiVersion = "-1"
|
|
niLibVersion = "2023.1.0"
|
|
opencvVersion = "4.6.0-2"
|
|
googleTestVersion = "1.11.0-3"
|
|
imguiVersion = "1.88-8"
|
|
wpimathVersion = "-1"
|
|
}
|
|
}
|
|
}
|
|
|
|
nativeUtils.wpi.addWarnings()
|
|
nativeUtils.wpi.addWarningsAsErrors()
|
|
|
|
if (project.name != 'wpilibcExamples') {
|
|
nativeUtils.wpi.addReleaseSymbolGeneration()
|
|
}
|
|
|
|
nativeUtils.setSinglePrintPerPlatform()
|
|
nativeUtils.enableSourceLink()
|
|
|
|
nativeUtils.platformConfigs.each {
|
|
if (it.name.contains('windows')) {
|
|
it.cppCompiler.args.remove("/std:c++17")
|
|
it.cppCompiler.args.add("/std:c++20")
|
|
return
|
|
} else if (it.name == 'linuxx86-64' || it.name == 'osxx86-64' || it.name == 'osxarm64') {
|
|
it.cppCompiler.args.remove("-std=c++17")
|
|
it.cppCompiler.args.add("-std=c++20")
|
|
}
|
|
if (it.name.contains('osx')) {
|
|
it.linker.args << '-Wl,-rpath,\'@loader_path\''
|
|
it.linker.args << "-headerpad_max_install_names"
|
|
} else {
|
|
it.linker.args << '-Wl,-rpath,\'$ORIGIN\''
|
|
}
|
|
}
|
|
|
|
// Suppress OpenCV warning
|
|
// https://github.com/opencv/opencv/issues/20269
|
|
nativeUtils.platformConfigs.each {
|
|
if (it.name == nativeUtils.wpi.platforms.linuxx64) {
|
|
it.cppCompiler.args.add("-Wno-deprecated-enum-enum-conversion")
|
|
} else if (it.name.contains('osx')) {
|
|
it.cppCompiler.args.add("-Wno-deprecated-anon-enum-enum-conversion")
|
|
}
|
|
}
|
|
|
|
nativeUtils.platformConfigs.linuxathena.linker.args.add("-Wl,--fatal-warnings")
|
|
|
|
model {
|
|
components {
|
|
all {
|
|
nativeUtils.useAllPlatforms(it)
|
|
}
|
|
}
|
|
binaries {
|
|
withType(NativeBinarySpec).all {
|
|
nativeUtils.usePlatformArguments(it)
|
|
}
|
|
}
|
|
}
|
|
|
|
apply plugin: DisableBuildingGTest
|
|
|
|
if (project.hasProperty('buildServer')) {
|
|
tasks.withType(org.gradle.nativeplatform.test.tasks.RunTestExecutable) {
|
|
def exeFile = file(it.executable)
|
|
def folder = exeFile.parentFile
|
|
|
|
it.doLast {
|
|
folder.deleteDir()
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
classifier = key
|
|
archiveBaseName = '_M_' + base
|
|
duplicatesStrategy = 'exclude'
|
|
|
|
from(licenseFile) {
|
|
into '/'
|
|
}
|
|
|
|
func(it, value)
|
|
}
|
|
taskList.add(task)
|
|
|
|
project.build.dependsOn task
|
|
|
|
project.artifacts {
|
|
task
|
|
}
|
|
addTaskToCopyAllOutputs(task)
|
|
}
|
|
return taskList
|
|
}
|
|
|
|
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'
|
|
}
|
|
def pdbDir = binary.staticLibraryFile.parentFile
|
|
task.from(pdbDir) {
|
|
include '*.pdb'
|
|
into nativeUtils.getPlatformPath(binary) + '/static'
|
|
}
|
|
task.from(new File(pdbDir, "SourceLink.json")) {
|
|
into nativeUtils.getPlatformPath(binary) + '/static'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|