From d91e36d197466c49e3cc4d3d62115fb41b4acfe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Fri, 8 Nov 2013 13:53:07 +0200 Subject: [PATCH] Fix MSBuild find to look from both (x86) and non-x86 program files. Fixes https://github.com/kripken/emscripten/issues/1770. --- emsdk | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/emsdk b/emsdk index 5f0c105..9412a2a 100644 --- a/emsdk +++ b/emsdk @@ -386,7 +386,21 @@ JS_ENGINES = [NODE_JS] print '' print ' ' + ENVPATH_SEPARATOR.join(path_add) -MSBUILD_DIR = "C:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/Platforms" +def find_msbuild_dir(): + program_files = os.environ['ProgramFiles'] + if not program_files: + program_files = 'C:/Program Files' + program_files_x86 = os.environ['ProgramFiles(x86)'] + if not program_files_x86: + program_files_x86 = 'C:/Program Files (x86)' + MSBUILDX86_DIR = os.path.join(program_files_x86, "MSBuild/Microsoft.Cpp/v4.0/Platforms") + MSBUILD_DIR = os.path.join(program_files, "MSBuild/Microsoft.Cpp/v4.0/Platforms") + if os.path.exists(MSBUILDX86_DIR): + return MSBUILDX86_DIR + elif os.path.exists(MSBUILD_DIR): + return MSBUILD_DIR + else: + return '' # No MSbuild installed. def get_installed_vstool_version(installed_path): try: @@ -409,7 +423,7 @@ class Tool: # Specifies the target path where this tool will be installed to. This could either be a directory or a filename (e.g. in case of node.js) def installation_path(self): if WINDOWS and hasattr(self, 'windows_install_path'): - pth = self.windows_install_path.replace("%MSBuildPlatformsDir%", MSBUILD_DIR) + pth = self.windows_install_path.replace("%MSBuildPlatformsDir%", find_msbuild_dir()) return pth p = self.version if hasattr(self, 'bitness'): @@ -506,10 +520,11 @@ class Tool: # Otherwise, this function returns a string that describes the reason why this tool is not available. def can_be_installed(self): if self.id == 'vs-tool': - if os.path.exists(MSBUILD_DIR): + msbuild_dir = find_msbuild_dir() + if len(msbuild_dir) > 0: return True else: - return "VS2010 was not found!" + return "Visual Studio was not found!" else: return True