From 7d0881ea73fec754cc6a774ec50a55352b3b63ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Thu, 13 Jul 2017 13:09:32 +0300 Subject: [PATCH] Fix emsdk to not crash after PR #77 on Windows if VS2017 is not installed. --- emsdk | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/emsdk b/emsdk index f912dd8..406bc47 100755 --- a/emsdk +++ b/emsdk @@ -101,10 +101,13 @@ def which(program): return None def vswhere(version): - program_files = os.environ['ProgramFiles(x86)'] if 'ProgramFiles(x86)' in os.environ else os.environ['ProgramFiles'] - vswhere_path = os.path.join(program_files, 'Microsoft Visual Studio', 'Installer', 'vswhere.exe') - output = json.loads(subprocess.check_output([vswhere_path, '-latest', '-version', '[%s.0,%s.0)' % (version, version + 1) , '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', '-property', 'installationPath', '-format', 'json'])) - return output[0]['installationPath'].encode('ascii') if len(output) > 0 else '' + try: + program_files = os.environ['ProgramFiles(x86)'] if 'ProgramFiles(x86)' in os.environ else os.environ['ProgramFiles'] + vswhere_path = os.path.join(program_files, 'Microsoft Visual Studio', 'Installer', 'vswhere.exe') + output = json.loads(subprocess.check_output([vswhere_path, '-latest', '-version', '[%s.0,%s.0)' % (version, version + 1) , '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', '-property', 'installationPath', '-format', 'json'])) + return output[0]['installationPath'].encode('ascii') if len(output) > 0 else '' + except Exception, e: + return '' def vs_filewhere(installation_path, platform, file): vcvarsall = os.path.join(installation_path, 'VC/Auxiliary/Build/vcvarsall.bat')