Diffstat (limited to 'qmake/generators/win32/msvc_dsp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/win32/msvc_dsp.cpp | 955 |
1 files changed, 955 insertions, 0 deletions
diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp new file mode 100644 index 0000000..8b08c78 --- a/dev/null +++ b/qmake/generators/win32/msvc_dsp.cpp | |||
@@ -0,0 +1,955 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of ________ class. | ||
5 | ** | ||
6 | ** Created : 970521 | ||
7 | ** | ||
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | ||
9 | ** | ||
10 | ** This file is part of the network module of the Qt GUI Toolkit. | ||
11 | ** | ||
12 | ** This file may be distributed under the terms of the Q Public License | ||
13 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
14 | ** LICENSE.QPL included in the packaging of this file. | ||
15 | ** | ||
16 | ** This file may be distributed and/or modified under the terms of the | ||
17 | ** GNU General Public License version 2 as published by the Free Software | ||
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
19 | ** packaging of this file. | ||
20 | ** | ||
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | ||
22 | ** file in accordance with the Qt Commercial License Agreement provided | ||
23 | ** with the Software. | ||
24 | ** | ||
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
27 | ** | ||
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
29 | ** information about Qt Commercial License Agreements. | ||
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
32 | ** | ||
33 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
34 | ** not clear to you. | ||
35 | ** | ||
36 | **********************************************************************/ | ||
37 | |||
38 | #include "msvc_dsp.h" | ||
39 | #include "option.h" | ||
40 | #include <qdir.h> | ||
41 | #include <qregexp.h> | ||
42 | #include <stdlib.h> | ||
43 | #include <time.h> | ||
44 | |||
45 | DspMakefileGenerator::DspMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) | ||
46 | { | ||
47 | |||
48 | } | ||
49 | |||
50 | bool | ||
51 | DspMakefileGenerator::writeMakefile(QTextStream &t) | ||
52 | { | ||
53 | if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { | ||
54 | /* for now just dump, I need to generated an empty dsp or something.. */ | ||
55 | fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", | ||
56 | var("QMAKE_FAILED_REQUIREMENTS").latin1()); | ||
57 | return TRUE; | ||
58 | } | ||
59 | |||
60 | if(project->first("TEMPLATE") == "vcapp" || | ||
61 | project->first("TEMPLATE") == "vclib") { | ||
62 | return writeDspParts(t); | ||
63 | } | ||
64 | else if(project->first("TEMPLATE") == "subdirs") { | ||
65 | writeHeader(t); | ||
66 | writeSubDirs(t); | ||
67 | return TRUE; | ||
68 | } | ||
69 | return FALSE; | ||
70 | } | ||
71 | |||
72 | bool | ||
73 | DspMakefileGenerator::writeDspParts(QTextStream &t) | ||
74 | { | ||
75 | QString dspfile; | ||
76 | if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) { | ||
77 | dspfile = project->first("DSP_TEMPLATE"); | ||
78 | } else { | ||
79 | dspfile = project->first("MSVCDSP_TEMPLATE"); | ||
80 | } | ||
81 | QString dspfile_loc = findTemplate(dspfile); | ||
82 | |||
83 | QFile file(dspfile_loc); | ||
84 | if(!file.open(IO_ReadOnly)) { | ||
85 | fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1()); | ||
86 | return FALSE; | ||
87 | } | ||
88 | QTextStream dsp(&file); | ||
89 | |||
90 | int rep; | ||
91 | QString line; | ||
92 | while ( !dsp.eof() ) { | ||
93 | line = dsp.readLine(); | ||
94 | while((rep = line.find(QRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) { | ||
95 | QString torep = line.mid(rep, line.find(QRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep); | ||
96 | QString variable = torep.right(torep.length()-2); | ||
97 | |||
98 | t << line.left(rep); //output the left side | ||
99 | line = line.right(line.length() - (rep + torep.length())); //now past the variable | ||
100 | if(variable == "MSVCDSP_SOURCES") { | ||
101 | if(project->variables()["SOURCES"].isEmpty()) | ||
102 | continue; | ||
103 | |||
104 | QString mocpath = var( "QMAKE_MOC" ); | ||
105 | mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; | ||
106 | |||
107 | QStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"]; | ||
108 | if(!project->isActiveConfig("flat")) | ||
109 | list.sort(); | ||
110 | QStringList::Iterator it; | ||
111 | for( it = list.begin(); it != list.end(); ++it) { | ||
112 | beginGroupForFile((*it), t); | ||
113 | t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; | ||
114 | if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) { | ||
115 | QString base = (*it); | ||
116 | base.replace(QRegExp("\\..*$"), "").upper(); | ||
117 | base.replace(QRegExp("[^a-zA-Z]"), "_"); | ||
118 | |||
119 | QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + | ||
120 | "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" | ||
121 | " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" | ||
122 | "\t" + mocpath + findMocSource((*it)) + " -o " + | ||
123 | (*it) + "\n\n" "# End Custom Build\n\n"; | ||
124 | |||
125 | t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; | ||
126 | |||
127 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
128 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" | ||
129 | << build << "!ENDIF " << endl << endl; | ||
130 | } | ||
131 | t << "# End Source File" << endl; | ||
132 | } | ||
133 | endGroups(t); | ||
134 | } else if(variable == "MSVCDSP_IMAGES") { | ||
135 | if(project->variables()["IMAGES"].isEmpty()) | ||
136 | continue; | ||
137 | t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl; | ||
138 | t << "# End Source File" << endl; | ||
139 | } else if(variable == "MSVCDSP_HEADERS") { | ||
140 | if(project->variables()["HEADERS"].isEmpty()) | ||
141 | continue; | ||
142 | |||
143 | QStringList list = project->variables()["HEADERS"]; | ||
144 | if(!project->isActiveConfig("flat")) | ||
145 | list.sort(); | ||
146 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
147 | // beginGroupForFile((*it), t); | ||
148 | t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl; | ||
149 | if ( project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) { | ||
150 | QString base = (*it); | ||
151 | base.replace(QRegExp("\\..*$"), "").upper(); | ||
152 | base.replace(QRegExp("[^a-zA-Z]"), "_"); | ||
153 | |||
154 | QString mocpath = var( "QMAKE_MOC" ); | ||
155 | mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; | ||
156 | |||
157 | QString build = "\n\n# Begin Custom Build - Moc'ing " + (*it) + | ||
158 | "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + findMocDestination((*it)) + | ||
159 | "\"" " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" | ||
160 | "\t" + mocpath + (*it) + " -o " + | ||
161 | findMocDestination((*it)) + "\n\n" "# End Custom Build\n\n"; | ||
162 | |||
163 | t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; | ||
164 | |||
165 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
166 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" | ||
167 | << build << "!ENDIF " << endl << endl; | ||
168 | } | ||
169 | t << "# End Source File" << endl; | ||
170 | } | ||
171 | // endGroups(t); | ||
172 | } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") { | ||
173 | if(project->variables()["FORMS"].isEmpty()) | ||
174 | continue; | ||
175 | |||
176 | QString uiSourcesDir; | ||
177 | QString uiHeadersDir; | ||
178 | if(!project->variables()["UI_DIR"].isEmpty()) { | ||
179 | uiSourcesDir = project->first("UI_DIR"); | ||
180 | uiHeadersDir = project->first("UI_DIR"); | ||
181 | } else { | ||
182 | if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) | ||
183 | uiSourcesDir = project->first("UI_SOURCES_DIR"); | ||
184 | else | ||
185 | uiSourcesDir = ""; | ||
186 | if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) | ||
187 | uiHeadersDir = project->first("UI_HEADERS_DIR"); | ||
188 | else | ||
189 | uiHeadersDir = ""; | ||
190 | } | ||
191 | |||
192 | QStringList list = project->variables()["FORMS"]; | ||
193 | if(!project->isActiveConfig("flat")) | ||
194 | list.sort(); | ||
195 | QString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h"; | ||
196 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
197 | QString base = (*it); | ||
198 | int dot = base.findRev("."); | ||
199 | base.replace( dot, base.length() - dot, ext ); | ||
200 | QString fname = base; | ||
201 | |||
202 | int lbs = fname.findRev( "\\" ); | ||
203 | QString fpath; | ||
204 | if ( lbs != -1 ) | ||
205 | fpath = fname.left( lbs + 1 ); | ||
206 | fname = fname.right( fname.length() - lbs - 1 ); | ||
207 | |||
208 | if ( ext == ".cpp" && !uiSourcesDir.isEmpty() ) | ||
209 | fname.prepend(uiSourcesDir); | ||
210 | else if ( ext == ".h" && !uiHeadersDir.isEmpty() ) | ||
211 | fname.prepend(uiHeadersDir); | ||
212 | else | ||
213 | fname = base; | ||
214 | // beginGroupForFile(fname, t); | ||
215 | t << "# Begin Source File\n\nSOURCE=" << fname | ||
216 | << "\n# End Source File" << endl; | ||
217 | } | ||
218 | // endGroups(t); | ||
219 | } else if(variable == "MSVCDSP_TRANSLATIONS" ) { | ||
220 | if(project->variables()["TRANSLATIONS"].isEmpty()) | ||
221 | continue; | ||
222 | |||
223 | t << "# Begin Group \"Translations\"\n"; | ||
224 | t << "# Prop Default_Filter \"ts\"\n"; | ||
225 | |||
226 | QStringList list = project->variables()["TRANSLATIONS"]; | ||
227 | if(!project->isActiveConfig("flat")) | ||
228 | list.sort(); | ||
229 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
230 | QString sify = *it; | ||
231 | sify.replace('/', '\\' ); | ||
232 | QString base = (*it); | ||
233 | base.replace(QRegExp("\\..*$"), "").upper(); | ||
234 | base.replace(QRegExp("[^a-zA-Z]"), "_"); | ||
235 | |||
236 | // beginGroupForFile(sify, t); | ||
237 | t << "# Begin Source File\n\nSOURCE=" << sify << endl; | ||
238 | t << "\n# End Source File" << endl; | ||
239 | } | ||
240 | // endGroups(t); | ||
241 | t << "\n# End Group\n"; | ||
242 | } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) { | ||
243 | if ( project->variables()["SRCMOC"].isEmpty()) | ||
244 | continue; | ||
245 | |||
246 | QString mocpath = var( "QMAKE_MOC" ); | ||
247 | mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; | ||
248 | |||
249 | QStringList list = project->variables()["SRCMOC"]; | ||
250 | if(!project->isActiveConfig("flat")) | ||
251 | list.sort(); | ||
252 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
253 | // beginGroupForFile((*it), t); | ||
254 | t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; | ||
255 | if ( project->isActiveConfig("moc") && (*it).endsWith(Option::moc_ext)) { | ||
256 | QString base = (*it); | ||
257 | base.replace(QRegExp("\\..*$"), "").upper(); | ||
258 | base.replace(QRegExp("[^a-zA-Z]"), "_"); | ||
259 | |||
260 | QString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + | ||
261 | "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" | ||
262 | " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" | ||
263 | "\t" + mocpath + findMocSource((*it)) + " -o " + | ||
264 | (*it) + "\n\n" "# End Custom Build\n\n"; | ||
265 | |||
266 | t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; | ||
267 | |||
268 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
269 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" | ||
270 | << build << "!ENDIF " << endl << endl; | ||
271 | } | ||
272 | t << "# End Source File" << endl; | ||
273 | } | ||
274 | // endGroups(t); | ||
275 | } else if(variable == "MSVCDSP_PICTURES") { | ||
276 | if(project->variables()["IMAGES"].isEmpty()) | ||
277 | continue; | ||
278 | |||
279 | t << "# Begin Group \"Images\"\n" | ||
280 | << "# Prop Default_Filter \"png jpeg bmp xpm\"\n"; | ||
281 | |||
282 | QStringList list = project->variables()["IMAGES"]; | ||
283 | if(!project->isActiveConfig("flat")) | ||
284 | list.sort(); | ||
285 | QStringList::Iterator it; | ||
286 | |||
287 | // dump the image list to a file UIC can read. | ||
288 | QFile f( "images.tmp" ); | ||
289 | f.open( IO_WriteOnly ); | ||
290 | QTextStream ts( &f ); | ||
291 | for( it = list.begin(); it != list.end(); ++it ) | ||
292 | ts << " " << *it; | ||
293 | f.close(); | ||
294 | |||
295 | // create an output step for images not more than once | ||
296 | bool imagesBuildDone = FALSE; | ||
297 | for( it = list.begin(); it != list.end(); ++it ) { | ||
298 | // beginGroupForFile((*it), t); | ||
299 | t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; | ||
300 | |||
301 | QString base = (*it); | ||
302 | QString uicpath = var("QMAKE_UIC"); | ||
303 | uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " "; | ||
304 | |||
305 | if ( !imagesBuildDone ) { | ||
306 | imagesBuildDone = TRUE; | ||
307 | QString build = "\n\n# Begin Custom Build - Creating image collection...\n" | ||
308 | "InputPath=.\\" + base + "\n\n"; | ||
309 | |||
310 | build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"; | ||
311 | build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o " | ||
312 | + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n"; | ||
313 | build.append("# End Custom Build\n\n"); | ||
314 | |||
315 | t << "USERDEP_" << base << "="; | ||
316 | QStringList::Iterator it2 = list.begin(); | ||
317 | while ( it2 != list.end() ) { | ||
318 | t << "\"" << (*it2) << "\""; | ||
319 | it2++; | ||
320 | if ( it2 != list.end() ) | ||
321 | t << "\\\n"; | ||
322 | } | ||
323 | t << endl << endl; | ||
324 | |||
325 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
326 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build | ||
327 | << "!ENDIF \n\n" << endl; | ||
328 | } | ||
329 | |||
330 | t << "# End Source File" << endl; | ||
331 | } | ||
332 | // endGroups(t); | ||
333 | t << "\n# End Group\n"; | ||
334 | } else if(variable == "MSVCDSP_FORMS") { | ||
335 | if(project->variables()["FORMS"].isEmpty()) | ||
336 | continue; | ||
337 | |||
338 | t << "# Begin Group \"Forms\"\n" | ||
339 | << "# Prop Default_Filter \"ui\"\n"; | ||
340 | |||
341 | QString uicpath = var("QMAKE_UIC"); | ||
342 | uicpath = uicpath.replace(QRegExp("\\..*$"), "") + " "; | ||
343 | QString mocpath = var( "QMAKE_MOC" ); | ||
344 | mocpath = mocpath.replace( QRegExp( "\\..*$" ), "" ) + " "; | ||
345 | |||
346 | QStringList list = project->variables()["FORMS"]; | ||
347 | if(!project->isActiveConfig("flat")) | ||
348 | list.sort(); | ||
349 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
350 | QString base = (*it); | ||
351 | // beginGroupForFile(base, t); | ||
352 | t << "# Begin Source File\n\nSOURCE=" << base << endl; | ||
353 | |||
354 | QString fname = base; | ||
355 | fname.replace(".ui", ""); | ||
356 | int lbs = fname.findRev( "\\" ); | ||
357 | QString fpath; | ||
358 | if ( lbs != -1 ) | ||
359 | fpath = fname.left( lbs + 1 ); | ||
360 | fname = fname.right( fname.length() - lbs - 1 ); | ||
361 | |||
362 | QString mocFile; | ||
363 | if(!project->variables()["MOC_DIR"].isEmpty()) | ||
364 | mocFile = project->first("MOC_DIR"); | ||
365 | else | ||
366 | mocFile = fpath; | ||
367 | |||
368 | QString uiSourcesDir; | ||
369 | QString uiHeadersDir; | ||
370 | if(!project->variables()["UI_DIR"].isEmpty()) { | ||
371 | uiSourcesDir = project->first("UI_DIR"); | ||
372 | uiHeadersDir = project->first("UI_DIR"); | ||
373 | } else { | ||
374 | if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) | ||
375 | uiSourcesDir = project->first("UI_SOURCES_DIR"); | ||
376 | else | ||
377 | uiSourcesDir = fpath; | ||
378 | if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) | ||
379 | uiHeadersDir = project->first("UI_HEADERS_DIR"); | ||
380 | else | ||
381 | uiHeadersDir = fpath; | ||
382 | } | ||
383 | |||
384 | t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\" \"$(QTDIR)\\bin\\uic.exe\"" << endl << endl; | ||
385 | |||
386 | QString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n" | ||
387 | "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base + | ||
388 | " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base + | ||
389 | " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n" | ||
390 | "\t" + mocpath + uiHeadersDir + fname + ".h -o " + mocFile + "moc_" + fname + ".cpp \\\n"; | ||
391 | |||
392 | build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" | ||
393 | "\t$(BuildCmds)\n\n" | ||
394 | "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" | ||
395 | "\t$(BuildCmds)\n\n" | ||
396 | "\"" + mocFile + "moc_" + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" | ||
397 | "\t$(BuildCmds)\n\n"); | ||
398 | |||
399 | build.append("# End Custom Build\n\n"); | ||
400 | |||
401 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
402 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build | ||
403 | << "!ENDIF \n\n" << "# End Source File" << endl; | ||
404 | } | ||
405 | // endGroups(t); | ||
406 | t << "\n# End Group\n"; | ||
407 | } else if(variable == "MSVCDSP_LEXSOURCES") { | ||
408 | if(project->variables()["LEXSOURCES"].isEmpty()) | ||
409 | continue; | ||
410 | |||
411 | t << "# Begin Group \"Lexables\"\n" | ||
412 | << "# Prop Default_Filter \"l\"\n"; | ||
413 | |||
414 | QString lexpath = var("QMAKE_LEX") + varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " "; | ||
415 | |||
416 | QStringList list = project->variables()["LEXSOURCES"]; | ||
417 | if(!project->isActiveConfig("flat")) | ||
418 | list.sort(); | ||
419 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
420 | QString fname = (*it); | ||
421 | // beginGroupForFile(fname, t); | ||
422 | t << "# Begin Source File\n\nSOURCE=" << fname << endl; | ||
423 | fname.replace(".l", Option::lex_mod + Option::cpp_ext.first()); | ||
424 | |||
425 | QString build = "\n\n# Begin Custom Build - Lex'ing " + (*it) + "...\n" | ||
426 | "InputPath=.\\" + (*it) + "\n\n" | ||
427 | "\"" + fname + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" | ||
428 | "\t" + lexpath + (*it) + "\\\n" | ||
429 | "\tdel " + fname + "\\\n" | ||
430 | "\tcopy lex.yy.c " + fname + "\n\n" + | ||
431 | "# End Custom Build\n\n"; | ||
432 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
433 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build | ||
434 | << "!ENDIF \n\n" << build | ||
435 | |||
436 | << "# End Source File" << endl; | ||
437 | } | ||
438 | // endGroups(t); | ||
439 | t << "\n# End Group\n"; | ||
440 | } else if(variable == "MSVCDSP_YACCSOURCES") { | ||
441 | if(project->variables()["YACCSOURCES"].isEmpty()) | ||
442 | continue; | ||
443 | |||
444 | t << "# Begin Group \"Yaccables\"\n" | ||
445 | << "# Prop Default_Filter \"y\"\n"; | ||
446 | |||
447 | QString yaccpath = var("QMAKE_YACC") + varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " "; | ||
448 | |||
449 | QStringList list = project->variables()["YACCSOURCES"]; | ||
450 | if(!project->isActiveConfig("flat")) | ||
451 | list.sort(); | ||
452 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
453 | QString fname = (*it); | ||
454 | // beginGroupForFile(fname, t); | ||
455 | t << "# Begin Source File\n\nSOURCE=" << fname << endl; | ||
456 | fname.replace(".y", Option::yacc_mod); | ||
457 | |||
458 | QString build = "\n\n# Begin Custom Build - Yacc'ing " + (*it) + "...\n" | ||
459 | "InputPath=.\\" + (*it) + "\n\n" | ||
460 | "\"" + fname + Option::cpp_ext.first() + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" | ||
461 | "\t" + yaccpath + (*it) + "\\\n" | ||
462 | "\tdel " + fname + Option::h_ext.first() + "\\\n" | ||
463 | "\tmove y.tab.h " + fname + Option::h_ext.first() + "\n\n" + | ||
464 | "\tdel " + fname + Option::cpp_ext.first() + "\\\n" | ||
465 | "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" + | ||
466 | "# End Custom Build\n\n"; | ||
467 | |||
468 | t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build | ||
469 | << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build | ||
470 | << "!ENDIF \n\n" | ||
471 | << "# End Source File" << endl; | ||
472 | } | ||
473 | // endGroups(t); | ||
474 | t << "\n# End Group\n"; | ||
475 | } else if( variable == "MSVCDSP_CONFIGMODE" ) { | ||
476 | if( project->isActiveConfig( "debug" ) ) | ||
477 | t << "Debug"; | ||
478 | else | ||
479 | t << "Release"; | ||
480 | } else if( variable == "MSVCDSP_IDLSOURCES" ) { | ||
481 | QStringList list = project->variables()["MSVCDSP_IDLSOURCES"]; | ||
482 | if(!project->isActiveConfig("flat")) | ||
483 | list.sort(); | ||
484 | for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { | ||
485 | t << "# Begin Source File" << endl << endl; | ||
486 | t << "SOURCE=" << (*it) << endl; | ||
487 | t << "# PROP Exclude_From_Build 1" << endl; | ||
488 | t << "# End Source File" << endl << endl; | ||
489 | } | ||
490 | } | ||
491 | else | ||
492 | t << var(variable); | ||
493 | } | ||
494 | t << line << endl; | ||
495 | } | ||
496 | t << endl; | ||
497 | file.close(); | ||
498 | return TRUE; | ||
499 | } | ||
500 | |||
501 | |||
502 | |||
503 | void | ||
504 | DspMakefileGenerator::init() | ||
505 | { | ||
506 | if(init_flag) | ||
507 | return; | ||
508 | QStringList::Iterator it; | ||
509 | init_flag = TRUE; | ||
510 | |||
511 | /* this should probably not be here, but I'm using it to wrap the .t files */ | ||
512 | if(project->first("TEMPLATE") == "vcapp" ) | ||
513 | project->variables()["QMAKE_APP_FLAG"].append("1"); | ||
514 | else if(project->first("TEMPLATE") == "vclib") | ||
515 | project->variables()["QMAKE_LIB_FLAG"].append("1"); | ||
516 | if ( project->variables()["QMAKESPEC"].isEmpty() ) | ||
517 | project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); | ||
518 | |||
519 | bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX); | ||
520 | project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; | ||
521 | |||
522 | QStringList &configs = project->variables()["CONFIG"]; | ||
523 | if (project->isActiveConfig("shared")) | ||
524 | project->variables()["DEFINES"].append("QT_DLL"); | ||
525 | if (project->isActiveConfig("qt_dll")) | ||
526 | if(configs.findIndex("qt") == -1) configs.append("qt"); | ||
527 | if ( project->isActiveConfig("qt") ) { | ||
528 | if ( project->isActiveConfig( "plugin" ) ) { | ||
529 | project->variables()["CONFIG"].append("dll"); | ||
530 | project->variables()["DEFINES"].append("QT_PLUGIN"); | ||
531 | } | ||
532 | if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && | ||
533 | ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || | ||
534 | project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || | ||
535 | (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { | ||
536 | project->variables()["QMAKE_QT_DLL"].append("1"); | ||
537 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) | ||
538 | project->variables()["CONFIG"].append("dll"); | ||
539 | } | ||
540 | } | ||
541 | if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { | ||
542 | project->variables()["CONFIG"].remove("staticlib"); | ||
543 | project->variables()["QMAKE_APP_OR_DLL"].append("1"); | ||
544 | } else { | ||
545 | project->variables()["CONFIG"].append("staticlib"); | ||
546 | } | ||
547 | |||
548 | if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { | ||
549 | project->variables()["CONFIG"].append("windows"); | ||
550 | } | ||
551 | if ( !project->variables()["VERSION"].isEmpty() ) { | ||
552 | QString version = project->variables()["VERSION"][0]; | ||
553 | int firstDot = version.find( "." ); | ||
554 | QString major = version.left( firstDot ); | ||
555 | QString minor = version.right( version.length() - firstDot - 1 ); | ||
556 | minor.replace( ".", "" ); | ||
557 | project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); | ||
558 | } | ||
559 | |||
560 | if ( project->isActiveConfig("qt") ) { | ||
561 | project->variables()["CONFIG"].append("moc"); | ||
562 | project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"]; | ||
563 | project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; | ||
564 | |||
565 | if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { | ||
566 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { | ||
567 | project->variables()["DEFINES"].append("QT_MAKEDLL"); | ||
568 | project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\""); | ||
569 | } | ||
570 | } else { | ||
571 | if(project->isActiveConfig("thread")) | ||
572 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; | ||
573 | else | ||
574 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; | ||
575 | if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { | ||
576 | int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); | ||
577 | if ( hver == -1 ) | ||
578 | hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt"); | ||
579 | if(hver != -1) { | ||
580 | QString ver; | ||
581 | ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); | ||
582 | QStringList &libs = project->variables()["QMAKE_LIBS"]; | ||
583 | for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) | ||
584 | (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver); | ||
585 | } | ||
586 | } | ||
587 | if ( project->isActiveConfig( "activeqt" ) ) { | ||
588 | project->variables().remove("QMAKE_LIBS_QT_ENTRY"); | ||
589 | project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; | ||
590 | if ( project->isActiveConfig( "dll" ) ) | ||
591 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; | ||
592 | } | ||
593 | if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { | ||
594 | project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; | ||
595 | } | ||
596 | } | ||
597 | } | ||
598 | |||
599 | if ( project->isActiveConfig("debug") ) { | ||
600 | if ( !project->first("OBJECTS_DIR").isEmpty() ) | ||
601 | project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR"); | ||
602 | else | ||
603 | project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; | ||
604 | project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; | ||
605 | if ( !project->first("DESTDIR").isEmpty() ) | ||
606 | project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR"); | ||
607 | else | ||
608 | project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; | ||
609 | project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; | ||
610 | } else { | ||
611 | if ( !project->first("OBJECTS_DIR").isEmpty() ) | ||
612 | project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); | ||
613 | project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; | ||
614 | if ( !project->first("DESTDIR").isEmpty() ) | ||
615 | project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); | ||
616 | else | ||
617 | project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; | ||
618 | project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; | ||
619 | } | ||
620 | |||
621 | if ( project->isActiveConfig("opengl") ) { | ||
622 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; | ||
623 | project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; | ||
624 | } | ||
625 | if ( project->isActiveConfig("thread") ) { | ||
626 | if(project->isActiveConfig("qt")) | ||
627 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); | ||
628 | if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain" | ||
629 | || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { | ||
630 | project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; | ||
631 | project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; | ||
632 | } else { | ||
633 | // YES we want to use the DLL even in a static build | ||
634 | project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; | ||
635 | project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"]; | ||
636 | } | ||
637 | if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt | ||
638 | && project->first("TARGET") != "qtmain" ) | ||
639 | project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); | ||
640 | } | ||
641 | |||
642 | if(project->isActiveConfig("qt")) { | ||
643 | if ( project->isActiveConfig("accessibility" ) ) | ||
644 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); | ||
645 | if ( project->isActiveConfig("tablet") ) | ||
646 | project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); | ||
647 | } | ||
648 | if ( project->isActiveConfig("dll") ) { | ||
649 | if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { | ||
650 | QString ver_xyz(project->first("VERSION")); | ||
651 | ver_xyz.replace(".", ""); | ||
652 | project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); | ||
653 | } else { | ||
654 | project->variables()["TARGET_EXT"].append(".dll"); | ||
655 | } | ||
656 | } else { | ||
657 | if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) | ||
658 | project->variables()["TARGET_EXT"].append(".exe"); | ||
659 | else | ||
660 | project->variables()["TARGET_EXT"].append(".lib"); | ||
661 | } | ||
662 | |||
663 | project->variables()["MSVCDSP_VER"] = "6.00"; | ||
664 | project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI"; | ||
665 | |||
666 | if(!project->isActiveConfig("incremental")) { | ||
667 | project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); | ||
668 | if ( is_qt ) | ||
669 | project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /Zi"; | ||
670 | } | ||
671 | |||
672 | QString msvcdsp_project; | ||
673 | if ( project->variables()["TARGET"].count() ) | ||
674 | msvcdsp_project = project->variables()["TARGET"].first(); | ||
675 | |||
676 | QString targetfilename = project->variables()["TARGET"].first(); | ||
677 | project->variables()["TARGET"].first() += project->first("TARGET_EXT"); | ||
678 | if ( project->isActiveConfig("moc") ) | ||
679 | setMocAware(TRUE); | ||
680 | |||
681 | project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; | ||
682 | project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', | ||
683 | "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); | ||
684 | QStringList &l = project->variables()["QMAKE_FILETAGS"]; | ||
685 | for(it = l.begin(); it != l.end(); ++it) { | ||
686 | QStringList &gdmf = project->variables()[(*it)]; | ||
687 | for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) | ||
688 | (*inner) = Option::fixPathToTargetOS((*inner), FALSE); | ||
689 | } | ||
690 | |||
691 | MakefileGenerator::init(); | ||
692 | if ( msvcdsp_project.isEmpty() ) | ||
693 | msvcdsp_project = Option::output.name(); | ||
694 | |||
695 | msvcdsp_project = msvcdsp_project.right( msvcdsp_project.length() - msvcdsp_project.findRev( "\\" ) - 1 ); | ||
696 | msvcdsp_project = msvcdsp_project.left( msvcdsp_project.findRev( "." ) ); | ||
697 | msvcdsp_project.replace("-", ""); | ||
698 | |||
699 | project->variables()["MSVCDSP_PROJECT"].append(msvcdsp_project); | ||
700 | QStringList &proj = project->variables()["MSVCDSP_PROJECT"]; | ||
701 | |||
702 | for(it = proj.begin(); it != proj.end(); ++it) | ||
703 | (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); | ||
704 | |||
705 | if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { | ||
706 | project->variables()["MSVCDSP_TEMPLATE"].append("win32app" + project->first( "DSP_EXTENSION" ) ); | ||
707 | if ( project->isActiveConfig("console") ) { | ||
708 | project->variables()["MSVCDSP_CONSOLE"].append("Console"); | ||
709 | project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE"); | ||
710 | project->variables()["MSVCDSP_DSPTYPE"].append("0x0103"); | ||
711 | project->variables()["MSVCDSP_SUBSYSTEM"].append("console"); | ||
712 | } else { | ||
713 | project->variables()["MSVCDSP_CONSOLE"].clear(); | ||
714 | project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); | ||
715 | project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); | ||
716 | project->variables()["MSVCDSP_SUBSYSTEM"].append("windows"); | ||
717 | } | ||
718 | } else { | ||
719 | if ( project->isActiveConfig("dll") ) { | ||
720 | project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) ); | ||
721 | } else { | ||
722 | project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) ); | ||
723 | } | ||
724 | } | ||
725 | |||
726 | project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; | ||
727 | |||
728 | project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; | ||
729 | if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) | ||
730 | project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); | ||
731 | project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; | ||
732 | project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); | ||
733 | project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); | ||
734 | |||
735 | QStringList &libs = project->variables()["QMAKE_LIBS"]; | ||
736 | for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { | ||
737 | QString lib = (*libit); | ||
738 | lib.replace(QRegExp("\""), ""); | ||
739 | project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\""); | ||
740 | } | ||
741 | |||
742 | QStringList &incs = project->variables()["INCLUDEPATH"]; | ||
743 | for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { | ||
744 | QString inc = (*incit); | ||
745 | inc.replace("\"", ""); | ||
746 | project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); | ||
747 | } | ||
748 | |||
749 | project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\""); | ||
750 | if ( project->isActiveConfig("qt") ) { | ||
751 | project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\""); | ||
752 | } else { | ||
753 | project->variables()["MSVCDSP_RELDEFS"].clear(); | ||
754 | } | ||
755 | |||
756 | QString dest; | ||
757 | if ( !project->variables()["DESTDIR"].isEmpty() ) { | ||
758 | project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); | ||
759 | Option::fixPathToTargetOS(project->first("TARGET")); | ||
760 | dest = project->first("TARGET"); | ||
761 | if ( project->first("TARGET").startsWith("$(QTDIR)") ) | ||
762 | dest.replace( "$(QTDIR)", getenv("QTDIR") ); | ||
763 | project->variables()["MSVCDSP_TARGET"].append( | ||
764 | QString("/out:\"") + dest + "\""); | ||
765 | if ( project->isActiveConfig("dll") ) { | ||
766 | QString imp = dest; | ||
767 | imp.replace(".dll", ".lib"); | ||
768 | project->variables()["MSVCDSP_TARGET"].append(QString(" /implib:\"") + imp + "\""); | ||
769 | } | ||
770 | } | ||
771 | if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { | ||
772 | QStringList dlldirs = project->variables()["DLLDESTDIR"]; | ||
773 | QString copydll = "# Begin Special Build Tool\n" | ||
774 | "TargetPath=" + dest + "\n" | ||
775 | "SOURCE=$(InputPath)\n" | ||
776 | "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" | ||
777 | "PostBuild_Cmds="; | ||
778 | |||
779 | for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { | ||
780 | copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; | ||
781 | } | ||
782 | |||
783 | copydll += "\n# End Special Build Tool"; | ||
784 | project->variables()["MSVCDSP_COPY_DLL_REL"].append( copydll ); | ||
785 | project->variables()["MSVCDSP_COPY_DLL_DBG"].append( copydll ); | ||
786 | } | ||
787 | if ( project->isActiveConfig("activeqt") ) { | ||
788 | QString idl = project->variables()["QMAKE_IDL"].first(); | ||
789 | QString idc = project->variables()["QMAKE_IDC"].first(); | ||
790 | QString version = project->variables()["VERSION"].first(); | ||
791 | if ( version.isEmpty() ) | ||
792 | version = "1.0"; | ||
793 | |||
794 | project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); | ||
795 | project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); | ||
796 | project->variables()["MSVCDSP_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" ); | ||
797 | if ( project->isActiveConfig( "dll" ) ) { | ||
798 | QString regcmd = "# Begin Special Build Tool\n" | ||
799 | "TargetPath=" + targetfilename + "\n" | ||
800 | "SOURCE=$(InputPath)\n" | ||
801 | "PostBuild_Desc=Finalizing ActiveQt server...\n" | ||
802 | "PostBuild_Cmds=" + | ||
803 | idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version + | ||
804 | "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" | ||
805 | "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" | ||
806 | "\t" + idc + " %1 /regserver\n" | ||
807 | "# End Special Build Tool"; | ||
808 | |||
809 | QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); | ||
810 | project->variables()["MSVCDSP_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); | ||
811 | |||
812 | executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); | ||
813 | project->variables()["MSVCDSP_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); | ||
814 | } else { | ||
815 | QString regcmd = "# Begin Special Build Tool\n" | ||
816 | "TargetPath=" + targetfilename + "\n" | ||
817 | "SOURCE=$(InputPath)\n" | ||
818 | "PostBuild_Desc=Finalizing ActiveQt server...\n" | ||
819 | "PostBuild_Cmds=" | ||
820 | "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version + | ||
821 | "\t" + idl + " tmp\\" + targetfilename + ".idl /nologo /o tmp\\" + targetfilename + ".midl /tlb tmp\\" + targetfilename + ".tlb /iid tmp\\dump.midl /dlldata tmp\\dump.midl /cstub tmp\\dump.midl /header tmp\\dump.midl /proxy tmp\\dump.midl /sstub tmp\\dump.midl" | ||
822 | "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" | ||
823 | "\t%1 -regserver\n" | ||
824 | "# End Special Build Tool"; | ||
825 | |||
826 | QString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); | ||
827 | project->variables()["MSVCDSP_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); | ||
828 | |||
829 | executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); | ||
830 | project->variables()["MSVCDSP_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); | ||
831 | } | ||
832 | |||
833 | } | ||
834 | if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) { | ||
835 | project->variables()["SOURCES"] += project->variables()["RC_FILE"]; | ||
836 | } | ||
837 | QStringList &list = project->variables()["FORMS"]; | ||
838 | for( it = list.begin(); it != list.end(); ++it ) { | ||
839 | if ( QFile::exists( *it + ".h" ) ) | ||
840 | project->variables()["SOURCES"].append( *it + ".h" ); | ||
841 | } | ||
842 | project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS"; | ||
843 | } | ||
844 | |||
845 | |||
846 | QString | ||
847 | DspMakefileGenerator::findTemplate(QString file) | ||
848 | { | ||
849 | QString ret; | ||
850 | if(!QFile::exists((ret = file)) && | ||
851 | !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && | ||
852 | !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) && | ||
853 | !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file)))) | ||
854 | return ""; | ||
855 | return ret; | ||
856 | } | ||
857 | |||
858 | |||
859 | void | ||
860 | DspMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l) | ||
861 | { | ||
862 | if(var == "QMAKE_PRL_DEFINES") { | ||
863 | QStringList &out = project->variables()["MSVCDSP_DEFINES"]; | ||
864 | for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { | ||
865 | if(out.findIndex((*it)) == -1) | ||
866 | out.append((" /D \"" + *it + "\"")); | ||
867 | } | ||
868 | } else { | ||
869 | MakefileGenerator::processPrlVariable(var, l); | ||
870 | } | ||
871 | } | ||
872 | |||
873 | |||
874 | int | ||
875 | DspMakefileGenerator::beginGroupForFile(QString file, QTextStream &t, | ||
876 | QString filter) | ||
877 | { | ||
878 | if(project->isActiveConfig("flat")) | ||
879 | return 0; | ||
880 | |||
881 | fileFixify(file, QDir::currentDirPath(), QDir::currentDirPath(), TRUE); | ||
882 | file = file.section(Option::dir_sep, 0, -2); | ||
883 | if(file.right(Option::dir_sep.length()) != Option::dir_sep) | ||
884 | file += Option::dir_sep; | ||
885 | if(file == currentGroup) | ||
886 | return 0; | ||
887 | |||
888 | if(file.isEmpty() || !QDir::isRelativePath(file)) { | ||
889 | endGroups(t); | ||
890 | return 0; | ||
891 | } | ||
892 | if(file.startsWith(currentGroup)) | ||
893 | file = file.mid(currentGroup.length()); | ||
894 | else | ||
895 | endGroups(t); | ||
896 | int lvl = file.contains(Option::dir_sep), old_lvl = currentGroup.contains(Option::dir_sep); | ||
897 | if(lvl > old_lvl) { | ||
898 | QStringList dirs = QStringList::split(Option::dir_sep, file); | ||
899 | for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { | ||
900 | t << "# Begin Group \"" << (*dir_it) << "\"\n" | ||
901 | << "# Prop Default_Filter \"" << filter << "\"\n"; | ||
902 | } | ||
903 | } else { | ||
904 | for(int x = old_lvl - lvl; x; x--) | ||
905 | t << "\n# End Group\n"; | ||
906 | } | ||
907 | currentGroup = file; | ||
908 | return lvl - old_lvl; | ||
909 | } | ||
910 | |||
911 | |||
912 | int | ||
913 | DspMakefileGenerator::endGroups(QTextStream &t) | ||
914 | { | ||
915 | if(project->isActiveConfig("flat")) | ||
916 | return 0; | ||
917 | else if(currentGroup.isEmpty()) | ||
918 | return 0; | ||
919 | |||
920 | QStringList dirs = QStringList::split(Option::dir_sep, currentGroup); | ||
921 | for(QStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) { | ||
922 | t << "\n# End Group\n"; | ||
923 | } | ||
924 | currentGroup = ""; | ||
925 | return dirs.count(); | ||
926 | } | ||
927 | |||
928 | bool | ||
929 | DspMakefileGenerator::openOutput(QFile &file) const | ||
930 | { | ||
931 | QString outdir; | ||
932 | if(!file.name().isEmpty()) { | ||
933 | QFileInfo fi(file); | ||
934 | if(fi.isDir()) | ||
935 | outdir = file.name() + QDir::separator(); | ||
936 | } | ||
937 | if(!outdir.isEmpty() || file.name().isEmpty()) | ||
938 | file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION")); | ||
939 | if(QDir::isRelativePath(file.name())) { | ||
940 | QString ofile; | ||
941 | ofile = file.name(); | ||
942 | int slashfind = ofile.findRev('\\'); | ||
943 | if (slashfind == -1) { | ||
944 | ofile = ofile.replace(QRegExp("-"), "_"); | ||
945 | } else { | ||
946 | int hypenfind = ofile.find('-', slashfind); | ||
947 | while (hypenfind != -1 && slashfind < hypenfind) { | ||
948 | ofile = ofile.replace(hypenfind, 1, "_"); | ||
949 | hypenfind = ofile.find('-', hypenfind + 1); | ||
950 | } | ||
951 | } | ||
952 | file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile)); | ||
953 | } | ||
954 | return Win32MakefileGenerator::openOutput(file); | ||
955 | } | ||