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 the sconsign script works when using an individual
29 .sconsign file in each directory (SConsignFile(None)).
35 _python_ = TestSCons._python_
37 test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
39 test.subdir('sub1', 'sub2')
41 test.write('fake_cc.py', r"""
47 path = string.split(sys.argv[1])
48 output = open(sys.argv[2], 'wb')
49 input = open(sys.argv[3], 'rb')
51 output.write('fake_cc.py: %s\n' % sys.argv)
60 def process(infp, outfp):
61 for line in infp.readlines():
62 m = re.match('#include <(.*)>', line)
65 process(find_file(file), outfp)
69 process(input, output)
74 test.write('fake_link.py', r"""
77 output = open(sys.argv[1], 'wb')
78 input = open(sys.argv[2], 'rb')
80 output.write('fake_link.py: %s\n' % sys.argv)
82 output.write(input.read())
87 # Note: We don't use os.path.join() representations of the file names
88 # in the expected output because paths in the .sconsign files are
89 # canonicalized to use / as the separator.
91 sub1_hello_c = 'sub1/hello.c'
92 sub1_hello_obj = 'sub1/hello.obj'
93 sub2_hello_c = 'sub2/hello.c'
94 sub2_hello_obj = 'sub2/hello.obj'
95 sub2_inc1_h = 'sub2/inc1.h'
96 sub2_inc2_h = 'sub2/inc2.h'
98 test.write(['SConstruct'], """
100 env1 = Environment(PROGSUFFIX = '.exe',
102 CCCOM = r'%(_python_)s fake_cc.py sub2 $TARGET $SOURCE',
103 LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCE')
104 env1.Program('sub1/hello.c')
105 env2 = env1.Clone(CPPPATH = ['sub2'])
106 env2.Program('sub2/hello.c')
109 test.write(['sub1', 'hello.c'], r"""\
113 test.write(['sub2', 'hello.c'], r"""\
119 test.write(['sub2', 'inc1.h'], r"""\
120 #define STRING1 "inc1.h"
123 test.write(['sub2', 'inc2.h'], r"""\
124 #define STRING2 "inc2.h"
127 test.run(arguments = '--implicit-cache --tree=prune .')
129 sig_re = r'[0-9a-fA-F]{32}'
131 expect = r"""hello.c: %(sig_re)s \d+ \d+
132 hello.exe: %(sig_re)s \d+ \d+
133 %(sub1_hello_obj)s: %(sig_re)s \d+ \d+
135 hello.obj: %(sig_re)s \d+ \d+
136 %(sub1_hello_c)s: %(sig_re)s \d+ \d+
140 test.run_sconsign(arguments = "sub1/.sconsign", stdout=expect)
141 #test.run_sconsign(arguments = "sub1/.sconsign")
144 test.run_sconsign(arguments = "--raw sub1/.sconsign",
145 stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
146 hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
147 %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
149 hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
150 %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
154 test.run_sconsign(arguments = "-v sub1/.sconsign",
155 stdout = r"""hello.c:
168 action: %(sig_re)s \[.*\]
178 action: %(sig_re)s \[.*\]
181 test.run_sconsign(arguments = "-c -v sub1/.sconsign",
182 stdout = r"""hello.c:
190 test.run_sconsign(arguments = "-s -v sub1/.sconsign",
191 stdout = r"""hello.c:
199 test.run_sconsign(arguments = "-t -v sub1/.sconsign",
200 stdout = r"""hello.c:
208 test.run_sconsign(arguments = "-e hello.obj sub1/.sconsign",
209 stdout = r"""hello.obj: %(sig_re)s \d+ \d+
210 %(sub1_hello_c)s: %(sig_re)s \d+ \d+
214 test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj sub1/.sconsign",
215 stdout = r"""hello.obj: %(sig_re)s \d+ \d+
216 %(sub1_hello_c)s: %(sig_re)s \d+ \d+
218 hello.exe: %(sig_re)s \d+ \d+
219 %(sub1_hello_obj)s: %(sig_re)s \d+ \d+
221 hello.obj: %(sig_re)s \d+ \d+
222 %(sub1_hello_c)s: %(sig_re)s \d+ \d+
226 test.run_sconsign(arguments = "sub2/.sconsign",
227 stdout = r"""hello.c: %(sig_re)s \d+ \d+
228 hello.exe: %(sig_re)s \d+ \d+
229 %(sub2_hello_obj)s: %(sig_re)s \d+ \d+
231 hello.obj: %(sig_re)s \d+ \d+
232 %(sub2_hello_c)s: %(sig_re)s \d+ \d+
233 %(sub2_inc1_h)s: %(sig_re)s \d+ \d+
234 %(sub2_inc2_h)s: %(sig_re)s \d+ \d+
236 inc1.h: %(sig_re)s \d+ \d+
237 inc2.h: %(sig_re)s \d+ \d+
240 #test.run_sconsign(arguments = "-i -v sub2/.sconsign",
241 # stdout = r"""hello.c: %(sig_re)s \d+ \d+
242 #hello.exe: %(sig_re)s \d+ \d+
244 # hello.obj: %(sig_re)s \d+ \d+
245 #hello.obj: %(sig_re)s \d+ \d+
247 # hello.c: %(sig_re)s \d+ \d+
248 # inc1.h: %(sig_re)s \d+ \d+
249 # inc2.h: %(sig_re)s \d+ \d+
252 test.run_sconsign(arguments = "-e hello.obj sub2/.sconsign sub1/.sconsign",
253 stdout = r"""hello.obj: %(sig_re)s \d+ \d+
254 %(sub2_hello_c)s: %(sig_re)s \d+ \d+
255 %(sub2_inc1_h)s: %(sig_re)s \d+ \d+
256 %(sub2_inc2_h)s: %(sig_re)s \d+ \d+
258 hello.obj: %(sig_re)s \d+ \d+
259 %(sub1_hello_c)s: %(sig_re)s \d+ \d+