From 76f770a7b4bbaaea25ef2670958b9136eea7049a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 30 Aug 2021 10:39:14 -0700 Subject: add logic to ensure PCH is subst() evaluated when it should be --- CHANGES.txt | 19 ++++----- RELEASE.txt | 2 + test/MSVC/msvc.py | 69 +++----------------------------- test/MSVC/msvc_fixture/SConstruct | 15 +++++++ test/MSVC/msvc_fixture/StdAfx.cpp | 4 ++ test/MSVC/msvc_fixture/StdAfx.h | 3 ++ test/MSVC/msvc_fixture/foo.cpp | 1 + test/MSVC/msvc_fixture/resource.h | 1 + test/MSVC/msvc_fixture/sconstest.skip | 0 test/MSVC/msvc_fixture/test.cpp | 10 +++++ test/MSVC/msvc_fixture/test.rc | 6 +++ test/MSVC/pch_gen/fixture/SConstruct | 19 +++++++++ test/MSVC/pch_gen/fixture/sconstest.skip | 0 test/MSVC/pch_gen/pch_gen.py | 50 +++++++++++++++++++++++ 14 files changed, 126 insertions(+), 73 deletions(-) create mode 100644 test/MSVC/msvc_fixture/SConstruct create mode 100644 test/MSVC/msvc_fixture/StdAfx.cpp create mode 100644 test/MSVC/msvc_fixture/StdAfx.h create mode 100644 test/MSVC/msvc_fixture/foo.cpp create mode 100644 test/MSVC/msvc_fixture/resource.h create mode 100644 test/MSVC/msvc_fixture/sconstest.skip create mode 100644 test/MSVC/msvc_fixture/test.cpp create mode 100644 test/MSVC/msvc_fixture/test.rc create mode 100644 test/MSVC/pch_gen/fixture/SConstruct create mode 100644 test/MSVC/pch_gen/fixture/sconstest.skip create mode 100644 test/MSVC/pch_gen/pch_gen.py diff --git a/CHANGES.txt b/CHANGES.txt index 6ac5519..511ef6a 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,9 +13,19 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix reproducible builds. Restore logic respecting SOURCE_DATE_EPOCH when set. - Fix version tests to work with updated scons --version output. (Date format changed) + From Ryan Egesdahl: + - Small fix to ensure CLVar default value is an empty list. + See MongoDB bug report: https://jira.mongodb.org/browse/SERVER-59656 + Code contributed by MongoDB. + + From Aaron Franke: + - Define HOST_OS and HOST_ARCH in the environment for all platforms. + Before this change, these were only defined for Win32 and OS/2. + From Daniel Moody: - Fix ninja tool to never use for_sig substitution because ninja does not use signatures. This issue affected CommandGeneratorAction function actions specifically. + - Added support for the PCH environment variable to support subst generators. From Mats Wichmann: - Two small Python 3.10 fixes: one more docstring turned into raw @@ -24,15 +34,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - EmitterProxy rich comparison set is completed (checker warning). Added __le__, __gt__, __ge__. - From Aaron Franke: - - Define HOST_OS and HOST_ARCH in the environment for all platforms. - Before this change, these were only defined for Win32 and OS/2. - - From Ryan Egesdahl: - - Small fix to ensure CLVar default value is an empty list. - See MongoDB bug report: https://jira.mongodb.org/browse/SERVER-59656 - Code contributed by MongoDB. - RELEASE 4.2.0 - Sat, 31 Jul 2021 18:12:46 -0700 From Byron Platt: diff --git a/RELEASE.txt b/RELEASE.txt index faa017f..9f620d9 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -31,6 +31,8 @@ FIXES Code contributed by MongoDB. - Fix ninja tool to never use for_sig substitution because ninja does not use signatures. This issue affected CommandGeneratorAction function actions specifically. +- Fix PCH not being evaluated by subst() where necessary. + IMPROVEMENTS ------------ diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index 3b32046..b870b77 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -26,7 +28,6 @@ Verify basic invocation of Microsoft Visual C/C++, including use of a precompiled header with the $CCFLAGS variable. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import time @@ -36,71 +37,11 @@ test = TestSCons.TestSCons(match = TestSCons.match_re) test.skip_if_not_msvc() +test.dir_fixture('msvc_fixture') + ##### # Test the basics -test.write('SConstruct',""" -import os -DefaultEnvironment(tools=[]) -# TODO: this is order-dependent (putting 'mssdk' second or third breaks), -# and ideally we shouldn't need to specify the tools= list anyway. -env = Environment(tools=['mssdk', 'msvc', 'mslink']) -env.Append(CPPPATH=os.environ.get('INCLUDE', ''), - LIBPATH=os.environ.get('LIB', ''), - CCFLAGS='/DPCHDEF') -env['PDB'] = File('test.pdb') -env['PCHSTOP'] = 'StdAfx.h' -env['PCH'] = env.PCH('StdAfx.cpp')[0] -env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) - -env.Object('fast', 'foo.cpp') -env.Object('slow', 'foo.cpp', PCH=0) -""") - -test.write('test.cpp', ''' -#include "StdAfx.h" -#include "resource.h" - -int main(void) -{ - char test[1024]; - LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); - printf("%d %s\\n", IDS_TEST, test); - return 0; -} -''') - -test.write('test.rc', ''' -#include "resource.h" - -STRINGTABLE DISCARDABLE -BEGIN - IDS_TEST "test 1" -END -''') - -test.write('resource.h', ''' -#define IDS_TEST 2001 -''') - - -test.write('foo.cpp', ''' -#include "StdAfx.h" -''') - -test.write('StdAfx.h', ''' -#include -#include -#include "resource.h" -''') - -test.write('StdAfx.cpp', ''' -#include "StdAfx.h" -#ifndef PCHDEF -this line generates an error if PCHDEF is not defined! -#endif -''') - # Visual Studio 8 has deprecated the /Yd option and prints warnings # about it, so ignore stderr when running SCons. diff --git a/test/MSVC/msvc_fixture/SConstruct b/test/MSVC/msvc_fixture/SConstruct new file mode 100644 index 0000000..2a63180 --- /dev/null +++ b/test/MSVC/msvc_fixture/SConstruct @@ -0,0 +1,15 @@ +import os +DefaultEnvironment(tools=[]) +# TODO: this is order-dependent (putting 'mssdk' second or third breaks), +# and ideally we shouldn't need to specify the tools= list anyway. +env = Environment(tools=['mssdk', 'msvc', 'mslink']) +env.Append(CPPPATH=os.environ.get('INCLUDE', ''), + LIBPATH=os.environ.get('LIB', ''), + CCFLAGS='/DPCHDEF') +env['PDB'] = File('test.pdb') +env['PCHSTOP'] = 'StdAfx.h' +env['PCH'] = env.PCH('StdAfx.cpp')[0] +env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) + +env.Object('fast', 'foo.cpp') +env.Object('slow', 'foo.cpp', PCH=0) diff --git a/test/MSVC/msvc_fixture/StdAfx.cpp b/test/MSVC/msvc_fixture/StdAfx.cpp new file mode 100644 index 0000000..a6a290b --- /dev/null +++ b/test/MSVC/msvc_fixture/StdAfx.cpp @@ -0,0 +1,4 @@ +#include "StdAfx.h" +#ifndef PCHDEF +this line generates an error if PCHDEF is not defined! +#endif \ No newline at end of file diff --git a/test/MSVC/msvc_fixture/StdAfx.h b/test/MSVC/msvc_fixture/StdAfx.h new file mode 100644 index 0000000..a92d7df --- /dev/null +++ b/test/MSVC/msvc_fixture/StdAfx.h @@ -0,0 +1,3 @@ +#include +#include +#include "resource.h" \ No newline at end of file diff --git a/test/MSVC/msvc_fixture/foo.cpp b/test/MSVC/msvc_fixture/foo.cpp new file mode 100644 index 0000000..09f15b6 --- /dev/null +++ b/test/MSVC/msvc_fixture/foo.cpp @@ -0,0 +1 @@ +#include "StdAfx.h" \ No newline at end of file diff --git a/test/MSVC/msvc_fixture/resource.h b/test/MSVC/msvc_fixture/resource.h new file mode 100644 index 0000000..089e932 --- /dev/null +++ b/test/MSVC/msvc_fixture/resource.h @@ -0,0 +1 @@ +#define IDS_TEST 2001 diff --git a/test/MSVC/msvc_fixture/sconstest.skip b/test/MSVC/msvc_fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/MSVC/msvc_fixture/test.cpp b/test/MSVC/msvc_fixture/test.cpp new file mode 100644 index 0000000..354b5f1 --- /dev/null +++ b/test/MSVC/msvc_fixture/test.cpp @@ -0,0 +1,10 @@ +#include "StdAfx.h" +#include "resource.h" + +int main(void) +{ + char test[1024]; + LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test)); + printf("%d %s\n", IDS_TEST, test); + return 0; +} \ No newline at end of file diff --git a/test/MSVC/msvc_fixture/test.rc b/test/MSVC/msvc_fixture/test.rc new file mode 100644 index 0000000..aec22a2 --- /dev/null +++ b/test/MSVC/msvc_fixture/test.rc @@ -0,0 +1,6 @@ +#include "resource.h" + +STRINGTABLE DISCARDABLE +BEGIN + IDS_TEST "test 1" +END diff --git a/test/MSVC/pch_gen/fixture/SConstruct b/test/MSVC/pch_gen/fixture/SConstruct new file mode 100644 index 0000000..5fea0a8 --- /dev/null +++ b/test/MSVC/pch_gen/fixture/SConstruct @@ -0,0 +1,19 @@ +import os +DefaultEnvironment(tools=[]) +# TODO: this is order-dependent (putting 'mssdk' second or third breaks), +# and ideally we shouldn't need to specify the tools= list anyway. +env = Environment(tools=['mssdk', 'msvc', 'mslink']) +env.Append(CPPPATH=os.environ.get('INCLUDE', ''), + LIBPATH=os.environ.get('LIB', ''), + CCFLAGS='/DPCHDEF') +env['PDB'] = File('test.pdb') +env['PCHSTOP'] = 'StdAfx.h' + +def pch_gen(env, target, source, for_signature): + return 'StdAfx.pch' +env['PCH'] = pch_gen +env.PCH('StdAfx.cpp')[0] +env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32']) + +env.Object('fast', 'foo.cpp') +env.Object('slow', 'foo.cpp', PCH=0) \ No newline at end of file diff --git a/test/MSVC/pch_gen/fixture/sconstest.skip b/test/MSVC/pch_gen/fixture/sconstest.skip new file mode 100644 index 0000000..e69de29 diff --git a/test/MSVC/pch_gen/pch_gen.py b/test/MSVC/pch_gen/pch_gen.py new file mode 100644 index 0000000..9fea9e2 --- /dev/null +++ b/test/MSVC/pch_gen/pch_gen.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Template for end-to-end test file. +Replace this with a description of the test. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.skip_if_not_msvc() + +test.dir_fixture('../msvc_fixture') + +test.file_fixture('fixture/SConstruct', + 'SConstruct') + +test.run(arguments='.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12