Fix VS2017 detection logic to fail properly when run on linux (posix) systems
authorWilliam Deegan <bill@baddogconsulting.com>
Tue, 8 Aug 2017 02:20:29 +0000 (19:20 -0700)
committerWilliam Deegan <bill@baddogconsulting.com>
Tue, 8 Aug 2017 02:20:29 +0000 (19:20 -0700)
src/engine/SCons/Tool/MSCommon/vc.py

index c76afacf9e592319a529e51525974ee9a51ab332..f8e72f52c165ba545b3f32ab2788e3b062756d9f 100644 (file)
@@ -242,10 +242,14 @@ def find_vc_pdir_vswhere(msvc_version):
     )
     vswhere_cmd = [vswhere_path, '-version', msvc_version, '-property', 'installationPath']
 
-    sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    vsdir, err = sp.communicate()
-    vc_pdir = os.path.join(vsdir.rstrip(), 'VC')
-    return vc_pdir
+    if os.path.exists(vswhere_path):
+        sp = subprocess.Popen(vswhere_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        vsdir, err = sp.communicate()
+        vc_pdir = os.path.join(vsdir.rstrip(), 'VC')
+        return vc_pdir
+    else:
+        # No vswhere on system, no install info available
+        return None
 
 
 def find_vc_pdir(msvc_version):
@@ -268,6 +272,9 @@ def find_vc_pdir(msvc_version):
             comps = None
             if not key:
                 comps = find_vc_pdir_vswhere(msvc_version)
+                if not comps:
+                    debug('find_vc_dir(): no VC found via vswhere for version {}'.format(repr(key)))
+                    raise SCons.Util.WinError
             else:
                 if common.is_win64():
                     try: