Skip to content

Commit f9b68fe

Browse files
committed
MSVS/MSVC: msvs tool, msvs tests, and msvc detection fixes
Updates: * Fix issue SCons#2755: the msvs tool no longer writes the OS environment SCONS_HOME value into the SCons environment when the SCONS_HOME variable already exists in the SCons environment. * Update the windows registry keys for detection of Visual Studio 2015 Express ('14.0Exp'): the VS2015 registry key ('WDExpress') appears to be different than the registry key ('VCExpress') for earlier Visual Studio express versions. * Fix the vs-6.0-exec.py test script: the msvs generated project is 'foo.dsp' and the command-line invocation of the Visual Studio development environment program was attempting to build 'test.dsp'. * Update the msvs project generation test scripts: the msvs project execution tests could produce a "false positive" test result when the test executable is correctly built via the SConstruct env.Program() call and the command-line invocation of the Visual Studio development environment program fails.
1 parent 6cbb718 commit f9b68fe

20 files changed

+136
-7
lines changed

CHANGES.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support
88
NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer supported
99

1010
RELEASE VERSION/DATE TO BE FILLED IN LATER
11+
12+
From Joseph Brill:
13+
- Fix issue #2755: the msvs tool no longer writes the OS environment SCONS_HOME
14+
value into the SCons environment when the SCONS_HOME variable already exists
15+
in the SCons environment. Prior to this change, a valid user-defined SCons
16+
environment value for SCONS_HOME would be overwritten with the OS environment
17+
value of SCONS_HOME which could be None (i.e., undefined).
18+
- Update the windows registry keys for detection of Visual Studio 2015 Express
19+
('14.0Exp'): the VS2015 registry key ('WDExpress') appears to be different
20+
than the registry key ('VCExpress') for earlier Visual Studio express
21+
versions. The registry key value is relative to the installation root rather
22+
than the VC folder and requires additional path components during evaluation.
23+
- Fix the vs-6.0-exec.py test script: the msvs generated project is 'foo.dsp'
24+
and the command-line invocation of the Visual Studio development environment
25+
program was attempting to build 'test.dsp'. The command-line invocation was
26+
changed to build 'foo.dsp'.
27+
- Update the msvs project generation test scripts: the msvs project execution
28+
tests could produce a "false positive" test result when the test executable is
29+
correctly built via the SConstruct env.Program() call and the command-line
30+
invocation of the Visual Studio development environment program fails. The
31+
test passes due to the existence of the test executable from the initial
32+
build. The tests were modified to delete the test executable, object file,
33+
and sconsign file prior to the command-line invocation of the VS development
34+
binary.
35+
1136
From Michał Górny:
1237
- Remove unecessary dependencies on pypi packages from setup.cfg
1338

RELEASE.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ FIXES
3434

3535
- Fix of the --debug=sconscript option to return exist statements when using return
3636
statement with stop flag enabled
37+
- MSVS: prevent overwriting the SCons environment variable SCONS_HOME with the OS
38+
environment value of SCONS_HOME in the msvs tool.
39+
- MSVC: Fix the detection of Visual Studio 2015 Express ('14.0Exp') by adding a
40+
registry key definition and updating the installation root-relative registry value
41+
at runtime for the location of the VC folder.
42+
- MSVS: Fix the msvs project generation test for MSVS 6.0 to use the correct name of
43+
the generated project file.
44+
- MSVS: Fix the msvs project generation test scripts so that "false positive" tests
45+
results are not possible when the initial build is successful and the command-line
46+
build of the project file fails.
3747

3848
IMPROVEMENTS
3949
------------

