Skip to content

Ghidra is a software reverse engineering (SRE) framework

GT-2565 revised Visual Studio setup

ghidra11b4552e6b41c
diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle
index 3f35078b2e..48c3827b84 100644
--- a/GPL/nativeBuildProperties.gradle
+++ b/GPL/nativeBuildProperties.gradle
@@ -15,38 +15,65 @@
apply plugin: 'cpp'
apply plugin: 'c'
+// Unclear if we can rely on the VisualCpp plugin to identify the correct Visual Studio paths
+
project.ext.VISUAL_STUDIO_BASE_DIR = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017"
+project.ext.WINDOWS_KITS_DIR = "C:/Program Files (x86)/Windows Kits/10"
+
+/****************************************************************************
+ * Method for extracting value from <name>=<value> pairs
+ ****************************************************************************/
+ext.getEnvironmentValue = { envLines, name ->
+ String assignment = name + "="
+ for (String line : envLines) {
+ if (line.startsWith(assignment)) {
+ String[] parts = line.split("=")
+ String value = parts[1].trim()
+ // remove trailing \ if present
+ if (value.endsWith("\\")) {
+ value = value.substring(0, value.length()-1)
+ }
+ return value
+ }
+ }
+ return null
+}
// Ok, this is stupid, but mac and linux can't handle files paths that start with c:
// These paths are actually only used when running on windows, but the paths gets evaulated
// as a file no matter what platform you run gradle on. So the best solution I can think of is as
// follows.
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
-
+
project.ext.VISUAL_STUDIO_INSTALL_DIR = project.ext.VISUAL_STUDIO_BASE_DIR + "\\Professional"
if (!file(project.ext.VISUAL_STUDIO_INSTALL_DIR).exists()) {
project.ext.VISUAL_STUDIO_INSTALL_DIR = project.ext.VISUAL_STUDIO_BASE_DIR + "\\Community"
}
+ println "Visual Studio Path: ${VISUAL_STUDIO_INSTALL_DIR}"
- // TODO: Use of this will require coping with VC version in path
- project.ext.WINDOWS_KITS_DIR = "C:/Program Files (x86)/Windows Kits/10.0"
-
project.ext.VISUAL_STUDIO_VCVARS_CMD = "\"${VISUAL_STUDIO_INSTALL_DIR}\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x86_amd64"
- // TODO: force VisualCpp installDir and windowsSdkDir
-
// NOTE: Windows 7 targeting requires the use of the Windows 8.1 SDK and setting the
// WINVER property a value of "0x0601" which may be specified to the compiler/linker.
// If using a VS Solution this must be specified within the project file(s).
project.ext.WINVER = "0x0601"
+
+ // Rely on vcvars script to supply SDK versions
+ def c = VISUAL_STUDIO_VCVARS_CMD + " && env"
+ String envText = c.execute().text
+ String[] envLines = c.execute().text.split("\n")
+ project.ext.MSVC_SDK_VERSION = getEnvironmentValue(envLines, "WINDOWSSDKVERSION")
+ println "Visual Studio SDK Version: ${MSVC_SDK_VERSION}"
+ project.ext.MSVC_TOOLS_VERSION = getEnvironmentValue(envLines, "VCTOOLSVERSION")
+ println "Visual Studio VCTools Version: ${MSVC_TOOLS_VERSION}"
}
else {
project.ext.VISUAL_STUDIO_INSTALL_DIR = "/"
- project.ext.WINDOWS_KITS_DIR = "/"
project.ext.VISUAL_STUDIO_VCVARS_CMD = "NA"
+ project.ext.MSVC_SDK_VERSION = "?"
+ project.ext.MSVC_TOOLS_VERSION = "?"
}
-
/****************************************************************************
* Defines the platforms we have to support in Ghidra. This model is used
* for all native builds and should be extended by each module as-needed.