From 8662e7c190559fa4249fdf4aee38dbe08dd7847a Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Thu, 6 Feb 2020 09:37:19 -0700 Subject: Add a warning if msvc config cache may be outdated. If we didn't find cl.exe in the final check in msvc_setup_env(), issue a different warning if config caching is enabled. If it is, there's a decent chance we've found cl.exe in the past, meaning the cache is probably out of date - entries are indexed by path to the bat file+arg, whereas an msvc update may bump a version number in the path and the old path won't be valid: a cached path entry could look like this: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX64\\x64", and the .28314 could be changed in an update. Signed-off-by: Mats Wichmann --- src/CHANGES.txt | 1 + src/engine/SCons/Tool/MSCommon/vc.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 407a83b..b320aaf 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -62,6 +62,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Accommodate VS 2017 Express - it's got a more liberal license then VS Community, so some people prefer it (from 2019, no more Express) - vswhere call should also now work even if programs aren't on the C: drive. + - Add a specific warning msg if msvc config cache may be out of date. RELEASE 3.1.2 - Mon, 17 Dec 2019 02:06:27 +0000 diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index a18a1a7..ed713d0 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -22,6 +22,9 @@ # # TODO: +# * gather all the information from a single vswhere call instead +# of calling repeatedly (use json format?) +# * support passing/setting location for vswhere in env. # * supported arch for versions: for old versions of batch file without # argument, giving bogus argument cannot be detected, so we have to hardcode # this here @@ -41,7 +44,6 @@ import subprocess import os import platform import sys -from contextlib import suppress from string import digits as string_digits from subprocess import PIPE #TODO: Python 2 cleanup @@ -52,12 +54,8 @@ import SCons.Warnings from SCons.Tool import find_program_path from . import common - -debug = common.debug - -from . import sdk - -get_installed_sdks = sdk.get_installed_sdks +from .common import CONFIG_CACHE, debug +from .sdk import get_installed_sdks class VisualCException(Exception): @@ -921,11 +919,14 @@ def msvc_setup_env(env): debug("msvc_setup_env() env['ENV']['%s'] = %s" % (k, env['ENV'][k])) # final check to issue a warning if the compiler is not present - msvc_cl = find_program_path(env, 'cl') - if not msvc_cl: + if not find_program_path(env, 'cl'): debug("msvc_setup_env() did not find 'cl'") - SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, - "Could not find MSVC compiler 'cl', it may need to be installed separately with Visual Studio") + if CONFIG_CACHE: + propose = "SCONS_CACHE_MSVC_CONFIG caching enabled, remove cache file {} if out of date.".format(CONFIG_CACHE) + else: + propose = "It may need to be installed separately with Visual Studio." + warn_msg = "Could not find MSVC compiler 'cl'. {}".format(propose) + SCons.Warnings.warn(SCons.Warnings.VisualCMissingWarning, warn_msg) def msvc_exists(env=None, version=None): vcs = cached_get_installed_vcs(env) -- cgit v0.12