Fix emsdk to not crash after PR #77 on Windows if VS2017 is not installed.
This commit is contained in:
3
emsdk
3
emsdk
@@ -101,10 +101,13 @@ def which(program):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def vswhere(version):
|
def vswhere(version):
|
||||||
|
try:
|
||||||
program_files = os.environ['ProgramFiles(x86)'] if 'ProgramFiles(x86)' in os.environ else os.environ['ProgramFiles']
|
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')
|
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']))
|
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 ''
|
return output[0]['installationPath'].encode('ascii') if len(output) > 0 else ''
|
||||||
|
except Exception, e:
|
||||||
|
return ''
|
||||||
|
|
||||||
def vs_filewhere(installation_path, platform, file):
|
def vs_filewhere(installation_path, platform, file):
|
||||||
vcvarsall = os.path.join(installation_path, 'VC/Auxiliary/Build/vcvarsall.bat')
|
vcvarsall = os.path.join(installation_path, 'VC/Auxiliary/Build/vcvarsall.bat')
|
||||||
|
|||||||
Reference in New Issue
Block a user