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