summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2021-09-06 20:08:50 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2021-09-18 23:48:01 (GMT)
commit7d06a82467097fee7178d3d41414a6fa8781cd62 (patch)
treeb4be0fba5339b6b0d0a211ddfd1f7a93a8671383 /test
parentd9e034fb0a6b4bb94997f7f4e98802c08bdbc507 (diff)
downloadSCons-7d06a82467097fee7178d3d41414a6fa8781cd62.zip
SCons-7d06a82467097fee7178d3d41414a6fa8781cd62.tar.gz
SCons-7d06a82467097fee7178d3d41414a6fa8781cd62.tar.bz2
add test to verify that a generator specified for PCH with returns a false value will disable PCH being added to compile and link lines
Diffstat (limited to 'test')
-rw-r--r--test/MSVC/pch_gen/fixture/SConstruct35
-rw-r--r--test/MSVC/pch_gen/pch_gen.py7
2 files changed, 32 insertions, 10 deletions
diff --git a/test/MSVC/pch_gen/fixture/SConstruct b/test/MSVC/pch_gen/fixture/SConstruct
index f0b3738..16b708c 100644
--- a/test/MSVC/pch_gen/fixture/SConstruct
+++ b/test/MSVC/pch_gen/fixture/SConstruct
@@ -3,16 +3,31 @@
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(CCFLAGS='/DPCHDEF')
-env['PDB'] = File('test.pdb')
-env['PCHSTOP'] = 'StdAfx.h'
+
+
+# Add flag to cause pch_gen to return empty string
+# This will enable testing that PCH if subst'd yields empty string will stop
+# PCH from being enabled.
+vars = Variables(None, ARGUMENTS)
+vars.AddVariables(BoolVariable("DISABLE_PCH", help="Disable PCH functionality", default=False))
+
+
+env = Environment(variables=vars, tools=["mssdk", "msvc", "mslink"])
+env.Append(CCFLAGS="/DPCHDEF")
+env["PDB"] = File("test.pdb")
+env["PCHSTOP"] = "StdAfx.h"
+
def pch_gen(env, target, source, for_signature):
- return 'StdAfx-1.pch'
-env['PCH'] = pch_gen
-env.PCH('StdAfx-1.pch', 'StdAfx.cpp')[0]
-env.Program('test', ['test.cpp', env.RES('test.rc')], LIBS=['user32'])
+ if env['DISABLE_PCH']:
+ return ""
+ else:
+ return "StdAfx-1.pch"
+
+
+env["PCH"] = pch_gen
+env.PCH("StdAfx-1.pch", "StdAfx.cpp")
+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
+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/pch_gen.py b/test/MSVC/pch_gen/pch_gen.py
index b6da454..7ec2373 100644
--- a/test/MSVC/pch_gen/pch_gen.py
+++ b/test/MSVC/pch_gen/pch_gen.py
@@ -49,6 +49,13 @@ test.must_exist(test.workpath('test.pdb'))
test.must_exist(test.workpath('StdAfx-1.pch'))
test.must_exist(test.workpath('StdAfx-1.obj'))
+test.run(arguments="-c .")
+test.run(arguments="DISABLE_PCH=1 .")
+
+test.must_exist(test.workpath('test.exe'))
+test.must_exist(test.workpath('test.res'))
+test.must_exist(test.workpath('test.pdb'))
+test.fail_test(condition = ('/YuStdAfx.h' in test.stdout()), message="Shouldn't have /YuStdAfx.h in compile line when PCH is disabled")
test.pass_test()