Fix emsdk to not crash after PR #77 on Windows if VS2017 is not installed.

This commit is contained in:
Jukka Jylänki
2017-07-13 13:09:32 +03:00
parent ee89d408a9
commit 7d0881ea73

11
emsdk
View File

@@ -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')