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 that rebuilds do not occur when SConsignFile(None) is used to
29 put a .sconsign file in each directory and we subdvide the dependency
30 tree with subsidiary *SConstruct* files in various subdirectories.
32 This depends on using content signatures for evaluation of
33 intermediate Nodes. This relies on the default behavior
34 being the equivalent of Decider('content').
40 test
= TestSCons
.TestSCons()
42 test
.subdir('src', ['src', 'sub'])
44 _python_
= TestSCons
._python
_
46 # Because this test sets SConsignFile(None), we execute our fake
47 # scripts directly, not by feeding them to the Python executable.
48 # That is, we chmod 0o755 and use a "#!/usr/bin/env python" first
49 # line for POSIX systems, and add .PY to the %PATHEXT% variable on
50 # Windows. If we didn't do this, then running this script with
51 # suitable prileveges would create a .sconsign file in the directory
52 # where the Python executable lives. This can happen out of the
53 # box on Mac OS X, with the result that the .sconsign statefulness
54 # can mess up other tests.
56 fake_cc_py
= test
.workpath('fake_cc.py')
57 fake_link_py
= test
.workpath('fake_link.py')
59 test
.write(fake_cc_py
, """\
61 with open(sys.argv[1], 'w') as ofp:
62 ofp.write('fake_cc.py: %s\\n' % sys.argv)
63 for s in sys.argv[2:]:
64 with open(s, 'r') as ifp:
68 test
.write(fake_link_py
, """\
70 with open(sys.argv[1], 'w') as ofp:
71 ofp.write('fake_link.py: %s\\n' % sys.argv)
72 for s in sys.argv[2:]:
73 with open(s, 'r') as ifp:
77 test
.chmod(fake_cc_py
, 0o755)
78 test
.chmod(fake_link_py
, 0o755)
80 test
.write('SConstruct', """\
81 DefaultEnvironment(tools=[])
83 env = Environment(PROGSUFFIX = '.exe',
85 CCCOM = r'%(_python_)s %(fake_cc_py)s $TARGET $SOURCES',
86 LINKCOM = r'%(_python_)s %(fake_link_py)s $TARGET $SOURCES')
87 env.PrependENVPath('PATHEXT', '.PY')
88 env.SConscript('src/SConstruct', exports=['env'])
92 test
.write(['src', 'SConstruct'], """\
93 DefaultEnvironment(tools=[])
95 env = Environment(PROGSUFFIX = '.exe',
97 CCCOM = r'%(_python_)s %(fake_cc_py)s $TARGET $SOURCES',
98 LINKCOM = r'%(_python_)s %(fake_link_py)s $TARGET $SOURCES')
99 env.PrependENVPath('PATHEXT', '.PY')
100 p = env.Program('prog', ['main.c', '../foo$OBJSUFFIX', 'sub/bar.c'])
104 test
.write('foo.c', """\
108 test
.write(['src', 'main.c'], """\
112 test
.write(['src', 'sub', 'bar.c'], """\
118 src_prog_exe
= os
.path
.join('src', 'prog.exe')
119 src_main_c
= os
.path
.join('src', 'main.c')
120 src_main_obj
= os
.path
.join('src', 'main.obj')
121 src_sub_bar_c
= os
.path
.join('src', 'sub', 'bar.c')
122 src_sub_bar_obj
= os
.path
.join('src', 'sub', 'bar.obj')
125 fake_link.py: ['%(fake_link_py)s', '%(src_prog_exe)s', '%(src_main_obj)s', 'foo.obj', '%(src_sub_bar_obj)s']
126 fake_cc.py: ['%(fake_cc_py)s', '%(src_main_obj)s', '%(src_main_c)s']
128 fake_cc.py: ['%(fake_cc_py)s', 'foo.obj', 'foo.c']
130 fake_cc.py: ['%(fake_cc_py)s', '%(src_sub_bar_obj)s', '%(src_sub_bar_c)s']
135 expect
= expect
.replace('\\', '\\\\')
137 test
.must_match(['src', 'prog.exe'], expect
, mode
='r')
139 test
.up_to_date(chdir
='src', arguments
= test
.workpath())
141 test
.up_to_date(arguments
= '.')
147 # indent-tabs-mode:nil
149 # vim: set expandtab tabstop=4 shiftwidth=4: