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 Testing the gnu tool chain, i.e. the tools 'gcc', 'g++' and 'gnulink'.
34 _python_ = TestSCons._python_
38 return TestSCons.dll_ + s + TestSCons._dll
40 test = TestSCons.TestSCons()
42 test.subdir('gnutools')
44 test.write(['gnutools','mygcc.py'], """
47 cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', [])
50 for opt, arg in cmd_opts:
51 if opt == '-o': output = open(arg, 'wb')
52 else: opt_string = opt_string + ' ' + opt + arg
53 output.write('gcc ' + opt_string + '\\n')
55 contents = open(a, 'rb').read()
56 output.write(contents)
61 test.write(['gnutools','myg++.py'], """
64 cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', [])
67 for opt, arg in cmd_opts:
68 if opt == '-o': output = open(arg, 'wb')
69 else: opt_string = opt_string + ' ' + opt + arg
70 output.write('g++ ' + opt_string + '\\n')
72 contents = open(a, 'rb').read()
73 output.write(contents)
80 test.write(['work1', 'cfile1.c'],"""
84 test.write(['work1', 'cfile2.c'],"""
88 test.write(['work1', 'cppfile1.cpp'],"""
92 test.write(['work1', 'cppfile2.cpp'],"""
96 mygcc_py = test.workpath('gnutools','mygcc.py')
97 mygxx_py = test.workpath('gnutools','myg++.py')
99 test.write(['work1', 'SConstruct'],"""
100 env = Environment(tools=['gcc','g++','gnulink'],
101 CC=r'%(_python_)s %(mygcc_py)s',
102 CXX=r'%(_python_)s %(mygxx_py)s',
105 env.Program('c-only', Split('cfile1.c cfile2.c'))
106 env.Program('cpp-only', Split('cppfile1.cpp cppfile2.cpp'))
107 env.Program('c-and-cpp', Split('cfile1.c cppfile1.cpp'))
109 env.SharedLibrary('c-only', Split('cfile1.c cfile2.c'))
110 env.SharedLibrary('cpp-only', Split('cppfile1.cpp cppfile2.cpp'))
111 env.SharedLibrary('c-and-cpp', Split('cfile1.c cppfile1.cpp'))
114 test.run(chdir='work1')
116 def testObject(test, obj, expect):
117 contents = test.read(test.workpath('work1', obj))
118 line1 = contents.split('\n')[0]
119 actual = ' '.join(line1.split())
120 if not expect == actual:
121 print "%s: %s != %s\n" % (obj, repr(expect), repr(actual))
124 if sys.platform in ('win32', 'cygwin'):
129 testObject(test, 'cfile1.o', 'gcc -c')
130 testObject(test, 'cfile2.o', 'gcc -c')
131 testObject(test, 'cppfile1.o', 'g++ -c')
132 testObject(test, 'cppfile2.o', 'g++ -c')
133 testObject(test, 'cfile1.os', 'gcc -c' + c_fpic)
134 testObject(test, 'cfile2.os', 'gcc -c' + c_fpic)
135 testObject(test, 'cppfile1.os', 'g++ -c' + c_fpic)
136 testObject(test, 'cppfile2.os', 'g++ -c' + c_fpic)
137 testObject(test, 'c-only' + _exe, 'gcc')
138 testObject(test, 'cpp-only' + _exe, 'g++')
139 testObject(test, 'c-and-cpp' + _exe, 'g++')
140 testObject(test, dll('c-only'), 'gcc -shared')
141 testObject(test, dll('cpp-only'), 'g++ -shared')
142 testObject(test, dll('c-and-cpp'), 'g++ -shared')
148 # indent-tabs-mode:nil
150 # vim: set expandtab tabstop=4 shiftwidth=4: