From f9b68fef9b08f4bcb523e7315595c23a8c64f4d9 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:20:07 -0500 Subject: MSVS/MSVC: msvs tool, msvs tests, and msvc detection fixes Updates: * Fix issue #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. --- CHANGES.txt | 25 +++++++++++++++++++++++++ RELEASE.txt | 10 ++++++++++ SCons/Tool/MSCommon/vc.py | 12 +++++++++--- SCons/Tool/msvs.py | 6 +++++- test/MSVS/vs-10.0-exec.py | 5 +++++ test/MSVS/vs-10.0Exp-exec.py | 5 +++++ test/MSVS/vs-11.0-exec.py | 5 +++++ test/MSVS/vs-11.0Exp-exec.py | 5 +++++ test/MSVS/vs-14.0-exec.py | 5 +++++ test/MSVS/vs-14.0Exp-exec.py | 13 +++++++++++-- test/MSVS/vs-14.1-exec.py | 5 +++++ test/MSVS/vs-14.2-exec.py | 5 +++++ test/MSVS/vs-14.3-exec.py | 5 +++++ test/MSVS/vs-6.0-exec.py | 7 ++++++- test/MSVS/vs-7.0-exec.py | 5 +++++ test/MSVS/vs-7.1-exec.py | 5 +++++ test/MSVS/vs-8.0-exec.py | 5 +++++ test/MSVS/vs-8.0Exp-exec.py | 5 +++++ test/MSVS/vs-9.0-exec.py | 5 +++++ test/MSVS/vs-9.0Exp-exec.py | 5 +++++ 20 files changed, 136 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 5a9d9e3..40c2d7c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,6 +8,31 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support NOTE: 4.3.0 now requires Python 3.6.0 and above. Python 3.5.x is no longer supported RELEASE VERSION/DATE TO BE FILLED IN LATER + + From Joseph Brill: + - Fix issue #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. Prior to this change, a valid user-defined SCons + environment value for SCONS_HOME would be overwritten with the OS environment + value of SCONS_HOME which could be None (i.e., undefined). + - 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. The registry key value is relative to the installation root rather + than the VC folder and requires additional path components during evaluation. + - 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'. The command-line invocation was + changed to build 'foo.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. The + test passes due to the existence of the test executable from the initial + build. The tests were modified to delete the test executable, object file, + and sconsign file prior to the command-line invocation of the VS development + binary. + From Michał Górny: - Remove unecessary dependencies on pypi packages from setup.cfg diff --git a/RELEASE.txt b/RELEASE.txt index 7599d43..b5e732e 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -34,6 +34,16 @@ FIXES - Fix of the --debug=sconscript option to return exist statements when using return statement with stop flag enabled +- MSVS: prevent overwriting the SCons environment variable SCONS_HOME with the OS + environment value of SCONS_HOME in the msvs tool. +- MSVC: Fix the detection of Visual Studio 2015 Express ('14.0Exp') by adding a + registry key definition and updating the installation root-relative registry value + at runtime for the location of the VC folder. +- MSVS: Fix the msvs project generation test for MSVS 6.0 to use the correct name of + the generated project file. +- MSVS: Fix the msvs project generation test scripts so that "false positive" tests + results are not possible when the initial build is successful and the command-line + build of the project file fails. IMPROVEMENTS ------------ diff --git a/SCons/Tool/MSCommon/vc.py b/SCons/Tool/MSCommon/vc.py index 8780604..e43c618 100644 --- a/SCons/Tool/MSCommon/vc.py +++ b/SCons/Tool/MSCommon/vc.py @@ -718,6 +718,7 @@ _VCVER_TO_PRODUCT_DIR = { '14.0': [ (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\14.0\Setup\VC\ProductDir')], '14.0Exp': [ + (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\WDExpress\14.0\Setup\VS\ProductDir'), (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VCExpress\14.0\Setup\VC\ProductDir')], '12.0': [ (SCons.Util.HKEY_LOCAL_MACHINE, r'Microsoft\VisualStudio\12.0\Setup\VC\ProductDir'), @@ -905,9 +906,14 @@ def find_vc_pdir(env, msvc_version): except OSError: debug('no VC registry key %s', repr(key)) else: - if msvc_version == '9.0' and key.lower().endswith('\\vcforpython\\9.0\\installdir'): - # Visual C++ for Python registry key is installdir (root) not productdir (vc) - comps = os.path.join(comps, 'VC') + if msvc_version == '9.0': + if key.lower().endswith('\\vcforpython\\9.0\\installdir'): + # Visual C++ for Python registry key is installdir (root) not productdir (vc) + comps = os.path.join(comps, 'VC') + elif msvc_version == '14.0Exp': + if key.lower().endswith('\\setup\\vs\\productdir'): + # Visual Studio 14.0 Express registry key is installdir (root) not productdir (vc) + comps = os.path.join(comps, 'VC') debug('found VC in registry: %s', comps) if os.path.exists(comps): return comps diff --git a/SCons/Tool/msvs.py b/SCons/Tool/msvs.py index 16e422d..1297448 100644 --- a/SCons/Tool/msvs.py +++ b/SCons/Tool/msvs.py @@ -145,6 +145,8 @@ def msvs_parse_version(s): # the MSVS Project file invoke SCons the same way that scons.bat does, # which works regardless of how we were invoked. def getExecScriptMain(env, xml=None): + if 'SCONS_HOME' not in env: + env['SCONS_HOME'] = os.environ.get('SCONS_HOME') scons_home = env.get('SCONS_HOME') if not scons_home and 'SCONS_LIB_DIR' in os.environ: scons_home = os.environ['SCONS_LIB_DIR'] @@ -2109,7 +2111,9 @@ def generate(env) -> None: env['GET_MSVSSOLUTIONSUFFIX'] = GetMSVSSolutionSuffix env['MSVSPROJECTSUFFIX'] = '${GET_MSVSPROJECTSUFFIX}' env['MSVSSOLUTIONSUFFIX'] = '${GET_MSVSSOLUTIONSUFFIX}' - env['SCONS_HOME'] = os.environ.get('SCONS_HOME') + + if 'SCONS_HOME' not in env: + env['SCONS_HOME'] = os.environ.get('SCONS_HOME') def exists(env): return msvc_setup_env_tool(env, tool=tool_name) diff --git a/test/MSVS/vs-10.0-exec.py b/test/MSVS/vs-10.0-exec.py index df13454..d439437 100644 --- a/test/MSVS/vs-10.0-exec.py +++ b/test/MSVS/vs-10.0-exec.py @@ -90,6 +90,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-10.0Exp-exec.py b/test/MSVS/vs-10.0Exp-exec.py index 1c3b561..f0b0881 100644 --- a/test/MSVS/vs-10.0Exp-exec.py +++ b/test/MSVS/vs-10.0Exp-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-11.0-exec.py b/test/MSVS/vs-11.0-exec.py index 8286841..f2dfe8e 100644 --- a/test/MSVS/vs-11.0-exec.py +++ b/test/MSVS/vs-11.0-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-11.0Exp-exec.py b/test/MSVS/vs-11.0Exp-exec.py index e7cffad..b16f870 100644 --- a/test/MSVS/vs-11.0Exp-exec.py +++ b/test/MSVS/vs-11.0Exp-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-14.0-exec.py b/test/MSVS/vs-14.0-exec.py index 7e919ba..a11f405 100644 --- a/test/MSVS/vs-14.0-exec.py +++ b/test/MSVS/vs-14.0-exec.py @@ -92,6 +92,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-14.0Exp-exec.py b/test/MSVS/vs-14.0Exp-exec.py index 5d2a585..5c49322 100644 --- a/test/MSVS/vs-14.0Exp-exec.py +++ b/test/MSVS/vs-14.0Exp-exec.py @@ -55,10 +55,14 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -sconsEnv = repr(env['ENV']) -print("os.environ.update(" + sconsEnv + ")") +if env.WhereIs('cl'): + print("os.environ.update(%%s)" %% repr(env['ENV'])) """ % locals()) +if test.stdout() == "": + msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version + test.skip_test(msg) + exec(test.stdout()) @@ -88,6 +92,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-14.1-exec.py b/test/MSVS/vs-14.1-exec.py index 2accaaf..d0324c2 100644 --- a/test/MSVS/vs-14.1-exec.py +++ b/test/MSVS/vs-14.1-exec.py @@ -92,6 +92,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-14.2-exec.py b/test/MSVS/vs-14.2-exec.py index 5a3079d..90c5641 100644 --- a/test/MSVS/vs-14.2-exec.py +++ b/test/MSVS/vs-14.2-exec.py @@ -92,6 +92,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-14.3-exec.py b/test/MSVS/vs-14.3-exec.py index 840b432..164c953 100644 --- a/test/MSVS/vs-14.3-exec.py +++ b/test/MSVS/vs-14.3-exec.py @@ -92,6 +92,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-6.0-exec.py b/test/MSVS/vs-6.0-exec.py index ab70872..38f715d 100644 --- a/test/MSVS/vs-6.0-exec.py +++ b/test/MSVS/vs-6.0-exec.py @@ -90,9 +90,14 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.run(chdir='sub dir', program=[test.get_msvs_executable(msvs_version)], - arguments=['Test.dsp', '/MAKE', 'foo - Win32 Release']) + arguments=['foo.dsp', '/MAKE', 'foo - Win32 Release']) test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n") diff --git a/test/MSVS/vs-7.0-exec.py b/test/MSVS/vs-7.0-exec.py index 3c41aa5..c0340c4 100644 --- a/test/MSVS/vs-7.0-exec.py +++ b/test/MSVS/vs-7.0-exec.py @@ -90,6 +90,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj')) test.run(chdir='sub dir', diff --git a/test/MSVS/vs-7.1-exec.py b/test/MSVS/vs-7.1-exec.py index f66b92d..015840b 100644 --- a/test/MSVS/vs-7.1-exec.py +++ b/test/MSVS/vs-7.1-exec.py @@ -90,6 +90,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj')) test.run(chdir='sub dir', diff --git a/test/MSVS/vs-8.0-exec.py b/test/MSVS/vs-8.0-exec.py index 91e99dd..228800a 100644 --- a/test/MSVS/vs-8.0-exec.py +++ b/test/MSVS/vs-8.0-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-8.0Exp-exec.py b/test/MSVS/vs-8.0Exp-exec.py index 77cae64..ba9aa7a 100644 --- a/test/MSVS/vs-8.0Exp-exec.py +++ b/test/MSVS/vs-8.0Exp-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-9.0-exec.py b/test/MSVS/vs-9.0-exec.py index 26a115d..75d7bb7 100644 --- a/test/MSVS/vs-9.0-exec.py +++ b/test/MSVS/vs-9.0-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj')) import SCons.Platform.win32 diff --git a/test/MSVS/vs-9.0Exp-exec.py b/test/MSVS/vs-9.0Exp-exec.py index 0c274ba..36d0367 100644 --- a/test/MSVS/vs-9.0Exp-exec.py +++ b/test/MSVS/vs-9.0Exp-exec.py @@ -91,6 +91,11 @@ main(int argc, char *argv) test.run(chdir='sub dir', arguments='.') +for filename in ('foo.exe', 'foo.obj', '.sconsign.dblite'): + filepath = test.workpath('sub dir', filename) + if os.path.exists(filepath): + test.unlink(filepath) + test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcproj')) import SCons.Platform.win32 -- cgit v0.12