Merge remote-tracking branch 'origin/Ghidra_12.0'

This commit is contained in:
Ryan Kurtz
2025-10-06 06:13:56 -04:00
+32 -13
View File
@@ -9,13 +9,7 @@
* and SDKs are installed. * and SDKs are installed.
****************************************************************************/ ****************************************************************************/
if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR")) { if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR") && isCurrentWindows()) {
configureVisualStudio()
}
def configureVisualStudio() {
if (isCurrentWindows()) {
// Initialize variables // Initialize variables
rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = "" rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = ""
@@ -34,7 +28,7 @@ def configureVisualStudio() {
println " -> To manually specify the location of vswhere.exe, add \"-PvswherePath=<vswhere path>\" to the Gradle command line arguments" println " -> To manually specify the location of vswhere.exe, add \"-PvswherePath=<vswhere path>\" to the Gradle command line arguments"
return return
} }
def vswhereProcess = "\"${vswherePath}\" -products * -sort -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -format json -utf8".execute() def vswhereProcess = "\"${vswherePath}\" -products * -prerelease -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -format json -utf8".execute()
def vswhereOutput = vswhereProcess.text.trim() def vswhereOutput = vswhereProcess.text.trim()
def vswhereExit = vswhereProcess.exitValue() def vswhereExit = vswhereProcess.exitValue()
if (vswhereExit != 0) { if (vswhereExit != 0) {
@@ -49,20 +43,29 @@ def configureVisualStudio() {
return return
} }
def vswhereJson = new groovy.json.JsonSlurper().parseText(vswhereOutput); def vswhereJson = new groovy.json.JsonSlurper().parseText(vswhereOutput);
// Our minimum supported version of vswhere does not support the -sort arg, so we must
// manually sort. The -sort arg was introduced in vswhere 2.6.7.
sortVisualStudioVersions(vswhereJson)
def usePrerelease = project.hasProperty("vswherePrerelease") def usePrerelease = project.hasProperty("vswherePrerelease")
def i = -1 def i = -1
println " -> Searching for Visual Studio installations..." println " -> Searching for Visual Studio installations..."
vswhereJson.eachWithIndex { item, index -> vswhereJson.eachWithIndex { item, index ->
def isPrerelease = item.get("isPrerelease") def isPrerelease = item.get("isPrerelease")
def name = item.get("displayName") + (isPrerelease ? " Prerelease" : "") if (i == -1 && (usePrerelease || !isPrerelease)) {
if (i == -1) {
if (usePrerelease || !isPrerelease) {
i = index i = index
} }
} println " ${index + 1}: ${item.displayName}" +
println " ${index + 1}: ${name}" +
(i == index ? " (selected)" : "") + (i == index ? " (selected)" : "") +
(isPrerelease && !usePrerelease ? " (enable with -PvswherePrerelease)" : "") (isPrerelease && !usePrerelease ? " (enable with -PvswherePrerelease)" : "")
println " - Installation Version: ${item.installationVersion}" +
(item.containsKey("unsupportedVersion") ? " (failed to sort)" : "")
println " - Installation Date: ${item.installDate}"
println " - Installation Path: ${item.installationPath}"
if (isPrerelease) {
println " - Prerelease"
}
} }
if (i == -1) { if (i == -1) {
println " -> Visual Studio not found!" println " -> Visual Studio not found!"
@@ -92,4 +95,20 @@ def configureVisualStudio() {
rootProject.ext.VISUAL_STUDIO_SDK_VERSION_OVERRIDE = windowsTargetPlatformVersion rootProject.ext.VISUAL_STUDIO_SDK_VERSION_OVERRIDE = windowsTargetPlatformVersion
rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = vcvarsCmd rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = vcvarsCmd
} }
def sortVisualStudioVersions(vswhereJson) {
// Try to parse each version using Java's own version parser, marking the entries that failed
// (none should fail)
vswhereJson.each {
try {
Runtime.Version.parse(it.installationVersion)
}
catch (Exception e) {
it.put("unsupportedVersion", "true")
}
}
vswhereJson.sort { a, b -> b.instanceId <=> a.instanceId } // secondary sort
vswhereJson.sort { a, b -> Runtime.Version.parse(b.installationVersion) <=> Runtime.Version.parse(a.installationVersion) } // primary sort
} }