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 test = TestSCons.TestSCons()
40 test.subdir('gnutools')
42 test.write(['gnutools','mygcc.py'], """
45 cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', [])
48 for opt, arg in cmd_opts:
49 if opt == '-o': output = open(arg, 'wb')
50 else: opt_string = opt_string + ' ' + opt + arg
51 output.write('gcc ' + opt_string + '\\n')
53 contents = open(a, 'rb').read()
54 output.write(contents)
59 test.write(['gnutools','myg++.py'], """
62 cmd_opts, args = getopt.getopt(sys.argv[1:], 'f:s:co:', [])
65 for opt, arg in cmd_opts:
66 if opt == '-o': output = open(arg, 'wb')
67 else: opt_string = opt_string + ' ' + opt + arg
68 output.write('g++ ' + opt_string + '\\n')
70 contents = open(a, 'rb').read()
71 output.write(contents)
78 test.write(['work1', 'cfile1.c'],"""
82 test.write(['work1', 'cfile2.c'],"""
86 test.write(['work1', 'cppfile1.cpp'],"""
90 test.write(['work1', 'cppfile2.cpp'],"""
94 test.write(['work1', 'SConstruct'],"""
95 env = Environment(tools=['gcc','g++','gnulink'],
100 env.Program('c-only', Split('cfile1.c cfile2.c'))
101 env.Program('cpp-only', Split('cppfile1.cpp cppfile2.cpp'))
102 env.Program('c-and-cpp', Split('cfile1.c cppfile1.cpp'))
104 env.SharedLibrary('c-only', Split('cfile1.c cfile2.c'))
105 env.SharedLibrary('cpp-only', Split('cppfile1.cpp cppfile2.cpp'))
106 env.SharedLibrary('c-and-cpp', Split('cfile1.c cppfile1.cpp'))
107 """ % (python, test.workpath('gnutools','mygcc.py'),
108 python, test.workpath('gnutools','myg++.py')))
110 test.run(chdir='work1')
112 def testObject(test, obj, command, flags):
113 contents = test.read(test.workpath('work1', obj))
114 line1 = string.split(contents,'\n')[0]
115 items = string.split(line1, ' ')
123 res = ((flags and (cmd == command + ' ' + flags)) or
124 (not flags and (cmd == command)))
125 if not res: print "'"+obj+command+flags+"'"+"!='"+str(line1)+"'"
128 if sys.platform == 'cygwin':
133 test.fail_test(not testObject(test, 'cfile1.o', 'gcc', '-c') or
134 not testObject(test, 'cfile2.o', 'gcc', '-c') or
135 not testObject(test, 'cppfile1.o', 'g++', '-c') or
136 not testObject(test, 'cppfile2.o', 'g++', '-c') or
137 not testObject(test, 'cfile1.os', 'gcc', '-c' + fpic) or
138 not testObject(test, 'cfile2.os', 'gcc', '-c' + fpic) or
139 not testObject(test, 'cppfile1.os', 'g++', '-c' + fpic) or
140 not testObject(test, 'cppfile2.os', 'g++', '-c' + fpic) or
141 not testObject(test, 'c-only' + _exe, 'gcc', '') or
142 not testObject(test, 'cpp-only' + _exe, 'g++', '') or
143 not testObject(test, 'c-and-cpp' + _exe, 'g++', '') or
144 not testObject(test, dll_ + 'c-only' + _dll, 'gcc', '-shared') or
145 not testObject(test, dll_ + 'cpp-only' + _dll, 'g++', '-shared') or
146 not testObject(test, dll_ + 'c-and-cpp' + _dll, 'g++', '-shared'))