Skip to content

Commit 3236d7a

Browse files
authored
Merge pull request SCons#4453 from jcbrill/jbrill-msvs-sconshome
Fix 2755: msvs tool, msvs tests, and msvc detection fixes
2 parents fe942c4 + 06e47f7 commit 3236d7a

22 files changed

+214
-9
lines changed

CHANGES.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
1414
of _ListVariable class
1515

1616
From Joseph Brill:
17+
- Fix issue #2755: the msvs tool no longer writes the OS environment SCONS_HOME
18+
value into the SCons environment when the SCONS_HOME variable already exists
19+
in the SCons environment. Prior to this change, a valid user-defined SCons
20+
environment value for SCONS_HOME would be overwritten with the OS environment
21+
value of SCONS_HOME which could be None (i.e., undefined).
22+
- Update the windows registry keys for detection of Visual Studio 2015 Express
23+
('14.0Exp'): the VS2015 registry key ('WDExpress') appears to be different
24+
than the registry key ('VCExpress') for earlier Visual Studio express
25+
versions. The registry key value is relative to the installation root rather
26+
than the VC folder and requires additional path components during evaluation.
27+
- Fix the vs-6.0-exec.py test script: the msvs generated project is 'foo.dsp'
28+
and the command-line invocation of the Visual Studio development environment
29+
program was attempting to build 'test.dsp'. The command-line invocation was
30+
changed to build 'foo.dsp'.
31+
- Update the msvs project generation test scripts: the msvs project execution
32+
tests could produce a "false positive" test result when the test executable is
33+
correctly built via the SConstruct env.Program() call and the command-line
34+
invocation of the Visual Studio development environment program fails. The
35+
test passes due to the existence of the test executable from the initial
36+
build. The tests were modified to delete the test executable, object file,
37+
and sconsign file prior to the command-line invocation of the VS development
38+
binary.
39+
- Method unlink_files was added to the TestCmd class that unlinks a list of
40+
files from a specified directory. An attempt to unlink a file is made only
41+
when the file exists; otherwise, the file is ignored.
1742
- Fix issue #4320: add an optional argument list string to configure's CheckFunc
1843
method so that the generated function argument list matches the function's
1944
prototype when including a header file.
@@ -29,7 +54,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
2954
statement with stop flag enabled
3055

3156

32-
3357
RELEASE 4.6.0 - Sun, 19 Nov 2023 17:22:20 -0700
3458

3559
From Max Bachmann:

RELEASE.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ Here is a summary of the changes since 4.6.0:
1616
NEW FUNCTIONALITY
1717
-----------------
1818

19-
- List new features (presumably why a checkpoint is being released)
19+
- Method unlink_files was added to the TestCmd class that unlinks a list of files
20+
from a specified directory. An attempt to unlink a file is made only when the
21+
file exists; otherwise, the file is ignored.
22+
2023

2124
DEPRECATED FUNCTIONALITY
2225
------------------------
@@ -35,6 +38,16 @@ FIXES
3538

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

3952
IMPROVEMENTS
4053
------------

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090

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

93+
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
94+
9395
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9496

9597
import SCons.Platform.win32

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

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

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

94+
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
95+
9496
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9597

9698
import SCons.Platform.win32

test/MSVS/vs-11.0-exec.py

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

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

94+
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
95+
9496
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9597

9698
import SCons.Platform.win32

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

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

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

94+
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
95+
9496
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9597

9698
import SCons.Platform.win32

test/MSVS/vs-14.0-exec.py

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

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

95+
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
96+
9597
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9698

9799
import SCons.Platform.win32

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

Lines changed: 8 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,8 @@
8892

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

95+
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
96+
9197
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9298

9399
import SCons.Platform.win32

0 commit comments

Comments
 (0)