Skip to content

Commit

Permalink
[build] Fix MSVC runtime archiver to grab default runtime (wpilibsuit…
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Oct 16, 2022
1 parent fbdc810 commit 8153911
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions msvcruntime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ if (OperatingSystem.current().isWindows()) {

def vsLocator = gradle.services.get(VisualStudioLocator)

def vsLocation = vsLocator.locateAllComponents().first()
def vsLocationResult = vsLocator.locateComponent(null)

if (!vsLocationResult.available) {
return
}

def vsLocation = vsLocationResult.component

def visualCppVersion = vsLocation.visualCpp.version

def vsDirectory = vsLocation.visualStudioDir

def runtimeLocation = file("$vsDirectory\\VC\\Redist\\MSVC")

def runtimeVerNumber = null
def defaultRedistFile = file("$vsDirectory\\VC\\Auxiliary\\Build\\Microsoft.VCRedistVersion.default.txt")

runtimeLocation.eachFile {
def verNumber = VersionNumber.parse(it.name)
if (verNumber.major == visualCppVersion.major && verNumber.minor == visualCppVersion.minor) {
runtimeVerNumber = verNumber
}
if (!defaultRedistFile.exists()) {
logger.warn("Version file for VS Compiler not found")
logger.warn("Expected at $defaultRedistFile")
return
}

if (runtimeVerNumber != null) {
runtimeLocation = file("$runtimeLocation\\$runtimeVerNumber")
def expectedVersion = VersionNumber.parse(defaultRedistFile.text.trim())

def runtimeLocation = file("$vsDirectory\\VC\\Redist\\MSVC\\$expectedVersion")

if (runtimeLocation.exists()) {

def x64Folder = null

Expand Down Expand Up @@ -68,5 +74,7 @@ if (OperatingSystem.current().isWindows()) {
}
}
}
} else if (project.hasProperty('buildServer')) {
throw new GradleException("Must find a runtime in CI. Expected at $runtimeLocation")
}
}

0 comments on commit 8153911

Please sign in to comment.