Skip to content

Ghidra is a software reverse engineering (SRE) framework

Corrected Visual Studio gradle configuration which must also support standalone GPL builds

ghidra1d9da0f0b6688
diff --git a/GPL/certification.local.manifest b/GPL/certification.local.manifest
index e1eb6d38d3..1d8b8c1740 100644
--- a/GPL/certification.local.manifest
+++ b/GPL/certification.local.manifest
@@ -2,3 +2,4 @@
##MODULE IP: Public Domain
gpl.gradle||Public Domain||||END|
nativeBuildProperties.gradle||Public Domain||||END|
+vsconfig.gradle||GHIDRA||||END|
diff --git a/GPL/gpl.gradle b/GPL/gpl.gradle
index 857b444393..9428b3bdf4 100644
--- a/GPL/gpl.gradle
+++ b/GPL/gpl.gradle
@@ -2,8 +2,18 @@
// BIN_REPO only useable in full Ghidra source configuration
project.ext.BIN_REPO = file("../../../ghidra.bin").absolutePath
+/****************************************************************************
+ * Create a set containing all the platforms we need when building native
+ * artifacts.
+ ****************************************************************************/
project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64"])
+/****************************************************************************
+ * Establish Visual Studio configuration environment for Windows native builds
+ * NOTE: vsconfig.gradle path is relative to each GPL project module
+ ****************************************************************************/
+apply from: "../vsconfig.gradle"
+
/*********************************************************************************
* Returns the local platform name.
*********************************************************************************/
diff --git a/GPL/vsconfig.gradle b/GPL/vsconfig.gradle
new file mode 100644
index 0000000000..fd99641970
--- /dev/null
+++ b/GPL/vsconfig.gradle
@@ -0,0 +1,48 @@
+/****************************************************************************
+ * Establish Visual Studio configuration environment for Windows native builds
+ *
+ * NOTE: We do not rely on the VisualCpp plugin to identify paths since it has
+ * proven in the past to be unreliable when multiple versions of Visual Studio
+ * and SDKs are installed.
+ ****************************************************************************/
+
+if (!hasProperty("VISUAL_STUDIO_BASE_DIR")) {
+ configureVisualStudio()
+}
+
+def configureVisualStudio() {
+
+ rootProject.ext.VISUAL_STUDIO_BASE_DIR = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017"
+ rootProject.ext.WINDOWS_KITS_DIR = "C:\\Program Files (x86)\\Windows Kits\\10"
+
+ rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = "/"
+ rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = "UNKNOWN"
+ rootProject.ext.MSVC_SDK_VERSION = "UNKNOWN"
+ rootProject.ext.MSVC_TOOLS_VERSION = "UNKNOWN"
+
+ if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
+
+ rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = "${VISUAL_STUDIO_BASE_DIR}\\Professional"
+ if (!file(rootProject.ext.VISUAL_STUDIO_INSTALL_DIR).exists()) {
+ rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = "${VISUAL_STUDIO_BASE_DIR}\\Community"
+ }
+ if (file(rootProject.ext.VISUAL_STUDIO_INSTALL_DIR).exists()) {
+
+ println "Visual Studio Path: ${VISUAL_STUDIO_INSTALL_DIR}"
+
+ rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = "\"${VISUAL_STUDIO_INSTALL_DIR}\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x86_amd64"
+
+ // 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).
+ rootProject.ext.WINVER = "0x0601"
+
+ // Rely on vcvars script to supply SDK versions
+ def COMMAND = "cmd /v:ON /c ${VISUAL_STUDIO_VCVARS_CMD} > nul && cmd /c echo"
+ rootProject.ext.MSVC_SDK_VERSION = "${COMMAND} !WINDOWSSDKVERSION!".execute().text.trim().replace('\\', '')
+ println "Visual Studio SDK Version: ${MSVC_SDK_VERSION}"
+ rootProject.ext.MSVC_TOOLS_VERSION = "${COMMAND} !VCTOOLSVERSION!".execute().text.trim().replace('\\', '')
+ println "Visual Studio VCTools Version: ${MSVC_TOOLS_VERSION}"
+ }
+ }
+}
diff --git a/build.gradle b/build.gradle
index 34662a60f0..948e1f164a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -74,43 +74,7 @@ project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64"])
/****************************************************************************
* Establish Visual Studio configuration environment for Windows native builds
****************************************************************************/
-
-// Unclear if we can rely on the VisualCpp plugin to properly identify the correct
-// Visual Studio paths when multiple versions of Visual Studio and SDKs are installed
-
-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"
-
-project.ext.VISUAL_STUDIO_INSTALL_DIR = "/"
-project.ext.VISUAL_STUDIO_VCVARS_CMD = "UNKNOWN"
-project.ext.MSVC_SDK_VERSION = "UNKNOWN"
-project.ext.MSVC_TOOLS_VERSION = "UNKNOWN"
-
-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"
- }
- if (file(project.ext.VISUAL_STUDIO_INSTALL_DIR).exists()) {
-
- println "Visual Studio Path: ${VISUAL_STUDIO_INSTALL_DIR}"
-
- project.ext.VISUAL_STUDIO_VCVARS_CMD = "\"${VISUAL_STUDIO_INSTALL_DIR}\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x86_amd64"
-
- // 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 COMMAND = "cmd /v:ON /c ${VISUAL_STUDIO_VCVARS_CMD} > nul && cmd /c echo"
- project.ext.MSVC_SDK_VERSION = "${COMMAND} !WINDOWSSDKVERSION!".execute().text.trim().replace('\\', '')
- println "Visual Studio SDK Version: ${MSVC_SDK_VERSION}"
- project.ext.MSVC_TOOLS_VERSION = "${COMMAND} !VCTOOLSVERSION!".execute().text.trim().replace('\\', '')
- println "Visual Studio VCTools Version: ${MSVC_TOOLS_VERSION}"
- }
-}
+apply from: "GPL/vsconfig.gradle"
/*********************************************************************************
* Imports