mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
111 lines
3.0 KiB
Groovy
111 lines
3.0 KiB
Groovy
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'
|
|
def artifactGroupId = "org.wpilib.msvc"
|
|
def zipBaseName = makeZipBaseName(artifactGroupId, baseArtifactId)
|
|
|
|
def vsLocator = gradle.services.get(VisualStudioLocator)
|
|
|
|
def vsLocationResult = vsLocator.locateComponent(null)
|
|
|
|
if (!vsLocationResult.available) {
|
|
return
|
|
}
|
|
|
|
def vsLocation = vsLocationResult.component
|
|
|
|
def visualCppVersion = vsLocation.visualCpp.version
|
|
|
|
def vsDirectory = vsLocation.visualStudioDir
|
|
|
|
def defaultRedistFile = file("$vsDirectory\\VC\\Auxiliary\\Build\\Microsoft.VCRedistVersion.default.txt")
|
|
|
|
if (!defaultRedistFile.exists()) {
|
|
logger.warn("Version file for VS Compiler not found")
|
|
logger.warn("Expected at $defaultRedistFile")
|
|
return
|
|
}
|
|
|
|
def expectedVersion = defaultRedistFile.text.trim()
|
|
|
|
def runtimeLocation = file("$vsDirectory\\VC\\Redist\\MSVC\\$expectedVersion")
|
|
|
|
if (runtimeLocation.exists()) {
|
|
|
|
def x64Folder = null
|
|
|
|
file("$runtimeLocation\\x64").eachFile {
|
|
if (it.name.endsWith('.CRT')) {
|
|
x64Folder = it
|
|
}
|
|
}
|
|
|
|
def x64ZipTask = null
|
|
|
|
if (x64Folder != null) {
|
|
x64ZipTask = tasks.create('x64RuntimeZip', Zip) {
|
|
destinationDirectory = outputsFolder
|
|
archiveBaseName = zipBaseName
|
|
archiveClassifier = 'x64'
|
|
|
|
from x64Folder
|
|
}
|
|
|
|
addTaskToCopyAllOutputs(x64ZipTask)
|
|
build.dependsOn x64ZipTask
|
|
}
|
|
|
|
def arm64Folder = null
|
|
file("$runtimeLocation\\arm64").eachFile {
|
|
if (it.name.endsWith('.CRT')) {
|
|
arm64Folder = it
|
|
}
|
|
}
|
|
|
|
def arm64ZipTask = null
|
|
|
|
if (arm64Folder != null) {
|
|
arm64ZipTask = tasks.create('arm64RuntimeZip', Zip) {
|
|
destinationDirectory = outputsFolder
|
|
archiveBaseName = zipBaseName
|
|
archiveClassifier = 'arm64'
|
|
|
|
from arm64Folder
|
|
}
|
|
|
|
addTaskToCopyAllOutputs(arm64ZipTask)
|
|
build.dependsOn arm64ZipTask
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
|
|
runtime(MavenPublication) {
|
|
if (x64ZipTask != null) {
|
|
artifact x64ZipTask
|
|
}
|
|
|
|
if (arm64ZipTask != null) {
|
|
artifact arm64ZipTask
|
|
}
|
|
|
|
artifactId = "${baseArtifactId}"
|
|
groupId = artifactGroupId
|
|
version = wpilibVersioning.version.get()
|
|
}
|
|
}
|
|
}
|
|
} else if (project.hasProperty('buildServer')) {
|
|
throw new GradleException("Must find a runtime in CI. Expected at $runtimeLocation")
|
|
}
|
|
}
|