From a245db4b2d5183ee27e1d13a9db454ce694d94d2 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 8 Mar 2022 10:02:42 -0700 Subject: Tweak the MSVC environment vars cache - Now performs a sanity check: if the retrieved tools path does not exist, consider the entry invalid so it will be recomputed. - The dictionary key, which is the name of a batch file, is computed a bit differently: the dashes are left off if there are no arguments. - The cachefile is changed to have a .json suffix, for better recognition on Windows systems. Signed-off-by: Mats Wichmann --- CHANGES.txt | 6 ++++++ RELEASE.txt | 3 +++ SCons/Tool/MSCommon/common.py | 2 +- SCons/Tool/MSCommon/vc.py | 15 ++++++++++++++- doc/man/scons.xml | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d36e911..e7be169 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -56,6 +56,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER processors for testing threads. - Fixed crash in C scanner's dictify_CPPDEFINES() function which happens if AppendUnique is called on CPPPATH. (Issue #4108). + - The MSVC script_env_cache now contains a sanity check: if the retrieved + tools path does not exist, it is invalidated so it will be recomputed. + The dictionary key, which is the name of a batch file, is also computed + a bit differently: the dashes are left off if there are no arguments. + The cachefile is changed to have a .json suffix, for better recognition + on Windows where there might, for example, be an editor association. From Zhichang Yu: - Added MSVC_USE_SCRIPT_ARGS variable to pass arguments to MSVC_USE_SCRIPT. diff --git a/RELEASE.txt b/RELEASE.txt index 4f963b5..80b8bf1 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -36,6 +36,9 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY - The change to "content" and "content-timestamp" Decider names is reflected in the User Guide as well, since the hash function may be other than md5 (tidying up from earlier change) +- The SCONS_CACHE_MSVC_CONFIG behavior changes slightly: will now do a + sanity check to hopefully regenerate if the compiler version has changed, + rather than fail; the default filename now has a .json suffix. FIXES diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index ee31b2d..fee460a 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -94,7 +94,7 @@ else: # SCONS_CACHE_MSVC_CONFIG is public, and is documented. CONFIG_CACHE = os.environ.get('SCONS_CACHE_MSVC_CONFIG') if CONFIG_CACHE in ('1', 'true', 'True'): - CONFIG_CACHE = os.path.join(os.path.expanduser('~'), '.scons_msvc_cache') + CONFIG_CACHE = os.path.join(os.path.expanduser('~'), '.scons_msvc_cache.json') def read_script_env_cache(): diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index fe31cb3..36a530e 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -43,6 +43,7 @@ import SCons.compat import subprocess import os import platform +from pathlib import Path from string import digits as string_digits from subprocess import PIPE @@ -741,8 +742,20 @@ def script_env(script, args=None): if script_env_cache is None: script_env_cache = common.read_script_env_cache() - cache_key = "{}--{}".format(script, args) + extra = f"--{args}" if args else "" + cache_key = f"{script}{extra}" cache_data = script_env_cache.get(cache_key, None) + + # brief sanity check + if cache_data is not None: + try: + cache_check = cache_data["VCToolsInstallDir"][0] + toolsdir = Path(cache_check) + if not toolsdir.exists(): + cache_data = None + except (KeyError, IndexError): + cache_data = None + if cache_data is None: stdout = common.get_output(script, args) diff --git a/doc/man/scons.xml b/doc/man/scons.xml index 047f230..d7fe39d 100644 --- a/doc/man/scons.xml +++ b/doc/man/scons.xml @@ -8082,7 +8082,7 @@ in tightly controlled Continuous Integration setups. If set to a True-like value ("1", "true" or "True") will cache to a file named -.scons_msvc_cache in the user's home directory. +.scons_msvc_cache.json in the user's home directory. If set to a pathname, will use that pathname for the cache. Note: use this cache with caution as it -- cgit v0.12 From 50ddff517f22b34b8d2054c4bcbb616a9efb0eb6 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 11 Mar 2022 08:47:31 -0700 Subject: MSVS_CACHE: Reword the CHANGES and RELEASE entries Sharpened up the descriptions of the change in PR 4111. Changed the opening of the cache file to use pathlib functions. Signed-off-by: Mats Wichmann --- CHANGES.txt | 13 ++++++++----- RELEASE.txt | 20 ++++++++++++-------- SCons/Tool/MSCommon/common.py | 9 ++++++--- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index e7be169..41b02d9 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -57,11 +57,14 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed crash in C scanner's dictify_CPPDEFINES() function which happens if AppendUnique is called on CPPPATH. (Issue #4108). - The MSVC script_env_cache now contains a sanity check: if the retrieved - tools path does not exist, it is invalidated so it will be recomputed. - The dictionary key, which is the name of a batch file, is also computed - a bit differently: the dashes are left off if there are no arguments. - The cachefile is changed to have a .json suffix, for better recognition - on Windows where there might, for example, be an editor association. + tools path does not exist, the entry is invalidated so it will + be recomputed, in an attempt to avoid scons failing when certain + compiler version bumps have taken place. The dictionary key (uses + the name of a batch file and any arguments which may have been + passes), is now computed a bit differently: the dashes are left + off if there are no arguments. The default cachefile is changed + to have a .json suffix, for better recognition on Windows since + the contents are json. From Zhichang Yu: - Added MSVC_USE_SCRIPT_ARGS variable to pass arguments to MSVC_USE_SCRIPT. diff --git a/RELEASE.txt b/RELEASE.txt index 80b8bf1..c021a40 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -26,19 +26,23 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY --------------------------------------- - On Windows, %AllUsersProfile%\scons\site_scons is now the default "system" - location for a site_scons. %AllUsersProfile%\Application Data\scons\site_scons - will continue to work. There does not seem to be any convention to use - an "Application Data" subdirectory here. + location for a site_scons directory. + %AllUsersProfile%\Application Data\scons\site_scons will continue to work. + There does not seem to be any existing convention to use an + "Application Data" subdirectory here. - Action._subproc() can now be used as a python context manager to ensure that the POpen object is properly closed. -- SCons help (-H) no longer prints the "ignored for compatibility" options, - which are still listed in the manpage. +- SCons help (-H) no longer prints the "ignored for compatibility" options + to save some space (these are still listed in the manpage). - The change to "content" and "content-timestamp" Decider names is reflected in the User Guide as well, since the hash function may be other than md5 (tidying up from earlier change) -- The SCONS_CACHE_MSVC_CONFIG behavior changes slightly: will now do a - sanity check to hopefully regenerate if the compiler version has changed, - rather than fail; the default filename now has a .json suffix. +- If SCONS_CACHE_MSVC_CONFIG is used, it will now attempt a sanity check for + the cached compiler information, and regenerate the information + if needed, rather than just failing after certain compiler version + changes have happened. The cache file can still be manually removed + if there are issues to force a regen. The default cache filename now + has a .json suffix - the contents have always been json. FIXES diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index fee460a..16ed42c 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -31,6 +31,7 @@ import os import re import subprocess import sys +from pathlib import Path import SCons.Util @@ -102,7 +103,8 @@ def read_script_env_cache(): envcache = {} if CONFIG_CACHE: try: - with open(CONFIG_CACHE, 'r') as f: + p = Path(CONFIG_CACHE) + with p.open('r') as f: envcache = json.load(f) except FileNotFoundError: # don't fail if no cache file, just proceed without it @@ -114,11 +116,12 @@ def write_script_env_cache(cache): """ write out cache of msvc env vars if requested """ if CONFIG_CACHE: try: - with open(CONFIG_CACHE, 'w') as f: + p = Path(CONFIG_CACHE) + with p.open('w') as f: json.dump(cache, f, indent=2) except TypeError: # data can't serialize to json, don't leave partial file - os.remove(CONFIG_CACHE) + p.unlink(missing_ok=True) except IOError: # can't write the file, just skip pass -- cgit v0.12 From 059f662e2991a039d2b6b3aa5997c25b1323e635 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 12 Mar 2022 10:07:59 -0700 Subject: PR 4111: tweak msvc cache invalid algorithm Adapt previous change so if cache entry tools dir is empty, don't invalidate the entry, it's an old compiler that doesn't add this info (we always add it, if it didn't come from the batch file it will be an empty list). We don't want to force that case to recalculate, or the value of the cache is lost for those compilers. Signed-off-by: Mats Wichmann --- SCons/Tool/MSCommon/vc.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 36a530e..64d5d38 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -742,19 +742,24 @@ def script_env(script, args=None): if script_env_cache is None: script_env_cache = common.read_script_env_cache() - extra = f"--{args}" if args else "" - cache_key = f"{script}{extra}" + cache_key = f"{script}--{args}" if args else f"{script}" cache_data = script_env_cache.get(cache_key, None) - # brief sanity check + # Brief sanity check: if we got a value for the key, + # see if it has a VCToolsInstallDir entry that is not empty. + # If so, and that path does not exist, invalidate the entry. + # If empty, this is an old compiler, just leave it alone. if cache_data is not None: try: - cache_check = cache_data["VCToolsInstallDir"][0] - toolsdir = Path(cache_check) - if not toolsdir.exists(): - cache_data = None - except (KeyError, IndexError): - cache_data = None + toolsdir = cache_data["VCToolsInstallDir"] + except KeyError: + # we write this value, so should not happen + pass + else: + if toolsdir: + toolpath = Path(toolsdir[0]) + if not toolpath.exists(): + cache_data = None if cache_data is None: stdout = common.get_output(script, args) -- cgit v0.12 From c9148823b065e0892c7269dbbc4217d80bc40c51 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Sat, 19 Mar 2022 07:40:53 -0400 Subject: Replace environment variable names VS70COMNTOOLS and VS60COMNTOOLS with VSCOMNTOOLS and MSDevDir, respectively. MSDevDir does not point to the MSVS 6.0 common folder but is included as it is optionally defined by the installer and is used for the VisualStudio definitions. With the definition of VSCOMNTOOLS for 7.0, the traditional vcvars32.bat can be configured for MSVC 7.1 and 7.0. Unify the batch file code for msvc 6.0-7.1 and suppress the build argument as the native batch files do not process any arguments. While not strictly necessary, this potentially is useful when caching is enabled. --- CHANGES.txt | 4 ++++ RELEASE.txt | 6 ++++++ SCons/Tool/MSCommon/common.py | 4 ++-- SCons/Tool/MSCommon/vc.py | 6 ++---- SCons/Tool/MSCommon/vs.py | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index d36e911..ab23aa4 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,6 +12,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Joseph Brill: - Verify that a user specified msvc script (via MSVC_USE_SCRIPT) exists and raise an exception when the user specified msvc script does not exist. + - Replace non-existent MSVS environment variables VS70COMNTOOLS and VS60COMNTOOLS with + VSCOMNTOOLS and MSDevDir for MSVC 7.0 and 6.0, respectively. Change the MSVS 7.x batch + files used from vsvars32.bat to vcvars32.bat. Suppress passing arguments to the MSVS 6.0-7.1 + batch files as no arguments are required. From William Deegan: - Fix check for unsupported Python version. It was broken. Also now the error message diff --git a/RELEASE.txt b/RELEASE.txt index 4f963b5..721573a 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -36,6 +36,10 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY - The change to "content" and "content-timestamp" Decider names is reflected in the User Guide as well, since the hash function may be other than md5 (tidying up from earlier change) +- The MSVC batch file names used for MSVC versions 6.0 to 7.1 were unified after the + requisite MSVC environment variable for version 7.0 was updated. The build argument + is now suppressed for the MSVC 6.0 to 7.1 batch files to be consistent with the expected + batch file usage. FIXES @@ -45,6 +49,8 @@ FIXES with python 3.9 (or higher) - Fixed crash in C scanner's dictify_CPPDEFINES() function which happens if AppendUnique is called on CPPPATH. (Issue #4108). +- The environment variable names used when constructing the MSVC 7.0 and 6.0 environments were + updated to be consistent with the names defined by the respective installers. IMPROVEMENTS diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index ee31b2d..29b63ae 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -253,8 +253,8 @@ def get_output(vcbat, args=None, env=None): 'VS90COMNTOOLS', 'VS80COMNTOOLS', 'VS71COMNTOOLS', - 'VS70COMNTOOLS', - 'VS60COMNTOOLS', + 'VSCOMNTOOLS', + 'MSDevDir', 'VSCMD_DEBUG', # enable logging and other debug aids 'VSCMD_SKIP_SENDTELEMETRY', ] diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index fe31cb3..c2314d3 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -512,12 +512,10 @@ def find_batch_file(env,msvc_version,host_arch,target_arch): msvc_ver_numeric = get_msvc_version_numeric(msvc_version) use_arg = True vernum = float(msvc_ver_numeric) - if 7 <= vernum < 8: - pdir = os.path.join(pdir, os.pardir, "Common7", "Tools") - batfilename = os.path.join(pdir, "vsvars32.bat") - elif vernum < 7: + if vernum < 8: pdir = os.path.join(pdir, "Bin") batfilename = os.path.join(pdir, "vcvars32.bat") + use_arg = False elif 8 <= vernum <= 14: batfilename = os.path.join(pdir, "vcvarsall.bat") else: # vernum >= 14.1 VS2017 and above diff --git a/SCons/Tool/MSCommon/vs.py b/SCons/Tool/MSCommon/vs.py index 35d21e0..08c3cf5 100644 --- a/SCons/Tool/MSCommon/vs.py +++ b/SCons/Tool/MSCommon/vs.py @@ -391,7 +391,7 @@ SupportedVSList = [ VisualStudio('7.0', sdk_version='2003R2', hkeys=[r'Microsoft\VisualStudio\7.0\Setup\VS\ProductDir'], - common_tools_var='VS70COMNTOOLS', + common_tools_var='VSCOMNTOOLS', executable_path=r'Common7\IDE\devenv.com', batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio .NET', @@ -403,7 +403,7 @@ SupportedVSList = [ sdk_version='2003R1', hkeys=[r'Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Studio\ProductDir', 'use_dir'], - common_tools_var='VS60COMNTOOLS', + common_tools_var='MSDevDir', executable_path=r'Common\MSDev98\Bin\MSDEV.COM', batch_file_path=r'Common7\Tools\vsvars32.bat', default_dirname='Microsoft Visual Studio', -- cgit v0.12 From affbc9b6d11a2087f57c697c7dc4369b452e4e23 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Sun, 20 Mar 2022 08:17:43 -0400 Subject: Update CHANGES.txt and RELEASE.txt. --- CHANGES.txt | 9 +++++---- RELEASE.txt | 13 +++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ab23aa4..1728519 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -12,10 +12,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER From Joseph Brill: - Verify that a user specified msvc script (via MSVC_USE_SCRIPT) exists and raise an exception when the user specified msvc script does not exist. - - Replace non-existent MSVS environment variables VS70COMNTOOLS and VS60COMNTOOLS with - VSCOMNTOOLS and MSDevDir for MSVC 7.0 and 6.0, respectively. Change the MSVS 7.x batch - files used from vsvars32.bat to vcvars32.bat. Suppress passing arguments to the MSVS 6.0-7.1 - batch files as no arguments are required. + - The imported system environment variable names for MSVC 7.0 and 6.0 have been changed to the + names set by their respective installers. Prior to this change, bypassing MSVC detection by + specifying the MSVC 7.0 batch file directly would fail due to using an erroneous environment + variable name. Arguments are no longer passed to the MSVC 6.0 to 7.1 batch files as no + arguments are required and could improve the effectiveness of the internal MSVC cache. From William Deegan: - Fix check for unsupported Python version. It was broken. Also now the error message diff --git a/RELEASE.txt b/RELEASE.txt index 721573a..f65e135 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -36,10 +36,10 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY - The change to "content" and "content-timestamp" Decider names is reflected in the User Guide as well, since the hash function may be other than md5 (tidying up from earlier change) -- The MSVC batch file names used for MSVC versions 6.0 to 7.1 were unified after the - requisite MSVC environment variable for version 7.0 was updated. The build argument - is now suppressed for the MSVC 6.0 to 7.1 batch files to be consistent with the expected - batch file usage. +- The build argument (i.e., x86) is no longer passed to the MSVC 6.0 to 7.1 batch + files. This may improve the effectiveness of the internal msvc cache when using + MSVC detection and when bypassing MSVC detection as the MSVC 6.0 to 7.1 batch files + do not expect any arguments. FIXES @@ -49,8 +49,9 @@ FIXES with python 3.9 (or higher) - Fixed crash in C scanner's dictify_CPPDEFINES() function which happens if AppendUnique is called on CPPPATH. (Issue #4108). -- The environment variable names used when constructing the MSVC 7.0 and 6.0 environments were - updated to be consistent with the names defined by the respective installers. +- The system environment variable names imported for MSVC 7.0 and 6.0 were updated to be + consistent with the variables names defined by their respective installers. This fixes an error + caused when bypassing MSVC detection by specifying the MSVC 7.0 batch file directly. IMPROVEMENTS -- cgit v0.12 From ec58ef74c0be0edc138305ab95ac2f5732bb6cc1 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 20 Mar 2022 10:25:27 -0600 Subject: Fix use of too-new (Py 3.8) pathlib feature Signed-off-by: Mats Wichmann --- SCons/Tool/MSCommon/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/common.py b/SCons/Tool/MSCommon/common.py index 16ed42c..be042f8 100644 --- a/SCons/Tool/MSCommon/common.py +++ b/SCons/Tool/MSCommon/common.py @@ -31,6 +31,7 @@ import os import re import subprocess import sys +from contextlib import suppress from pathlib import Path import SCons.Util @@ -121,7 +122,8 @@ def write_script_env_cache(cache): json.dump(cache, f, indent=2) except TypeError: # data can't serialize to json, don't leave partial file - p.unlink(missing_ok=True) + with suppress(FileNotFoundError): + p.unlink() except IOError: # can't write the file, just skip pass -- cgit v0.12 From 8c2cf586b6cad4d028838c54d1a25e3320585da7 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Mon, 21 Mar 2022 12:31:29 -0400 Subject: Bypass msvc detection and environment processing with a user-provided dictionary via the MSVC_USE_SETTINGS variable. MSVC_USE_SETTINGS is ignored when MSVC_USE_SCRIPT is defined or MSVC_USE_SETTINGS is None. Raise an MSVCUseSettingsError exception if MSVC_USE_SETTINGS is not a dictionary upon usage. --- SCons/Tool/MSCommon/vc.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index fe31cb3..860ffdd 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -79,6 +79,9 @@ class BatchFileExecutionError(VisualCException): class MSVCScriptNotFound(VisualCException): pass +class MSVCUseSettingsError(VisualCException): + pass + # Dict to 'canonalize' the arch _ARCH_TO_CANONICAL = { "amd64" : "amd64", @@ -920,6 +923,39 @@ def msvc_find_valid_batch_script(env, version): return d +_undefined = None + +def get_use_script_use_settings(env): + global _undefined + + if _undefined is None: + _undefined = object() + + # use_script use_settings return values + # value n/a (value, None) + # undefined undefined (True, None) + # undefined None (True, None) + # undefined not None (False, value) + + use_script = env.get('MSVC_USE_SCRIPT', _undefined) + use_settings = env.get('MSVC_USE_SETTINGS', _undefined) + + if use_script != _undefined: + # use_script defined, use_settings ignored + use_settings = None + elif use_settings == _undefined: + # use_script undefined, use_settings undefined + use_script = True + use_settings = None + elif use_settings is None: + # use script undefined, use_settings defined (None) + use_script = True + else: + # use script undefined, use_settings defined (not None) + use_script = False + + return use_script, use_settings + def msvc_setup_env(env): debug('called') @@ -937,7 +973,7 @@ def msvc_setup_env(env): env['MSVS'] = {} - use_script = env.get('MSVC_USE_SCRIPT', True) + use_script, use_settings = get_use_script_use_settings(env) if SCons.Util.is_String(use_script): use_script = use_script.strip() if not os.path.exists(use_script): @@ -950,6 +986,12 @@ def msvc_setup_env(env): debug('use_script 2 %s', d) if not d: return d + elif use_settings is not None: + if not SCons.Util.is_Dict(use_settings): + error_msg = 'MSVC_USE_SETTINGS type error: expected a dictionary, found {}'.format(type(use_settings).__name__) + raise MSVCUseSettingsError(error_msg) + d = use_settings + debug('use_settings %s', d) else: debug('MSVC_USE_SCRIPT set to False') warn_msg = "MSVC_USE_SCRIPT set to False, assuming environment " \ -- cgit v0.12 From 253a06db97698f0da1abab5d69807dc6faac1001 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Tue, 22 Mar 2022 10:08:24 -0400 Subject: Combine MSVC_USE_SETTINGS undefined and None. Additional comments describing behavior. --- SCons/Tool/MSCommon/vc.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 860ffdd..e5f229d 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -931,27 +931,26 @@ def get_use_script_use_settings(env): if _undefined is None: _undefined = object() - # use_script use_settings return values - # value n/a (value, None) - # undefined undefined (True, None) - # undefined None (True, None) - # undefined not None (False, value) + # use_script use_settings return values + # value ignore (value, None) + # undefined undefined/None (True, None) + # undefined value not None (False, value) + # None (documentation) or evaluates False (code): bypass detection + # distinguish between undefined and defined as evaluates False use_script = env.get('MSVC_USE_SCRIPT', _undefined) - use_settings = env.get('MSVC_USE_SETTINGS', _undefined) + + # undefined or None: use settings ignored + use_settings = env.get('MSVC_USE_SETTINGS', None) if use_script != _undefined: - # use_script defined, use_settings ignored - use_settings = None - elif use_settings == _undefined: - # use_script undefined, use_settings undefined - use_script = True + # use_script defined, use_settings ignored (not type checked) use_settings = None elif use_settings is None: - # use script undefined, use_settings defined (None) + # use script undefined, use_settings undefined or None use_script = True else: - # use script undefined, use_settings defined (not None) + # use script undefined, use_settings defined and not None (type checked) use_script = False return use_script, use_settings -- cgit v0.12 From 39fa3174f45a03f34c3ff6137f709de5084ab2cd Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Fri, 25 Mar 2022 09:04:07 -0400 Subject: Add documentation for MSVC_USE_SETTINGS. --- SCons/Tool/msvc.xml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/SCons/Tool/msvc.xml b/SCons/Tool/msvc.xml index 2b2b070..0dad6eb 100644 --- a/SCons/Tool/msvc.xml +++ b/SCons/Tool/msvc.xml @@ -422,6 +422,31 @@ Provides arguments passed to the script &cv-link-MSVC_USE_SCRIPT;. + + + +Use a dictionary to set up the Microsoft Visual C++ compiler. + + +&cv-MSVC_USE_SETTINGS; is ignored when &cv-link-MSVC_USE_SCRIPT; is defined +and/or when &cv-MSVC_USE_SETTINGS; is set to None. + + +The dictionary is used to populate the environment with the relevant variables +(typically %INCLUDE%, %LIB%, and %PATH%) +for supplying to the build. This can be useful to force the use of a compiler environment +that &SCons; does not configure correctly. This is an alternative to manually configuring +the environment when bypassing Visual Studio autodetection entirely by setting +&cv-link-MSVC_USE_SCRIPT; to None. + + +Note: the dictionary content requirements are based on the internal msvc implementation and +therefore may change at any time. The burden is on the user to ensure the dictionary contents +are minimally sufficient to ensure successful builds. + + + +