diff options
author | Steven Knight <knight@baldmt.com> | 2009-01-09 16:43:32 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2009-01-09 16:43:32 (GMT) |
commit | 7ab76c68556e5f6f142515872ea6334e959b8626 (patch) | |
tree | c4d23aed9df4381a24cac247b11dd1a4c245908a /test/MSVC | |
parent | e04fb604484cf37da383a38ef9b2bd8c9ef6c175 (diff) | |
download | SCons-7ab76c68556e5f6f142515872ea6334e959b8626.zip SCons-7ab76c68556e5f6f142515872ea6334e959b8626.tar.gz SCons-7ab76c68556e5f6f142515872ea6334e959b8626.tar.bz2 |
Issue 1086: add support for generic batch build actions, and
specific support for batched compilation for Microsoft Visual C/C++.
Merged revisions 3819-3851,3854-3869,3871-3877,3880 via svnmerge from
http://scons.tigris.org/svn/scons/branches/sgk_batch
........
r3820 | stevenknight | 2008-12-09 23:59:14 -0800 (Tue, 09 Dec 2008) | 6 lines
Issue 1086: Batch compilation support:
* $MSVC_BATCH to control Visual C/C++ batch compilation.
* New $CHANGED_SOURCES, $CHANGED_TARGETS, $UNCHANGED_SOURCES and
$UNCHANGED_TARGETS construction variables.
* New Action(batch_key=, targets=) keyword arguments.
........
r3880 | stevenknight | 2009-01-07 20:50:41 -0800 (Wed, 07 Jan 2009) | 3 lines
Use UniqueList objects to collect the all_children(), all_prerequisites()
and all_sources() lists instead of calling uniquer_hashables() by hand.
........
Diffstat (limited to 'test/MSVC')
-rw-r--r-- | test/MSVC/batch.py | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/test/MSVC/batch.py b/test/MSVC/batch.py new file mode 100644 index 0000000..3776df7 --- /dev/null +++ b/test/MSVC/batch.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify operation of Visual C/C++ batch builds. + +This uses a fake compiler and linker script, fake command lines, and +explicit suffix settings so that the test should work when run on any +platform. +""" + +import string + +import TestSCons + +test = TestSCons.TestSCons() + +_python_ = TestSCons._python_ + +test.write('fake_cl.py', """\ +import os +import string +import sys +input_files = sys.argv[2:] +if sys.argv[1][-1] in (os.sep, '\\\\'): + # The output (/Fo) argument ends with a backslash, indicating an + # output directory. We accept ending with a slash as well so this + # test runs on non-Windows systems. Strip either character and + # record the directory name. + sys.argv[1] = sys.argv[1][:-1] + dir = sys.argv[1][3:] +else: + dir = None + output = sys.argv[1][3:] +# Delay writing the .log output until here so any trailing slash or +# backslash has been stripped, and the output comparisons later in this +# script don't have to account for the difference. +open('fake_cl.log', 'ab').write(string.join(sys.argv[1:]) + '\\n') +for infile in input_files: + if dir: + outfile = os.path.join(dir, string.replace(infile, '.c', '.obj')) + else: + outfile = output + open(outfile, 'wb').write(open(infile, 'rb').read()) +""") + +test.write('fake_link.py', """\ +import string +import sys +ofp = open(sys.argv[1], 'wb') +for infile in sys.argv[2:]: + ofp.write(open(infile, 'rb').read()) +""") + +test.write('SConstruct', """ +cccom = '%(_python_)s fake_cl.py $_MSVC_OUTPUT_FLAG $CHANGED_SOURCES' +linkcom = '%(_python_)s fake_link.py ${TARGET.windows} $SOURCES' +env = Environment(tools=['msvc', 'mslink'], + CCCOM=cccom, + LINKCOM=linkcom, + PROGSUFFIX='.exe', + OBJSUFFIX='.obj', + MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH')) +p = env.Object('prog.c') +f1 = env.Object('f1.c') +f2 = env.Object('f2.c') +env.Program(p + f1 + f2) +""" % locals()) + +test.write('prog.c', "prog.c\n") +test.write('f1.c', "f1.c\n") +test.write('f2.c', "f2.c\n") + + + +test.run(arguments = 'MSVC_BATCH=1 .') + +test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n") +test.must_match('fake_cl.log', """\ +/Fo. prog.c f1.c f2.c +""") + +test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') + + + +test.write('f1.c', "f1.c 2\n") + +test.run(arguments = 'MSVC_BATCH=1 .') + +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('fake_cl.log', """\ +/Fo. prog.c f1.c f2.c +/Fo. f1.c +""") + +test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.') + + + +test.run(arguments = '-c .') + +test.unlink('fake_cl.log') + + + +test.run(arguments = '. MSVC_BATCH=0') + +test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n") +test.must_match('fake_cl.log', """\ +/Fof1.obj f1.c +/Fof2.obj f2.c +/Foprog.obj prog.c +""") + + + +test.write('f1.c', "f1.c 3\n") + +test.run(arguments = '. MSVC_BATCH=0') + +test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n") +test.must_match('fake_cl.log', """\ +/Fof1.obj f1.c +/Fof2.obj f2.c +/Foprog.obj prog.c +/Fof1.obj f1.c +""") + + + +test.pass_test() |