Added fix for TeX includes with same name as subdirs.
[scons.git] / test / ParseConfig.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 import TestSCons
28
29 _python_ = TestSCons._python_
30
31 test = TestSCons.TestSCons()
32
33 test_config1 = test.workpath('test-config1')
34 test_config2 = test.workpath('test-config2')
35 test_config3 = test.workpath('test-config3')
36
37 # 'abc' is supposed to be a static lib; it is included in LIBS as a
38 # File node.
39 # It used to be returned as the 'static_libs' output of ParseConfig.
40 test.write(test_config1, """\
41 print "-I/usr/include/fum -Ibar -X -arch i386"
42 print "-L/usr/fax -Lfoo -lxxx abc"
43 """)
44
45 test.write(test_config2, """\
46 print "-L foo -L lib_dir"
47 """)
48
49 # This is like what wxWidgets does on OSX w/ Universal Binaries
50 test.write(test_config3, """\
51 print "-L foo -L lib_dir -isysroot /tmp -arch ppc -arch i386"
52 """)
53
54 test.write('SConstruct1', """
55 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [],
56                   CCFLAGS = '-pipe -Wall')
57 env.ParseConfig([r'%(_python_)s', r"%(test_config1)s", "--libs --cflags"])
58 env.ParseConfig([r'%(_python_)s', r"%(test_config2)s", "--libs --cflags"])
59 print env['CPPPATH']
60 print env['LIBPATH']
61 print [str(x) for x in env['LIBS']]
62 print env['CCFLAGS']
63 """ % locals())
64
65 test.write('SConstruct2', """
66 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [],
67                   CCFLAGS = '-pipe -Wall',
68                   PYTHON = r'%(_python_)s')
69 env.ParseConfig(r"$PYTHON %(test_config1)s --libs --cflags")
70 env.ParseConfig(r"$PYTHON %(test_config2)s --libs --cflags")
71 print env['CPPPATH']
72 print env['LIBPATH']
73 print [str(x) for x in env['LIBS']]
74 print env['CCFLAGS']
75 """ % locals())
76
77 test.write('SConstruct3', """
78 env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [],
79                   CCFLAGS = '-pipe -Wall',
80                   PYTHON = r'%(_python_)s')
81 env.ParseConfig(r"$PYTHON %(test_config3)s --libs --cflags")
82 print env['CPPPATH']
83 print env['LIBPATH']
84 print [str(x) for x in env['LIBS']]
85 print env['CCFLAGS']
86 """ % locals())
87
88 good_stdout = """\
89 ['/usr/include/fum', 'bar']
90 ['/usr/fax', 'foo', 'lib_dir']
91 ['xxx', 'abc']
92 ['-pipe', '-Wall', '-X', ('-arch', 'i386')]
93 """
94
95 stdout3 = """\
96 []
97 ['foo', 'lib_dir']
98 []
99 ['-pipe', '-Wall', ('-isysroot', '/tmp'), ('-arch', 'ppc'), ('-arch', 'i386')]
100 """
101
102 test.run(arguments = "-q -Q -f SConstruct1 .", stdout = good_stdout)
103
104 test.run(arguments = "-q -Q -f SConstruct2 .", stdout = good_stdout)
105
106 test.run(arguments = "-q -Q -f SConstruct3 .", stdout = stdout3)
107
108 test.pass_test()
109
110 # Local Variables:
111 # tab-width:4
112 # indent-tabs-mode:nil
113 # End:
114 # vim: set expandtab tabstop=4 shiftwidth=4: