Skip to content

Commit

Permalink
Add a warning if msvc config cache may be outdated.
Browse files Browse the repository at this point in the history
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 <mats@linux.com>
  • Loading branch information
mwichmann committed Feb 11, 2020
1 parent eebcc30 commit 8662e7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 12 additions & 11 deletions src/engine/SCons/Tool/MSCommon/vc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -41,7 +44,6 @@
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
Expand All @@ -52,12 +54,8 @@
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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8662e7c

Please sign in to comment.