From 072bfb6525a35131a7a2a36f4e320dd721c14add Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 15 Jun 2020 08:33:47 -0400 Subject: reset_installed_vcs is setting a local variable named __INSTALLED_VCS_RUN rather than the changing the global variable. Added global definition. --- SCons/Tool/MSCommon/vc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 2fe4995..4ac87d1 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -674,6 +674,7 @@ def get_installed_vcs(env=None): def reset_installed_vcs(): """Make it try again to find VC. This is just for the tests.""" + global __INSTALLED_VCS_RUN __INSTALLED_VCS_RUN = None # Running these batch files isn't cheap: most of the time spent in -- cgit v0.12 From e9835ea9f4d174b6da94f8e36dfcaa47b12bd922 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 15 Jun 2020 08:39:38 -0400 Subject: The cl.exe existence check for msvc 6.0 fails due to the case sensitivity of the filename ("cl.exe" and "CL.EXE"). First check vc_dir/bin/cl.exe and vc_dir/cl.exe for existence. Modify the vc_dir walk to check for existence under the directories rather than testing if cl.exe is in the file list. Existence test is not sensitive to file name case. --- SCons/Tool/MSCommon/vc.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 4ac87d1..70a19a8 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -628,10 +628,19 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version): return True elif 8 > ver_num >= 6: - # not sure about these versions so if a walk the VC dir (could be slow) - for root, _, files in os.walk(vc_dir): - if _CL_EXE_NAME in files: - debug(_CL_EXE_NAME + ' found %s' % os.path.join(root, _CL_EXE_NAME)) + # quick check for vc_dir/bin and vc_dir/ before walk + # need to check root as the walk only considers subdirectories + for cl_dir in ('bin', ''): + cl_path = os.path.join(vc_dir, cl_dir, _CL_EXE_NAME) + if os.path.exists(cl_path): + debug(_CL_EXE_NAME + ' found %s' % cl_path) + return True + # not in bin or root: must be in a subdirectory + for cl_root, cl_dirs, _ in os.walk(vc_dir): + for cl_dir in cl_dirs: + cl_path = os.path.join(cl_root, cl_dir, _CL_EXE_NAME) + if os.path.exists(cl_path): + debug(_CL_EXE_NAME + ' found %s' % cl_path) return True return False else: -- cgit v0.12 From e59880bb11e551c3174af606332a7882e625f7cb Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 15 Jun 2020 08:48:57 -0400 Subject: Msvc 14.1Exp detection raises an UnsupportedVersion exception due to a missing "14.Exp" key in the _VCVER_TO_VSWHERE_VER dictionary. Add the "14.Exp" to the dictionary. --- SCons/Tool/MSCommon/vc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 70a19a8..91265d2 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -231,8 +231,9 @@ _VCVER = ["14.2", "14.1", "14.1Exp", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0 # if using vswhere, a further mapping is needed _VCVER_TO_VSWHERE_VER = { - '14.2': '[16.0, 17.0)', - '14.1': '[15.0, 16.0)', + '14.2': '[16.0, 17.0)', + '14.1': '[15.0, 16.0)', + '14.1Exp': '[15.0, 16.0)', } _VCVER_TO_PRODUCT_DIR = { -- cgit v0.12 From 0d7249df69154a86f4e4697aca85ee89ca5c3293 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 15 Jun 2020 08:57:22 -0400 Subject: The order of results from the vswhere query using "products *" is unreliable when multiple versions of msvc are installed. Modify the vswhere queries by version to detect the appropriate products: 14.2 [default, BuildTools], 14.1 [default, BuildTools], 14.1Exp [WDExpress]. The default is Enterprise, Professional, Community. The order is unknown. With only Build Tools installed, 14.2 and 14.1 require two calls to vswhere. --- SCons/Tool/MSCommon/vc.py | 59 ++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 91265d2..5acada4 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -231,9 +231,17 @@ _VCVER = ["14.2", "14.1", "14.1Exp", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0 # if using vswhere, a further mapping is needed _VCVER_TO_VSWHERE_VER = { - '14.2': '[16.0, 17.0)', - '14.1': '[15.0, 16.0)', - '14.1Exp': '[15.0, 16.0)', + '14.2': [ + ["-version", "[16.0, 17.0)", ], # default: Enterprise, Professional, Community (order unpredictable?) + ["-version", "[16.0, 17.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools + ], + '14.1': [ + ["-version", "[15.0, 16.0)", ], # default: Enterprise, Professional, Community (order unpredictable?) + ["-version", "[15.0, 16.0)", "-products", "Microsoft.VisualStudio.Product.BuildTools"], # BuildTools + ], + '14.1Exp': [ + ["-version", "[15.0, 16.0)", "-products", "Microsoft.VisualStudio.Product.WDExpress"], # Express + ], } _VCVER_TO_PRODUCT_DIR = { @@ -377,29 +385,28 @@ def find_vc_pdir_vswhere(msvc_version, env=None): return None debug('VSWHERE: %s' % vswhere_path) - vswhere_cmd = [ - vswhere_path, - "-products", "*", - "-version", vswhere_version, - "-property", "installationPath", - ] - - debug("running: %s" % vswhere_cmd) - - #cp = subprocess.run(vswhere_cmd, capture_output=True) # 3.7+ only - cp = subprocess.run(vswhere_cmd, stdout=PIPE, stderr=PIPE) - - if cp.stdout: - # vswhere could return multiple lines, e.g. if Build Tools - # and {Community,Professional,Enterprise} are both installed. - # We could define a way to pick the one we prefer, but since - # this data is currently only used to make a check for existence, - # returning the first hit should be good enough. - lines = cp.stdout.decode("mbcs").splitlines() - return os.path.join(lines[0], 'VC') - else: - # We found vswhere, but no install info available for this version - return None + for vswhere_version_args in vswhere_version: + + vswhere_cmd = [vswhere_path] + vswhere_version_args + ["-property", "installationPath"] + + debug("running: %s" % vswhere_cmd) + + #cp = subprocess.run(vswhere_cmd, capture_output=True) # 3.7+ only + cp = subprocess.run(vswhere_cmd, stdout=PIPE, stderr=PIPE) + + if cp.stdout: + # vswhere could return multiple lines, e.g. if Build Tools + # and {Community,Professional,Enterprise} are both installed. + # We could define a way to pick the one we prefer, but since + # this data is currently only used to make a check for existence, + # returning the first hit should be good enough. + lines = cp.stdout.decode("mbcs").splitlines() + return os.path.join(lines[0], 'VC') + else: + # We found vswhere, but no install info available for this version + return None + + return None def find_vc_pdir(env, msvc_version): -- cgit v0.12 From 4299673d217886b178c2d9b44309bd21622e5526 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 15 Jun 2020 12:30:17 -0400 Subject: fix erroneous indent is os.walk code for cl.exe --- SCons/Tool/MSCommon/vc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 5acada4..8369a4b 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -649,7 +649,7 @@ def _check_cl_exists_in_vc_dir(env, vc_dir, msvc_version): cl_path = os.path.join(cl_root, cl_dir, _CL_EXE_NAME) if os.path.exists(cl_path): debug(_CL_EXE_NAME + ' found %s' % cl_path) - return True + return True return False else: # version not support return false -- cgit v0.12 From c23d2aa4d4f2239514a20d1bb1bbdf2d0b7c7b80 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 15 Jun 2020 16:11:37 -0400 Subject: don't exit immediately when vswhere returns no information since there may be more iterations (artifact from moving the vswhere query in a loop) --- SCons/Tool/MSCommon/vc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 8369a4b..b9ed694 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -404,7 +404,7 @@ def find_vc_pdir_vswhere(msvc_version, env=None): return os.path.join(lines[0], 'VC') else: # We found vswhere, but no install info available for this version - return None + pass return None -- cgit v0.12 From df223dc1578704e52e1761aafb072d57571bd2e4 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Tue, 16 Jun 2020 09:13:57 -0400 Subject: update comment for vswhere version arguments --- SCons/Tool/MSCommon/vc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index b9ed694..c6417e9 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -229,7 +229,7 @@ def get_host_target(env): # MSVC_VERSION documentation in Tool/msvc.xml. _VCVER = ["14.2", "14.1", "14.1Exp", "14.0", "14.0Exp", "12.0", "12.0Exp", "11.0", "11.0Exp", "10.0", "10.0Exp", "9.0", "9.0Exp","8.0", "8.0Exp","7.1", "7.0", "6.0"] -# if using vswhere, a further mapping is needed +# if using vswhere, configure command line arguments to probe for installed VC editions _VCVER_TO_VSWHERE_VER = { '14.2': [ ["-version", "[16.0, 17.0)", ], # default: Enterprise, Professional, Community (order unpredictable?) -- cgit v0.12 From 561d30ff2fc1f32626b843de72fe0726d63fb965 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Tue, 16 Jun 2020 13:36:21 -0400 Subject: updates concerning GH Issue #3699 [ci skip] --- CHANGES.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6fc1905..83588a0 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -182,7 +182,17 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER rewordings in manpage. Manpage Examples moved to an external repository / website (scons-cookbook.readthedocs.io). - + From Joseph Brill: + - MSVC updates: Add 14.1Exp entry for vswhere queries. (GH Issue #3699). + - MSVC updates: Modify vswhere query to allow specialized argument lists and + multiple passes. Fixes returned msvc instance when multiple versions are + installed: 14.1 Express returned for 14.1 and 14.2 Build Tools returned before + 14.2 Community (GH Issue #3699). + - MSVC updates: Fix initial detection failure (false negative) of MSVC 6.0 based on a + case-sensitive file name comparison (GH Issue #3699). Modify the initial detection + of MSVC 6.0-7.1 for performance. + - MSVC updates: Fix failure to properly reset installed msvc instances for testing (GH Issue #3699). + RELEASE 3.1.2 - Mon, 17 Dec 2019 02:06:27 +0000 From Edoardo Bezzeccheri -- cgit v0.12 From 86508e0f28cd4a3c54e97aa4a2ffbe027f3a8ea9 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Wed, 17 Jun 2020 17:03:17 -0400 Subject: rework changes to be end-user focused [ci skip] --- CHANGES.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 83588a0..14212fc 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -183,15 +183,16 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER repository / website (scons-cookbook.readthedocs.io). From Joseph Brill: - - MSVC updates: Add 14.1Exp entry for vswhere queries. (GH Issue #3699). - - MSVC updates: Modify vswhere query to allow specialized argument lists and - multiple passes. Fixes returned msvc instance when multiple versions are - installed: 14.1 Express returned for 14.1 and 14.2 Build Tools returned before - 14.2 Community (GH Issue #3699). - - MSVC updates: Fix initial detection failure (false negative) of MSVC 6.0 based on a - case-sensitive file name comparison (GH Issue #3699). Modify the initial detection - of MSVC 6.0-7.1 for performance. - - MSVC updates: Fix failure to properly reset installed msvc instances for testing (GH Issue #3699). + - MSVC updates: When there are multiple product installations (e.g, Community and + Build Tools) of MSVC 2017 or MSVC 2019, an Enterprise, Professional, + or Community installation will be selected before a Build Tools installation when + "14.1" or "14.2" is requested, respectively. (GH Issue #3699). + - MSVC updates: When there are multiple product installations of MSVC 2017 (e.g., + Community and Express), 2017 Express is no longer returned when "14.1" is + requested. Only 2017 Express will be returned when "14.1Exp" is requested. + (GH Issue #3699). + - MSVC updates: An MSVC 6.0 installation now appears in the installed versions list + when msvc debug output is enabled (GH Issue #3699). RELEASE 3.1.2 - Mon, 17 Dec 2019 02:06:27 +0000 -- cgit v0.12