SCons/Tool/MSCommon/vc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ def _skip_sendtelemetry(env):
718718
'14.0': [
719719
(SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\14.0\Setup\VC\ProductDir')],
720720
'14.0Exp': [
721+
(SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\WDExpress\14.0\Setup\VS\ProductDir'),
721722
(SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\14.0\Setup\VC\ProductDir')],
722723
'12.0': [
723724
(SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\12.0\Setup\VC\ProductDir'),
@@ -905,9 +906,14 @@ def find_vc_pdir(env, msvc_version):
905906
except OSError:
906907
debug('no VC registry key %s', repr(key))
907908
else:
908-
if msvc_version == '9.0' and key.lower().endswith('\\vcforpython\\9.0\\installdir'):
909-
# Visual C++ for Python registry key is installdir (root) not productdir (vc)
910-
comps = os.path.join(comps, 'VC')
909+
if msvc_version == '9.0':
910+
if key.lower().endswith('\\vcforpython\\9.0\\installdir'):
911+
# Visual C++ for Python registry key is installdir (root) not productdir (vc)
912+
comps = os.path.join(comps, 'VC')
913+
elif msvc_version == '14.0Exp':
914+
if key.lower().endswith('\\setup\\vs\\productdir'):
915+
# Visual Studio 14.0 Express registry key is installdir (root) not productdir (vc)
916+
comps = os.path.join(comps, 'VC')
911917
debug('found VC in registry: %s', comps)
912918
if os.path.exists(comps):
913919
return comps

SCons/Tool/msvs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def msvs_parse_version(s):
145145
# the MSVS Project file invoke SCons the same way that scons.bat does,
146146
# which works regardless of how we were invoked.
147147
def getExecScriptMain(env, xml=None):
148+
if 'SCONS_HOME' not in env:
149+
env['SCONS_HOME'] = os.environ.get('SCONS_HOME')
148150
scons_home = env.get('SCONS_HOME')
149151
if not scons_home and 'SCONS_LIB_DIR' in os.environ:
150152
scons_home = os.environ['SCONS_LIB_DIR']
@@ -2109,7 +2111,9 @@ def generate(env) -> None:
21092111
env['GET_MSVSSOLUTIONSUFFIX'] = GetMSVSSolutionSuffix
21102112
env['MSVSPROJECTSUFFIX'] = '${GET_MSVSPROJECTSUFFIX}'
21112113
env['MSVSSOLUTIONSUFFIX'] = '${GET_MSVSSOLUTIONSUFFIX}'
2112-
env['SCONS_HOME'] = os.environ.get('SCONS_HOME')
2114+
2115+
if 'SCONS_HOME' not in env:
2116+
env['SCONS_HOME'] = os.environ.get('SCONS_HOME')
21132117

21142118
def exists(env):
21152119
return msvc_setup_env_tool(env, tool=tool_name)

test/MSVS/vs-10.0-exec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@
9090

9191
test.run(chdir='sub dir', arguments='.')
9292

93+
for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
94+
filepath = test.workpath('sub dir', filename)
95+
if os.path.exists(filepath):
96+
test.unlink(filepath)
97+
9398
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9499

95100
import SCons.Platform.win32

test/MSVS/vs-10.0Exp-exec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191

9292
test.run(chdir='sub dir', arguments='.')
9393

94+
for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
95+
filepath = test.workpath('sub dir', filename)
96+
if os.path.exists(filepath):
97+
test.unlink(filepath)
98+
9499
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
95100

96101
import SCons.Platform.win32

test/MSVS/vs-11.0-exec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191

9292
test.run(chdir='sub dir', arguments='.')
9393

94+
for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
95+
filepath = test.workpath('sub dir', filename)
96+
if os.path.exists(filepath):
97+
test.unlink(filepath)
98+
9499
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
95100

96101
import SCons.Platform.win32

test/MSVS/vs-11.0Exp-exec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191

9292
test.run(chdir='sub dir', arguments='.')
9393

94+
for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
95+
filepath = test.workpath('sub dir', filename)
96+
if os.path.exists(filepath):
97+
test.unlink(filepath)
98+
9499
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
95100

96101
import SCons.Platform.win32

test/MSVS/vs-14.0-exec.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@
9292

9393
test.run(chdir='sub dir', arguments='.')
9494

95+
for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
96+
filepath = test.workpath('sub dir', filename)
97+
if os.path.exists(filepath):
98+
test.unlink(filepath)
99+
95100
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
96101

97102
import SCons.Platform.win32

test/MSVS/vs-14.0Exp-exec.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@
5555

5656
test.run(arguments = '-n -q -Q -f -', stdin = """\
5757
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
58-
sconsEnv = repr(env['ENV'])
59-
print("os.environ.update(" + sconsEnv + ")")
58+
if env.WhereIs('cl'):
59+
print("os.environ.update(%%s)" %% repr(env['ENV']))
6060
""" % locals())
6161

62+
if test.stdout() == "":
63+
msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
64+
test.skip_test(msg)
65+
6266
exec(test.stdout())
6367

6468

@@ -88,6 +92,11 @@
8892

8993
test.run(chdir='sub dir', arguments='.')
9094

95+
for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'):
96+
filepath = test.workpath('sub dir', filename)
97+
if os.path.exists(filepath):
98+
test.unlink(filepath)
99+
91100
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
92101

93102
import SCons.Platform.win32

0 commit comments

Comments
 (0)