Added fix for TeX includes with same name as subdirs.
[scons.git] / test / VariantDir / include-subdir.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Test VariantDir handling of #include files in subdirectories.
29
30 When a source file #includes a file that is not in the current directory,
31 we have to make sure that the file gets copied to the variant dir. (This
32 was not the case for 0.98.5 and earlier)
33
34 Test case supplied by Jared Grubb, based on a minimal example supplied
35 by Ali Tofigh, filed as issue #2121 at tigris.org.
36 """
37
38 import TestSCons
39
40 test = TestSCons.TestSCons()
41
42 #-------------------------------------------------------------------------------
43 #1- Create dep.cpp and the SConstruct. dep.h is missing and the build is
44 #expected to fail with 2.
45 #-------------------------------------------------------------------------------
46
47 test.subdir('src')
48 test.subdir('src/utils')
49 test.write(['src', 'main.cpp'], """\
50 #include "main.h"
51 #include "utils/util.h"
52
53 int main(int argc, char* argv[])
54 {
55     return MAIN_VALUE+UTIL_VALUE;
56 }
57 """)
58
59 test.write(['src', 'main.h'], """\
60 #define MAIN_VALUE 2
61 """)
62
63 test.write(['src', 'utils', 'util.h'], """\
64 #define UTIL_VALUE -2
65 """)
66
67 test.write('SConstruct', """
68 env = Environment()
69 env.VariantDir('bin', 'src')
70 o = env.Object('bin/main', 'bin/main.cpp')
71 env.Program('bin/main', o)
72 """)
73
74 test.run(arguments = '.')
75
76 test.pass_test()
77
78 # Local Variables:
79 # tab-width:4
80 # indent-tabs-mode:nil
81 # End:
82 # vim: set expandtab tabstop=4 shiftwidth=4: