Added fix for TeX includes with same name as subdirs.
[scons.git] / test / Libs / LIBS-LIBPREFIX-exists.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 Verify that we don't add $LIBPREFIX to library names in $LIBS that
29 already have the prefix on them.
30 """
31
32 import TestSCons
33
34 _exe = TestSCons._exe
35
36 test = TestSCons.TestSCons()
37
38 blender_exe = test.workpath('blender' + _exe)
39
40 test.subdir('src', ['src', 'component1'], ['src', 'component2'])
41
42 test.write('SConstruct', """\
43 SConscript(['src/SConscript'])
44
45 libpath = (['lib'])
46 libraries = (['libtest_component2',
47               'libtest_component1'])
48
49 # To remove the dependency problem, you should rename blender to mlender.
50 Program(source='main.c',
51         target='blender',
52         LIBS=libraries,
53         LIBPREFIX='lib',
54         LIBPATH=libpath,
55         CPPPATH=['src/component2'])
56 """)
57
58 test.write('main.c', """\
59 #include <stdlib.h>
60 #include "message2.h"
61
62 int main (void)
63 {
64     DisplayMessage2();
65     exit (0);
66 }
67 """)
68
69 test.write(['src', 'SConscript'], """\
70 SConscript(['component1/SConscript',
71             'component2/SConscript'])
72 """)
73
74 test.write(['src', 'component1', 'SConscript'], """\
75 source_files = ['message1.c']
76 Library(target='../../lib/libtest_component1',
77         source=source_files,
78         LINKFLAGS='')
79 """)
80
81 test.write(['src', 'component1', 'message1.c'], """\
82 #include <stdio.h>
83
84 void DisplayMessage1 (void)
85 {
86     printf ("src/component1/message.c\\n");
87 }
88 """)
89
90 test.write(['src', 'component1', 'message1.h'], """\
91 void DisplayMessage1 (void);
92 """)
93
94 test.write(['src', 'component2', 'SConscript'], """\
95 source_files = ['message2.c']
96 include_paths = ['../component1']
97 Library(target='../../lib/libtest_component2',
98         source=source_files,
99         CPPPATH=include_paths)
100 """)
101
102 test.write(['src', 'component2', 'message2.h'], """\
103 void DisplayMessage2 (void);
104 """)
105
106 test.write(['src', 'component2', 'message2.c'], """\
107 #include <stdio.h>
108 #include "message1.h"
109
110 void DisplayMessage2 (void)
111 {
112     DisplayMessage1();
113     printf ("src/component2/hello.c\\n");
114 }
115 """)
116
117 test.run(arguments = '.',
118          stderr=TestSCons.noisy_ar,
119          match=TestSCons.match_re_dotall)
120
121 test.run(program=blender_exe,
122          stdout='src/component1/message.c\nsrc/component2/hello.c\n')
123
124 test.pass_test()
125
126 # Local Variables:
127 # tab-width:4
128 # indent-tabs-mode:nil
129 # End:
130 # vim: set expandtab tabstop=4 shiftwidth=4: