diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle index 2a4db4e6d8..f289ca112d 100644 --- a/GPL/nativeBuildProperties.gradle +++ b/GPL/nativeBuildProperties.gradle @@ -15,16 +15,6 @@ 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" - -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" - /**************************************************************************** * 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. @@ -59,30 +49,6 @@ task CheckToolChain { // Native C/Cpp plugins will trigger failure if no tool chain found doFirst { 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}" - } - // ensure that required MS Visual Studio is installed where expected String msg = "Microsoft Visual Studio install not found: ${VISUAL_STUDIO_BASE_DIR}\n" + "Adjust path in Ghidra/GPL/nativeBuildProperties.gradle if needed." diff --git a/build.gradle b/build.gradle index 2f1fce9f24..34662a60f0 100644 --- a/build.gradle +++ b/build.gradle @@ -71,6 +71,47 @@ else { 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}" + } +} + /********************************************************************************* * Imports * For these tasks to be available on all subprojects, this MUST be placed