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 $IMPLICIT_COMMAND_DEPENDENCIES variable controls
29 whether or not the implicit dependency on executed commands
35 python = TestSCons.python
36 _python_ = TestSCons._python_
38 test = TestSCons.TestSCons()
40 generate_build_py_py_contents = """\
45 open(sys.argv[1], 'w').write('''\
46 #!/usr/bin/env %(python)s
50 fp = open(sys.argv[1], 'wb')
51 args = [os.path.split(sys.argv[0])[1]] + sys.argv[1:]
52 fp.write(string.join(args) + '\\\\n' + '%(extra)s')
53 for infile in sys.argv[2:]:
54 fp.write(open(infile, 'rb').read())
57 os.chmod(sys.argv[1], 0755)
62 test.write('generate_build_py.py', generate_build_py_py_contents % locals())
64 test.write('SConstruct', """
65 generate = Builder(action = r'%(_python_)s $GENERATE $TARGET')
66 build = Builder(action = r'$BUILD_PY $TARGET $SOURCES')
67 env = Environment(BUILDERS = {
68 'GenerateBuild' : generate,
71 GENERATE = 'generate_build_py.py',
72 BUILD_PY = 'build.py',
74 env.PrependENVPath('PATH', '.')
75 env.PrependENVPath('PATHEXT', '.PY')
76 env0 = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 0)
77 env1 = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = 1)
78 envNone = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = None)
79 envFalse = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = False)
80 envTrue = env.Clone(IMPLICIT_COMMAND_DEPENDENCIES = True)
82 build_py = env.GenerateBuild('${BUILD_PY}', [])
85 env.BuildFile('file.out', 'file.in')
86 env0.BuildFile('file0.out', 'file.in')
87 env1.BuildFile('file1.out', 'file.in')
88 envNone.BuildFile('fileNone.out', 'file.in')
89 envFalse.BuildFile('fileFalse.out', 'file.in')
90 envTrue.BuildFile('fileTrue.out', 'file.in')
91 envTrue.BuildFile('fileQuote.out', 'file.in', BUILD_PY='"build.py"')
96 test.write('file.in', "file.in\n")
98 test.run(arguments = '--tree=all .')
100 expect_none = 'build.py %s file.in\nfile.in\n'
102 test.must_match('file.out', expect_none % 'file.out')
103 test.must_match('file0.out', expect_none % 'file0.out')
104 test.must_match('file1.out', expect_none % 'file1.out')
105 test.must_match('fileNone.out', expect_none % 'fileNone.out')
106 test.must_match('fileFalse.out', expect_none % 'fileFalse.out')
107 test.must_match('fileTrue.out', expect_none % 'fileTrue.out')
108 test.must_match('fileQuote.out', expect_none % 'fileQuote.out')
113 test.write('generate_build_py.py', generate_build_py_py_contents % locals())
115 test.run(arguments = '--tree=all .')
117 expect_extra = 'build.py %s file.in\nxyzzy\nfile.in\n'
119 test.must_match('file.out', expect_extra % 'file.out')
120 test.must_match('file0.out', expect_none % 'file0.out')
121 test.must_match('file1.out', expect_extra % 'file1.out')
122 test.must_match('fileNone.out', expect_none % 'fileNone.out')
123 test.must_match('fileFalse.out', expect_none % 'fileFalse.out')
124 test.must_match('fileTrue.out', expect_extra % 'fileTrue.out')
125 test.must_match('fileQuote.out', expect_extra % 'fileQuote.out')
132 # indent-tabs-mode:nil
134 # vim: set expandtab tabstop=4 shiftwidth=4: