2020-12-30 16:17:20 -08:00
|
|
|
import org.gradle.nativeplatform.toolchain.internal.msvcpp.VisualStudioLocator
|
|
|
|
|
import org.gradle.internal.os.OperatingSystem
|
|
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
|
id 'cpp'
|
|
|
|
|
id 'maven-publish'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (OperatingSystem.current().isWindows()) {
|
|
|
|
|
def outputsFolder = file("$buildDir/outputs")
|
|
|
|
|
|
|
|
|
|
def baseArtifactId = 'runtime'
|
2025-11-07 20:00:38 -05:00
|
|
|
def artifactGroupId = "org.wpilib.msvc"
|
2026-04-27 14:46:11 -04:00
|
|
|
def zipBaseName = makeZipBaseName(artifactGroupId, baseArtifactId)
|
2020-12-30 16:17:20 -08:00
|
|
|
|
|
|
|
|
def vsLocator = gradle.services.get(VisualStudioLocator)
|
|
|
|
|
|
2022-10-16 15:37:13 -07:00
|
|
|
def vsLocationResult = vsLocator.locateComponent(null)
|
|
|
|
|
|
|
|
|
|
if (!vsLocationResult.available) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def vsLocation = vsLocationResult.component
|
2020-12-30 16:17:20 -08:00
|
|
|
|
|
|
|
|
def visualCppVersion = vsLocation.visualCpp.version
|
|
|
|
|
|
|
|
|
|
def vsDirectory = vsLocation.visualStudioDir
|
|
|
|
|
|
2022-10-16 15:37:13 -07:00
|
|
|
def defaultRedistFile = file("$vsDirectory\\VC\\Auxiliary\\Build\\Microsoft.VCRedistVersion.default.txt")
|
2020-12-30 16:17:20 -08:00
|
|
|
|
2022-10-16 15:37:13 -07:00
|
|
|
if (!defaultRedistFile.exists()) {
|
|
|
|
|
logger.warn("Version file for VS Compiler not found")
|
|
|
|
|
logger.warn("Expected at $defaultRedistFile")
|
|
|
|
|
return
|
2020-12-30 16:17:20 -08:00
|
|
|
}
|
|
|
|
|
|
2023-11-11 00:02:08 -05:00
|
|
|
def expectedVersion = defaultRedistFile.text.trim()
|
2022-10-16 15:37:13 -07:00
|
|
|
|
|
|
|
|
def runtimeLocation = file("$vsDirectory\\VC\\Redist\\MSVC\\$expectedVersion")
|
|
|
|
|
|
|
|
|
|
if (runtimeLocation.exists()) {
|
2020-12-30 16:17:20 -08:00
|
|
|
|
|
|
|
|
def x64Folder = null
|
|
|
|
|
|
|
|
|
|
file("$runtimeLocation\\x64").eachFile {
|
|
|
|
|
if (it.name.endsWith('.CRT')) {
|
|
|
|
|
x64Folder = it
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-14 22:06:18 -07:00
|
|
|
def x64ZipTask = null
|
2020-12-30 16:17:20 -08:00
|
|
|
|
2026-05-14 22:06:18 -07:00
|
|
|
if (x64Folder != null) {
|
|
|
|
|
x64ZipTask = tasks.create('x64RuntimeZip', Zip) {
|
|
|
|
|
destinationDirectory = outputsFolder
|
|
|
|
|
archiveBaseName = zipBaseName
|
|
|
|
|
archiveClassifier = 'x64'
|
|
|
|
|
|
|
|
|
|
from x64Folder
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addTaskToCopyAllOutputs(x64ZipTask)
|
|
|
|
|
build.dependsOn x64ZipTask
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def arm64Folder = null
|
2026-05-28 20:08:46 -07:00
|
|
|
def arm64Dir = file("$runtimeLocation\\arm64")
|
|
|
|
|
if (arm64Dir.exists()) {
|
|
|
|
|
arm64Dir.eachFile {
|
|
|
|
|
if (it.name.endsWith('.CRT')) {
|
|
|
|
|
arm64Folder = it
|
|
|
|
|
}
|
2026-05-14 22:06:18 -07:00
|
|
|
}
|
2020-12-30 16:17:20 -08:00
|
|
|
}
|
|
|
|
|
|
2026-05-14 22:06:18 -07:00
|
|
|
def arm64ZipTask = null
|
|
|
|
|
|
|
|
|
|
if (arm64Folder != null) {
|
|
|
|
|
arm64ZipTask = tasks.create('arm64RuntimeZip', Zip) {
|
|
|
|
|
destinationDirectory = outputsFolder
|
|
|
|
|
archiveBaseName = zipBaseName
|
|
|
|
|
archiveClassifier = 'arm64'
|
|
|
|
|
|
|
|
|
|
from arm64Folder
|
|
|
|
|
}
|
2020-12-30 16:17:20 -08:00
|
|
|
|
2026-05-14 22:06:18 -07:00
|
|
|
addTaskToCopyAllOutputs(arm64ZipTask)
|
|
|
|
|
build.dependsOn arm64ZipTask
|
|
|
|
|
}
|
2020-12-30 16:17:20 -08:00
|
|
|
|
|
|
|
|
publishing {
|
|
|
|
|
publications {
|
|
|
|
|
|
|
|
|
|
runtime(MavenPublication) {
|
2026-05-14 22:06:18 -07:00
|
|
|
if (x64ZipTask != null) {
|
|
|
|
|
artifact x64ZipTask
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (arm64ZipTask != null) {
|
|
|
|
|
artifact arm64ZipTask
|
|
|
|
|
}
|
2020-12-30 16:17:20 -08:00
|
|
|
|
|
|
|
|
artifactId = "${baseArtifactId}"
|
2025-09-20 17:59:29 -07:00
|
|
|
groupId = artifactGroupId
|
|
|
|
|
version = wpilibVersioning.version.get()
|
2020-12-30 16:17:20 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-16 15:37:13 -07:00
|
|
|
} else if (project.hasProperty('buildServer')) {
|
|
|
|
|
throw new GradleException("Must find a runtime in CI. Expected at $runtimeLocation")
|
2020-12-30 16:17:20 -08:00
|
|
|
}
|
|
|
|
|
}
|