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 (<https://sourceforge.net/tracker/index.php?func=detail&aid=1088979&group_id=30337&atid=398971>).
30 (historical - dead link)
32 Unnecessary rebuild with generated header file
33 Scons rebuilds some nodes when invoked twice. The
34 trigger seems to be a generated C++ source file that
35 includes a header file that also is generated.
37 A tarball with a minimal test case is attached.
38 Transcript for reproducing:
41 tar xzf scons_rebuild_debug.tar.gz
42 cd scons_rebuild_debug
47 Note that the bug is not triggered when scons is run
50 This may be a duplicate to bug 1019683.
59 test
= TestSCons
.TestSCons()
63 if sys
.platform
== 'win32' and not sysconfig
.get_platform() in ("mingw",):
65 generator_name
= 'generator.bat'
66 test
.write(generator_name
, '@echo #include "header.hh"')
67 kernel_action
= "$SOURCES > $TARGET"
69 generator_name
= 'generator.sh'
70 test
.write(generator_name
, 'echo \'#include "header.hh"\'')
71 kernel_action
= "sh $SOURCES > $TARGET"
73 if sysconfig
.get_platform() in ("mingw",):
74 # mingw Python uses a sep of '/', when Command fires, that will not work.
75 # use its altsep instead, that is the standard Windows separator.
81 test
.write('SConstruct', """\
84 kernelDefines = env.Command("header.hh", "header.hh.in", Copy('$TARGET', '$SOURCE'))
85 kernelImporterSource = env.Command("generated.cc", ["%s"], "%s")
86 kernelImporter = env.Program(kernelImporterSource + ["main.cc"])
87 kernelImports = env.Command("KernelImport.hh", kernelImporter, r".%s$SOURCE > $TARGET")
88 osLinuxModule = env.StaticObject(["target.cc"])
89 """ % (generator_name
, kernel_action
, sep
))
91 test
.write('main.cc', """\
99 test
.write('target.cc', """\
102 #include "KernelImport.hh"
107 test
.write("header.hh.in", "#define HEADER_HH 1\n")
109 test
.run(arguments
= 'target' + _obj
)
111 expected_stdout
= """\
112 scons: Reading SConscript files ...
113 scons: done reading SConscript files.
114 scons: Building targets ...
115 scons: `target%(_obj)s' is up to date.
116 scons: done building targets.
119 test
.run(arguments
= 'target' + _obj
, stdout
=expected_stdout
)
125 # indent-tabs-mode:nil
127 # vim: set expandtab tabstop=4 shiftwidth=4: