5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Test case for the bug report:
28 "[ 1088979 ] Unnecessary rebuild with generated header file"
29 (<http://sourceforge.net/tracker/index.php?func=detail&aid=1088979&group_id=30337&atid=398971>).
31 Unnecessary rebuild with generated header file
32 Scons rebuilds some nodes when invoked twice. The
33 trigger seems to be a generated C++ source file that
34 includes a header file that also is generated.
36 A tarball with a minimal test case is attached.
37 Transcript for reproducing:
40 tar xzf scons_rebuild_debug.tar.gz
41 cd scons_rebuild_debug
46 Note that the bug is not triggered when scons is run
49 This may be a duplicate to bug 1019683.
58 test
= TestSCons
.TestSCons()
62 if sys
.platform
== 'win32' and not sysconfig
.get_platform() in ("mingw",):
64 generator_name
= 'generator.bat'
65 test
.write(generator_name
, '@echo #include "header.hh"')
66 kernel_action
= "$SOURCES > $TARGET"
68 generator_name
= 'generator.sh'
69 test
.write(generator_name
, 'echo \'#include "header.hh"\'')
70 kernel_action
= "sh $SOURCES > $TARGET"
72 if sysconfig
.get_platform() in ("mingw",):
73 # mingw Python uses a sep of '/', when Command fires, that will not work.
74 # use its altsep instead, that is the standard Windows separator.
80 test
.write('SConstruct', """\
83 kernelDefines = env.Command("header.hh", "header.hh.in", Copy('$TARGET', '$SOURCE'))
84 kernelImporterSource = env.Command("generated.cc", ["%s"], "%s")
85 kernelImporter = env.Program(kernelImporterSource + ["main.cc"])
86 kernelImports = env.Command("KernelImport.hh", kernelImporter, r".%s$SOURCE > $TARGET")
87 osLinuxModule = env.StaticObject(["target.cc"])
88 """ % (generator_name
, kernel_action
, sep
))
90 test
.write('main.cc', """\
98 test
.write('target.cc', """\
101 #include "KernelImport.hh"
106 test
.write("header.hh.in", "#define HEADER_HH 1\n")
108 test
.run(arguments
= 'target' + _obj
)
110 expected_stdout
= """\
111 scons: Reading SConscript files ...
112 scons: done reading SConscript files.
113 scons: Building targets ...
114 scons: `target%(_obj)s' is up to date.
115 scons: done building targets.
118 test
.run(arguments
= 'target' + _obj
, stdout
=expected_stdout
)
124 # indent-tabs-mode:nil
126 # vim: set expandtab tabstop=4 shiftwidth=4: