diff options
author | Mats Wichmann <mats@linux.com> | 2020-03-17 14:22:08 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2020-03-17 14:28:04 (GMT) |
commit | b18601eb0e057afcbdbc92ff516742767361f192 (patch) | |
tree | 8ece6d4dcdd0d9a38832d578daa3841cd7bbc997 | |
parent | 735147d4d6434ba236571be3ec88f2ec53ea6554 (diff) | |
download | SCons-b18601eb0e057afcbdbc92ff516742767361f192.zip SCons-b18601eb0e057afcbdbc92ff516742767361f192.tar.gz SCons-b18601eb0e057afcbdbc92ff516742767361f192.tar.bz2 |
[PR #3576] add powershell path
We pass a very minimal PATH to the call to vcvars*. Apparently
there are circumstances where not having Powershell in it
can cause failures (relates to the same telemetry call that
is the subject of this PR).
Signed-off-by: Mats Wichmann <mats@linux.com>
-rwxr-xr-x | src/CHANGES.txt | 5 | ||||
-rw-r--r-- | src/engine/SCons/Tool/MSCommon/common.py | 25 |
2 files changed, 18 insertions, 12 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 958a475..2147f49 100755 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -84,8 +84,9 @@ From Rob Boehne - Fixed bug where changing TEXTFILESUFFIX would cause Substfile() to rebuild. (Github Issue #3540) - Script/Main.py now uses importlib instead of imp module. - Drop some Python 2-isms. - - Pass on VSCMD_DEBUG and VSCMD_SKIP_SENDTELEMETRY to msvc tool setup - if set in environment. + - MSVC updates: pass on VSCMD_DEBUG and VSCMD_SKIP_SENDTELEMETRY to msvc + tool setup if set in environment. Add powershell to default env + (used to call telemetry script). RELEASE 3.1.2 - Mon, 17 Dec 2019 02:06:27 +0000 diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index 422d897..c066fd8 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -156,15 +156,14 @@ def normalize_env(env, keys, force=False): if k in os.environ and (force or k not in normenv): normenv[k] = os.environ[k] - # This shouldn't be necessary, since the default environment should include system32, - # but keep this here to be safe, since it's needed to find reg.exe which the MSVC - # bat scripts use. - sys32_dir = os.path.join(os.environ.get("SystemRoot", - os.environ.get("windir", r"C:\Windows\system32")), - "System32") - - if sys32_dir not in normenv['PATH']: - normenv['PATH'] = normenv['PATH'] + os.pathsep + sys32_dir + # add some things to PATH to prevent problems: + # Shouldn't be necessary to add system32, since the default environment + # should include it, but keep this here to be safe (needed for reg.exe) + sys32_dir = os.path.join( + os.environ.get("SystemRoot", os.environ.get("windir", r"C:\Windows")), "System32" +) + if sys32_dir not in normenv["PATH"]: + normenv["PATH"] = normenv["PATH"] + os.pathsep + sys32_dir # Without Wbem in PATH, vcvarsall.bat has a "'wmic' is not recognized" # error starting with Visual Studio 2017, although the script still @@ -173,8 +172,14 @@ def normalize_env(env, keys, force=False): if sys32_wbem_dir not in normenv['PATH']: normenv['PATH'] = normenv['PATH'] + os.pathsep + sys32_wbem_dir - debug("PATH: %s" % normenv['PATH']) + # Without Powershell in PATH, an internal call to a telemetry + # function (starting with a VS2019 update) can fail + # Note can also set VSCMD_SKIP_SENDTELEMETRY to avoid this. + sys32_ps_dir = os.path.join(sys32_dir, r'WindowsPowerShell\1.0') + if sys32_ps_dir not in normenv['PATH']: + normenv['PATH'] = normenv['PATH'] + os.pathsep + sys32_ps_dir + debug("PATH: %s" % normenv['PATH']) return normenv |