5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify operation of Visual C/C++ batch builds.
30 This uses a fake compiler and linker script, fake command lines, and
31 explicit suffix settings so that the test should work when run on any
37 test = TestSCons.TestSCons()
39 _python_ = TestSCons._python_
41 test.write('fake_cl.py', """\
45 input_files = sys.argv[2:]
46 if sys.argv[1][-1] in (os.sep, '\\\\'):
47 # The output (/Fo) argument ends with a backslash, indicating an
48 # output directory. We accept ending with a slash as well so this
49 # test runs on non-Windows systems. Strip either character and
50 # record the directory name.
51 sys.argv[1] = sys.argv[1][:-1]
55 output = sys.argv[1][3:]
56 # Delay writing the .log output until here so any trailing slash or
57 # backslash has been stripped, and the output comparisons later in this
58 # script don't have to account for the difference.
59 open('fake_cl.log', 'ab').write(string.join(sys.argv[1:]) + '\\n')
60 for infile in input_files:
62 outfile = os.path.join(dir, string.replace(infile, '.c', '.obj'))
65 open(outfile, 'wb').write(open(infile, 'rb').read())
68 test.write('fake_link.py', """\
71 ofp = open(sys.argv[1], 'wb')
72 for infile in sys.argv[2:]:
73 ofp.write(open(infile, 'rb').read())
76 test.write('SConstruct', """
77 cccom = '%(_python_)s fake_cl.py $_MSVC_OUTPUT_FLAG $CHANGED_SOURCES'
78 linkcom = '%(_python_)s fake_link.py ${TARGET.windows} $SOURCES'
79 env = Environment(tools=['msvc', 'mslink'],
84 MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH'))
85 p = env.Object('prog.c')
86 f1 = env.Object('f1.c')
87 f2 = env.Object('f2.c')
88 env.Program(p + f1 + f2)
91 test.write('prog.c', "prog.c\n")
92 test.write('f1.c', "f1.c\n")
93 test.write('f2.c', "f2.c\n")
97 test.run(arguments = 'MSVC_BATCH=1 .')
99 test.must_match('prog.exe', "prog.c\nf1.c\nf2.c\n")
100 test.must_match('fake_cl.log', """\
101 /Fo. prog.c f1.c f2.c
104 test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.')
108 test.write('f1.c', "f1.c 2\n")
110 test.run(arguments = 'MSVC_BATCH=1 .')
112 test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n")
113 test.must_match('fake_cl.log', """\
114 /Fo. prog.c f1.c f2.c
118 test.up_to_date(options = 'MSVC_BATCH=1', arguments = '.')
122 test.run(arguments = '-c .')
124 test.unlink('fake_cl.log')
128 test.run(arguments = '. MSVC_BATCH=0')
130 test.must_match('prog.exe', "prog.c\nf1.c 2\nf2.c\n")
131 test.must_match('fake_cl.log', """\
139 test.write('f1.c', "f1.c 3\n")
141 test.run(arguments = '. MSVC_BATCH=0')
143 test.must_match('prog.exe', "prog.c\nf1.c 3\nf2.c\n")
144 test.must_match('fake_cl.log', """\
157 # indent-tabs-mode:nil
159 # vim: set expandtab tabstop=4 shiftwidth=4: