diff --git a/GPL/nativeBuildProperties.gradle b/GPL/nativeBuildProperties.gradle index 75ee3492d0..759e2c0ceb 100644 --- a/GPL/nativeBuildProperties.gradle +++ b/GPL/nativeBuildProperties.gradle @@ -49,11 +49,9 @@ task CheckToolChain { // Native C/Cpp plugins will trigger failure if no tool chain found doFirst { if (org.gradle.internal.os.OperatingSystem.current().isWindows()) { - // ensure that required MS Visual Studio is installed where expected - String msg = "Microsoft Visual Studio install not found: ${VISUAL_STUDIO_INSTALL_DIR}\n" + - "Adjust path in Ghidra/GPL/vsconfig.gradle if needed." - if (!file(VISUAL_STUDIO_INSTALL_DIR).exists()) { - throw new GradleException(msg); + // ensure that required MS Visual Studio is installed + if (!VISUAL_STUDIO_INSTALL_DIR) { + throw new GradleException("Visual Studio not found!"); } } } diff --git a/GPL/vsconfig.gradle b/GPL/vsconfig.gradle index 4fee5e68cf..a3e4d3c6d8 100644 --- a/GPL/vsconfig.gradle +++ b/GPL/vsconfig.gradle @@ -13,17 +13,27 @@ if (!hasProperty("VISUAL_STUDIO_INSTALL_DIR")) { def configureVisualStudio() { if (org.gradle.internal.os.OperatingSystem.current().isWindows()) { + + // Initialize variables + rootProject.ext.VISUAL_STUDIO_INSTALL_DIR = "" + rootProject.ext.VISUAL_STUDIO_TOOLS_VERSION_DEFAULT = "" + rootProject.ext.VISUAL_STUDIO_SDK_DIR_DEFAULT = "" + rootProject.ext.VISUAL_STUDIO_SDK_VERSION_DEFAULT = "" + rootProject.ext.VISUAL_STUDIO_SDK_VERSION_OVERRIDE = "" + rootProject.ext.VISUAL_STUDIO_VCVARS_CMD = "" // Use vswhere.exe to search for latest Visual Studio installation println "Searching for latest Visual Studio and required components..." def vswherePath = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" if (!file(vswherePath).exists()) { - throw new GradleException("Required file does not exist: " + vswherePath); + println "Visual Studio not found!" + return } def vswhereOutput = "${vswherePath} -latest -format json".execute().text.trim() def vswhereJson = new groovy.json.JsonSlurper().parseText(vswhereOutput); if (vswhereJson.isEmpty()) { - throw new GradleException("Failed to find Visual Studio!") + println "Visual Studio not found!" + return } def vsInstallDir = vswhereJson[0].installationPath println " -> Installation Directory: ${vsInstallDir}" diff --git a/Ghidra/Features/PDB/build.gradle b/Ghidra/Features/PDB/build.gradle index 9e4e4d4d88..8afedd266e 100644 --- a/Ghidra/Features/PDB/build.gradle +++ b/Ghidra/Features/PDB/build.gradle @@ -43,19 +43,21 @@ if ("win64".equals(getCurrentPlatformName())) { String makeName = "win64PDBMake" task(type: Exec, makeName) { - + def projectPath = projectDir.toString() def solutionBatchFilePath = projectPath + "/build/buildSolution.bat" - def projectPathWindows = projectPath.replace("/", File.separator) def solutionPathWindows = "${projectPathWindows}\\src\\pdb\\pdb.sln" - def platformToolset = 'v' + VISUAL_STUDIO_TOOLS_VERSION_DEFAULT.substring(0, 4).replace('.', ''); - def windowsTargetPlatformVersion = VISUAL_STUDIO_SDK_VERSION_OVERRIDE ?: VISUAL_STUDIO_SDK_VERSION_DEFAULT doFirst { file("build/os/win64").mkdirs() + + def platformToolset = 'v' + VISUAL_STUDIO_TOOLS_VERSION_DEFAULT.substring(0, 4).replace('.', ''); + def windowsTargetPlatformVersion = VISUAL_STUDIO_SDK_VERSION_OVERRIDE ?: VISUAL_STUDIO_SDK_VERSION_DEFAULT def msbuildCmd = "msbuild ${solutionPathWindows} /p:Configuration=Release /p:PlatformToolset=${platformToolset} /p:WindowsTargetPlatformVersion=${windowsTargetPlatformVersion}" + println "Executing: " + msbuildCmd + new File(solutionBatchFilePath).withWriter { out -> out.println "call " + VISUAL_STUDIO_VCVARS_CMD out.println msbuildCmd