Files
allwpilib/shared/config.gradle

217 lines
7.4 KiB
Groovy
Raw Normal View History

nativeUtils.skipInstallPdb = project.hasProperty('buildServer')
if (project.hasProperty('ciDebugOnly')) {
toolchainsPlugin.registerReleaseBuildType = false
}
nativeUtils.addWpiNativeUtils()
nativeUtils.withCrossLinuxArm64()
nativeUtils.withCrossSystemCore()
nativeUtils {
wpi {
configureDependencies {
opencvVersion = libs.versions.opencv
}
2018-05-13 19:37:20 -07:00
}
}
if (project.hasProperty('onlylinuxarm64')) {
nativeUtils.crossCompilers.getByName(org.wpilib.toolchain.NativePlatforms.linuxarm64).optional = false
}
if (project.hasProperty('onlylinuxsystemcore')) {
nativeUtils.crossCompilers.getByName(org.wpilib.toolchain.NativePlatforms.systemcore).optional = false
}
nativeUtils.wpi.addWarnings()
nativeUtils.wpi.addWarningsAsErrors()
if (project.name != 'wpilibcExamples') {
nativeUtils.wpi.addReleaseSymbolGeneration()
}
2018-05-13 19:37:20 -07:00
nativeUtils.setSinglePrintPerPlatform()
nativeUtils.enableSourceLink()
nativeUtils.wpi.addMacMinimumVersionArg()
nativeUtils.platformConfigs.each {
if (it.name.contains('osx')) {
it.linker.getArgs().add('-framework')
it.linker.getArgs().add('IOKit')
}
}
nativeUtils.platformConfigs.each {
if (it.name.contains('linux')) {
// Compress debug info on Linux
it.cppCompiler.debugArgs.add("-gz=zlib")
// Make warning in OpenCV 4.10 from GCC 15 not an error
it.cppCompiler.args.add("-Wno-error=overloaded-virtual")
// Make warning from Google Benchmark not an error
it.cppCompiler.args.add("-Wno-error=restrict")
}
}
nativeUtils.platformConfigs.linuxsystemcore.linker.args.add("-Wl,--fatal-warnings")
if (project.hasProperty('ntcoreffibuild')) {
// On windows, for ntcoreffi, use static runtime
nativeUtils.platformConfigs.each {
if (it.name.contains('windows')) {
it.cCompiler.releaseArgs.remove('/MD')
it.cppCompiler.releaseArgs.remove('/MD')
it.cCompiler.debugArgs.remove('/MDd')
it.cppCompiler.debugArgs.remove('/MDd')
it.cCompiler.releaseArgs.add('/MT')
it.cppCompiler.releaseArgs.add('/MT')
it.cCompiler.debugArgs.add('/MTd')
it.cppCompiler.debugArgs.add('/MTd')
}
}
}
model {
components {
all {
nativeUtils.useAllPlatforms(it)
2018-05-13 19:37:20 -07:00
}
}
binaries {
withType(NativeBinarySpec).all {
nativeUtils.usePlatformArguments(it)
2018-05-13 19:37:20 -07:00
}
}
}
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()}
2018-05-13 19:37:20 -07:00
def configMap = [:]
components.each {
if (it in NativeLibrarySpec && stringNames.contains(it.name)) {
2018-05-13 19:37:20 -07:00
it.binaries.each {
if (!it.buildable) return
def target = nativeUtils.getPublishClassifier(it)
2018-05-13 19:37:20 -07:00
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
2019-11-12 17:14:04 -08:00
destinationDirectory = outputsFolder
2023-05-12 21:27:31 -07:00
archiveClassifier = key
archiveBaseName = base
2018-05-13 19:37:20 -07:00
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
2018-05-13 19:37:20 -07:00
task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) {
into nativeUtils.getPlatformPath(binary) + '/shared'
2018-05-13 19:37:20 -07:00
}
def sharedPath = binary.sharedLibraryFile.absolutePath
sharedPath = sharedPath.substring(0, sharedPath.length() - 4)
task.from(new File(sharedPath + '.pdb')) {
into nativeUtils.getPlatformPath(binary) + '/shared'
}
2018-05-13 19:37:20 -07:00
task.from(binary.sharedLibraryFile) {
into nativeUtils.getPlatformPath(binary) + '/shared'
2018-05-13 19:37:20 -07:00
}
task.from(binary.sharedLibraryLinkFile) {
into nativeUtils.getPlatformPath(binary) + '/shared'
2018-05-13 19:37:20 -07:00
}
} else if (binary instanceof StaticLibraryBinarySpec) {
task.dependsOn binary.tasks.createStaticLib
2018-05-13 19:37:20 -07:00
task.from(binary.staticLibraryFile) {
into nativeUtils.getPlatformPath(binary) + '/static'
2018-05-13 19:37:20 -07:00
}
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'
}
2018-05-13 19:37:20 -07:00
}
}
}
}