OLD | NEW |
1 | 1 |
2 """SCons.Tool.qt | 2 """SCons.Tool.qt |
3 | 3 |
4 Tool-specific initialization for Qt. | 4 Tool-specific initialization for Qt. |
5 | 5 |
6 There normally shouldn't be any need to import this module directly. | 6 There normally shouldn't be any need to import this module directly. |
7 It will usually be imported through the generic SCons.Tool.Tool() | 7 It will usually be imported through the generic SCons.Tool.Tool() |
8 selection method. | 8 selection method. |
9 | 9 |
10 """ | 10 """ |
11 | 11 |
12 # | 12 # |
13 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundat
ion | 13 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons F
oundation |
14 # | 14 # |
15 # Permission is hereby granted, free of charge, to any person obtaining | 15 # Permission is hereby granted, free of charge, to any person obtaining |
16 # a copy of this software and associated documentation files (the | 16 # a copy of this software and associated documentation files (the |
17 # "Software"), to deal in the Software without restriction, including | 17 # "Software"), to deal in the Software without restriction, including |
18 # without limitation the rights to use, copy, modify, merge, publish, | 18 # without limitation the rights to use, copy, modify, merge, publish, |
19 # distribute, sublicense, and/or sell copies of the Software, and to | 19 # distribute, sublicense, and/or sell copies of the Software, and to |
20 # permit persons to whom the Software is furnished to do so, subject to | 20 # permit persons to whom the Software is furnished to do so, subject to |
21 # the following conditions: | 21 # the following conditions: |
22 # | 22 # |
23 # The above copyright notice and this permission notice shall be included | 23 # The above copyright notice and this permission notice shall be included |
24 # in all copies or substantial portions of the Software. | 24 # in all copies or substantial portions of the Software. |
25 # | 25 # |
26 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY | 26 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY |
27 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | 27 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
28 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 28 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
29 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | 29 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
30 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | 30 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
31 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 31 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
32 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 32 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
33 # | 33 # |
34 | 34 |
35 __revision__ = "src/engine/SCons/Tool/qt.py 3842 2008/12/20 22:59:52 scons" | 35 __revision__ = "src/engine/SCons/Tool/qt.py 3897 2009/01/13 06:45:54 scons" |
36 | 36 |
37 import os.path | 37 import os.path |
38 import re | 38 import re |
39 | 39 |
40 import SCons.Action | 40 import SCons.Action |
41 import SCons.Builder | 41 import SCons.Builder |
42 import SCons.Defaults | 42 import SCons.Defaults |
43 import SCons.Scanner | 43 import SCons.Scanner |
44 import SCons.Tool | 44 import SCons.Tool |
45 import SCons.Util | 45 import SCons.Util |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 # binary obj file provided | 131 # binary obj file provided |
132 if debug: | 132 if debug: |
133 print "scons: qt: '%s' seems to be a binary. Discarded." % s
tr(obj) | 133 print "scons: qt: '%s' seems to be a binary. Discarded." % s
tr(obj) |
134 continue | 134 continue |
135 cpp = obj.sources[0] | 135 cpp = obj.sources[0] |
136 if not splitext(str(cpp))[1] in cxx_suffixes: | 136 if not splitext(str(cpp))[1] in cxx_suffixes: |
137 if debug: | 137 if debug: |
138 print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp
) | 138 print "scons: qt: '%s' is no cxx file. Discarded." % str(cpp
) |
139 # c or fortran source | 139 # c or fortran source |
140 continue | 140 continue |
141 #cpp_contents = comment.sub('', cpp.get_contents()) | 141 #cpp_contents = comment.sub('', cpp.get_text_contents()) |
142 cpp_contents = cpp.get_contents() | 142 cpp_contents = cpp.get_text_contents() |
143 h=None | 143 h=None |
144 for h_ext in header_extensions: | 144 for h_ext in header_extensions: |
145 # try to find the header file in the corresponding source | 145 # try to find the header file in the corresponding source |
146 # directory | 146 # directory |
147 hname = splitext(cpp.name)[0] + h_ext | 147 hname = splitext(cpp.name)[0] + h_ext |
148 h = find_file(hname, (cpp.get_dir(),), env.File) | 148 h = find_file(hname, (cpp.get_dir(),), env.File) |
149 if h: | 149 if h: |
150 if debug: | 150 if debug: |
151 print "scons: qt: Scanning '%s' (header of '%s')" % (str
(h), str(cpp)) | 151 print "scons: qt: Scanning '%s' (header of '%s')" % (str
(h), str(cpp)) |
152 #h_contents = comment.sub('', h.get_contents()) | 152 #h_contents = comment.sub('', h.get_text_contents()) |
153 h_contents = h.get_contents() | 153 h_contents = h.get_text_contents() |
154 break | 154 break |
155 if not h and debug: | 155 if not h and debug: |
156 print "scons: qt: no header for '%s'." % (str(cpp)) | 156 print "scons: qt: no header for '%s'." % (str(cpp)) |
157 if h and q_object_search.search(h_contents): | 157 if h and q_object_search.search(h_contents): |
158 # h file with the Q_OBJECT macro found -> add moc_cpp | 158 # h file with the Q_OBJECT macro found -> add moc_cpp |
159 moc_cpp = env.Moc(h) | 159 moc_cpp = env.Moc(h) |
160 moc_o = objBuilder(moc_cpp) | 160 moc_o = objBuilder(moc_cpp) |
161 out_sources.append(moc_o) | 161 out_sources.append(moc_o) |
162 #moc_cpp.target_scanner = SCons.Defaults.CScan | 162 #moc_cpp.target_scanner = SCons.Defaults.CScan |
163 if debug: | 163 if debug: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 # third target is moc file | 214 # third target is moc file |
215 target.append(adjustixes(bs, | 215 target.append(adjustixes(bs, |
216 env.subst('$QT_MOCHPREFIX'), | 216 env.subst('$QT_MOCHPREFIX'), |
217 env.subst('$QT_MOCHSUFFIX'))) | 217 env.subst('$QT_MOCHSUFFIX'))) |
218 return target, source | 218 return target, source |
219 | 219 |
220 def uicScannerFunc(node, env, path): | 220 def uicScannerFunc(node, env, path): |
221 lookout = [] | 221 lookout = [] |
222 lookout.extend(env['CPPPATH']) | 222 lookout.extend(env['CPPPATH']) |
223 lookout.append(str(node.rfile().dir)) | 223 lookout.append(str(node.rfile().dir)) |
224 includes = re.findall("<include.*?>(.*?)</include>", node.get_contents()) | 224 includes = re.findall("<include.*?>(.*?)</include>", node.get_text_contents(
)) |
225 result = [] | 225 result = [] |
226 for incFile in includes: | 226 for incFile in includes: |
227 dep = env.FindFile(incFile,lookout) | 227 dep = env.FindFile(incFile,lookout) |
228 if dep: | 228 if dep: |
229 result.append(dep) | 229 result.append(dep) |
230 return result | 230 return result |
231 | 231 |
232 uicScanner = SCons.Scanner.Base(uicScannerFunc, | 232 uicScanner = SCons.Scanner.Base(uicScannerFunc, |
233 name = "UicScanner", | 233 name = "UicScanner", |
234 node_class = SCons.Node.FS.File, | 234 node_class = SCons.Node.FS.File, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 env.AppendUnique(PROGEMITTER =[AutomocStatic], | 321 env.AppendUnique(PROGEMITTER =[AutomocStatic], |
322 SHLIBEMITTER=[AutomocShared], | 322 SHLIBEMITTER=[AutomocShared], |
323 LIBEMITTER =[AutomocStatic], | 323 LIBEMITTER =[AutomocStatic], |
324 # Of course, we need to link against the qt libraries | 324 # Of course, we need to link against the qt libraries |
325 CPPPATH=["$QT_CPPPATH"], | 325 CPPPATH=["$QT_CPPPATH"], |
326 LIBPATH=["$QT_LIBPATH"], | 326 LIBPATH=["$QT_LIBPATH"], |
327 LIBS=['$QT_LIB']) | 327 LIBS=['$QT_LIB']) |
328 | 328 |
329 def exists(env): | 329 def exists(env): |
330 return _detect(env) | 330 return _detect(env) |
OLD | NEW |