@@ -83,9 +83,9 @@ def exit_with_error(msg):
83
83
elif EMSDK_OS == 'macos' :
84
84
MACOS = True
85
85
else :
86
- assert False
86
+ assert False , 'EMSDK_OS must be one of: windows, linux, macos'
87
87
else :
88
- if os .name == 'nt' or (os . getenv ( 'SYSTEMROOT' ) is not None and ' windows' in os .getenv ('SYSTEMROOT' ).lower ()) or (os . getenv ( 'COMSPEC' ) is not None and ' windows' in os .getenv ('COMSPEC' ).lower ()):
88
+ if os .name == 'nt' or (' windows' in os .getenv ('SYSTEMROOT' , '' ).lower ()) or (' windows' in os .getenv ('COMSPEC' , ' ' ).lower ()):
89
89
WINDOWS = True
90
90
91
91
if os .getenv ('MSYSTEM' ):
@@ -256,7 +256,9 @@ def is_exe(fpath):
256
256
257
257
def vswhere (version ):
258
258
try :
259
- program_files = os .environ ['ProgramFiles(x86)' ] if 'ProgramFiles(x86)' in os .environ else os .environ ['ProgramFiles' ]
259
+ program_files = os .environ .get ('ProgramFiles(x86)' )
260
+ if not program_files :
261
+ program_files = os .environ ['ProgramFiles' ]
260
262
vswhere_path = os .path .join (program_files , 'Microsoft Visual Studio' , 'Installer' , 'vswhere.exe' )
261
263
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' ]))
262
264
# Visual Studio 2017 Express is not included in the above search, and it
@@ -291,7 +293,6 @@ def vs_filewhere(installation_path, platform, file):
291
293
elif '--vs2019' in sys .argv :
292
294
CMAKE_GENERATOR = 'Visual Studio 16'
293
295
else :
294
- program_files = os .environ ['ProgramFiles(x86)' ] if 'ProgramFiles(x86)' in os .environ else os .environ ['ProgramFiles' ]
295
296
vs2019_exists = len (vswhere (16 )) > 0
296
297
vs2017_exists = len (vswhere (15 )) > 0
297
298
mingw_exists = which ('mingw32-make' ) is not None and which ('g++' ) is not None
@@ -566,7 +567,8 @@ def untargz(source_filename, dest_dir):
566
567
def fix_potentially_long_windows_pathname (pathname ):
567
568
if not WINDOWS :
568
569
return pathname
569
- # Test if emsdk calls fix_potentially_long_windows_pathname() with long relative paths (which is problematic)
570
+ # Test if emsdk calls fix_potentially_long_windows_pathname() with long
571
+ # relative paths (which is problematic)
570
572
if not os .path .isabs (pathname ) and len (pathname ) > 200 :
571
573
errlog ('Warning: Seeing a relative path "' + pathname + '" which is dangerously long for being referenced as a short Windows path name. Refactor emsdk to be able to handle this!' )
572
574
if pathname .startswith ('\\ \\ ?\\ ' ):
@@ -1671,14 +1673,8 @@ def generate_dot_emscripten(active_tools):
1671
1673
1672
1674
1673
1675
def find_msbuild_dir ():
1674
- if 'ProgramFiles' in os .environ and os .environ ['ProgramFiles' ]:
1675
- program_files = os .environ ['ProgramFiles' ]
1676
- else :
1677
- program_files = 'C:/Program Files'
1678
- if 'ProgramFiles(x86)' in os .environ and os .environ ['ProgramFiles(x86)' ]:
1679
- program_files_x86 = os .environ ['ProgramFiles(x86)' ]
1680
- else :
1681
- program_files_x86 = 'C:/Program Files (x86)'
1676
+ program_files = os .environ .get ('ProgramFiles' , 'C:/Program Files' )
1677
+ program_files_x86 = os .environ .get ('ProgramFiles(x86)' , 'C:/Program Files (x86)' )
1682
1678
MSBUILDX86_DIR = os .path .join (program_files_x86 , "MSBuild/Microsoft.Cpp/v4.0/Platforms" )
1683
1679
MSBUILD_DIR = os .path .join (program_files , "MSBuild/Microsoft.Cpp/v4.0/Platforms" )
1684
1680
if os .path .exists (MSBUILDX86_DIR ):
0 commit comments