summaryrefslogtreecommitdiff
path: root/qmake/generators/win32
authorkergoth <kergoth>2002-11-01 00:10:42 (UTC)
committer kergoth <kergoth>2002-11-01 00:10:42 (UTC)
commit5042e3cf0d3514552769e441f5aad590c8eaf967 (patch) (unidiff)
tree4a5ea45f3519d981a172ab5275bf38c6fa778dec /qmake/generators/win32
parent108c1c753e74e989cc13923086996791428c9af4 (diff)
downloadopie-5042e3cf0d3514552769e441f5aad590c8eaf967.zip
opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.gz
opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.bz2
Adding qmake in preperation for new build system
Diffstat (limited to 'qmake/generators/win32') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/win32/borland_bmake.cpp477
-rw-r--r--qmake/generators/win32/borland_bmake.h59
-rw-r--r--qmake/generators/win32/msvc_dsp.cpp955
-rw-r--r--qmake/generators/win32/msvc_dsp.h73
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp488
-rw-r--r--qmake/generators/win32/msvc_nmake.h59
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp1955
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h775
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp1050
-rw-r--r--qmake/generators/win32/msvc_vcproj.h129
-rw-r--r--qmake/generators/win32/winmakefile.cpp360
-rw-r--r--qmake/generators/win32/winmakefile.h72
12 files changed, 6452 insertions, 0 deletions
diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp
new file mode 100644
index 0000000..ae7b47b
--- a/dev/null
+++ b/qmake/generators/win32/borland_bmake.cpp
@@ -0,0 +1,477 @@
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 "borland_bmake.h"
39#include "option.h"
40#include <qdir.h>
41#include <qregexp.h>
42#include <time.h>
43#include <stdlib.h>
44
45
46BorlandMakefileGenerator::BorlandMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{
48
49}
50
51bool
52BorlandMakefileGenerator::writeMakefile(QTextStream &t)
53{
54 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl;
60 return TRUE;
61 }
62
63 if(project->first("TEMPLATE") == "app" ||
64 project->first("TEMPLATE") == "lib") {
65 writeBorlandParts(t);
66 return MakefileGenerator::writeMakefile(t);
67 }
68 else if(project->first("TEMPLATE") == "subdirs") {
69 writeSubDirs(t);
70 return TRUE;
71 }
72 return FALSE;
73}
74
75void
76BorlandMakefileGenerator::writeBorlandParts(QTextStream &t)
77{
78 t << "!if !$d(BCB)" << endl;
79 t << "BCB = $(MAKEDIR)\\.." << endl;
80 t << "!endif" << endl << endl;
81 t << "####### Compiler, tools and options" << endl << endl;
82 t << "CC =" << var("QMAKE_CC") << endl;
83 t << "CXX =" << var("QMAKE_CXX") << endl;
84 t << "LEX = " << var("QMAKE_LEX") << endl;
85 t << "YACC = " << var("QMAKE_YACC") << endl;
86 t << "CFLAGS =" << var("QMAKE_CFLAGS") << " "
87 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
88 << varGlue("DEFINES","-D"," -D","") << endl;
89 t << "CXXFLAGS=" << var("QMAKE_CXXFLAGS") << " "
90 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
91 << varGlue("DEFINES","-D"," -D","") << endl;
92 t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
93 t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
94
95 t << "INCPATH =";
96 QStringList &incs = project->variables()["INCLUDEPATH"];
97 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
98 QString inc = (*incit);
99 inc.replace(QRegExp("\\\\*$"), "");
100 inc.replace("\"", "");
101 t << " -I\"" << inc << "\"";
102 }
103 t << " -I\"" << specdir() << "\""
104 << endl;
105
106 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
107 t << "LINK =" << var("QMAKE_LINK") << endl;
108 t << "LFLAGS =";
109 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
110 t << varGlue("QMAKE_LIBDIR","-L",";","") << " ";
111 t << var("QMAKE_LFLAGS") << endl;
112 t << "LIBS =" << var("QMAKE_LIBS") << endl;
113 }
114 else {
115 t << "LIB =" << var("QMAKE_LIB") << endl;
116 }
117 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
118 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
119 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
120 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
121 t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
122 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
123 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
124 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
125 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
126 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
127 t << "ZIP =" << var("QMAKE_ZIP") << endl;
128 t << "DEF_FILE =" << varList("DEF_FILE") << endl;
129 t << "RES_FILE =" << varList("RES_FILE") << endl;
130 t << "COPY_FILE = " << var("QMAKE_COPY") << endl;
131 t << "COPY_DIR = " << var("QMAKE_COPY") << endl;
132 t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
133 t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl;
134 t << "MOVE = " << var("QMAKE_MOVE") << endl;
135 t << endl;
136
137 t << "####### Files" << endl << endl;
138 t << "HEADERS =" << varList("HEADERS") << endl;
139 t << "SOURCES =" << varList("SOURCES") << endl;
140 t << "OBJECTS =" << varList("OBJECTS") << endl;
141 t << "FORMS =" << varList("FORMS") << endl;
142 t << "UICDECLS =" << varList("UICDECLS") << endl;
143 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
144 t << "SRCMOC =" << varList("SRCMOC") << endl;
145 t << "OBJMOC =" << varList("OBJMOC") << endl;
146 t << "DIST =" << varList("DISTFILES") << endl;
147 t << "TARGET ="
148 << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"))
149 << endl;
150 t << endl;
151
152 t << "####### Implicit rules" << endl << endl;
153 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl;
154 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
155 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
156 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
157 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
158
159 t << "####### Build rules" << endl << endl;
160 t << "all: " << varGlue("ALL_DEPS",""," "," ") << " $(TARGET)" << endl << endl;
161 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS");
162 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
163 t << "\n\t" << "$(LINK) @&&|" << "\n\t"
164 << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)";
165 } else {
166 t << "\n\t-del $(TARGET)"
167 << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+"
168 << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+"
169 << project->variables()["OBJMOC"].join(" \\\n+");
170 }
171 t << endl << "|" << endl;
172 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
173 QStringList dlldirs = project->variables()["DLLDESTDIR"];
174 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
175 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
176 }
177 }
178 QString targetfilename = project->variables()["TARGET"].first();
179 if(project->isActiveConfig("activeqt")) {
180 QString version = project->variables()["VERSION"].first();
181 if ( version.isEmpty() )
182 version = "1.0";
183
184 if ( project->isActiveConfig("dll")) {
185 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
186 t << "\n\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");
187 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
188 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
189 } else {
190 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
191 t << "\n\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");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
193 t << "\n\t" << ("-$(TARGET) -regserver");
194 }
195 }
196 t << endl << endl;
197
198 if(!project->variables()["RC_FILE"].isEmpty()) {
199 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
200 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
201 }
202 t << "mocables: $(SRCMOC)" << endl << endl;
203
204 writeMakeQmake(t);
205
206 t << "dist:" << "\n\t"
207 << "$(ZIP) " << var("PROJECT") << ".zip " << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)"
208 << endl << endl;
209
210 t << "clean:\n"
211 << varGlue("OBJECTS","\t-del ","\n\t-del ","")
212 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
213 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
214 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
215 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
216 << "\n\t-del $(TARGET)"
217 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
218 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
219 if ( project->isActiveConfig("activeqt")) {
220 t << ("\n\t-del tmp\\" + targetfilename + ".*");
221 t << "\n\t-del tmp\\dump.*";
222 }
223 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty())
224 t << "\n\t-del " << var("DLLDESTDIR") << "\\" << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
225 if(!project->isEmpty("IMAGES"))
226 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
227
228 // blasted user defined targets
229 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
230 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
231 QString targ = var((*it) + ".target"),
232 cmd = var((*it) + ".commands"), deps;
233 if(targ.isEmpty())
234 targ = (*it);
235 QStringList &deplist = project->variables()[(*it) + ".depends"];
236 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
237 QString dep = var((*dep_it) + ".target");
238 if(dep.isEmpty())
239 dep = (*dep_it);
240 deps += " " + dep;
241 }
242 t << "\n\n" << targ << ":" << deps << "\n\t"
243 << cmd;
244 }
245
246 t << endl << endl;
247}
248
249void
250BorlandMakefileGenerator::init()
251{
252 if(init_flag)
253 return;
254 init_flag = TRUE;
255
256 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
257
258 /* this should probably not be here, but I'm using it to wrap the .t files */
259 if(project->first("TEMPLATE") == "app")
260 project->variables()["QMAKE_APP_FLAG"].append("1");
261 else if(project->first("TEMPLATE") == "lib")
262 project->variables()["QMAKE_LIB_FLAG"].append("1");
263 else if(project->first("TEMPLATE") == "subdirs") {
264 MakefileGenerator::init();
265 if(project->variables()["MAKEFILE"].isEmpty())
266 project->variables()["MAKEFILE"].append("Makefile");
267 if(project->variables()["QMAKE"].isEmpty())
268 project->variables()["QMAKE"].append("qmake");
269 return;
270 }
271
272 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qtmt"QTDLL_POSTFIX);
273 QStringList &configs = project->variables()["CONFIG"];
274 if (project->isActiveConfig("shared"))
275 project->variables()["DEFINES"].append("QT_DLL");
276 if (project->isActiveConfig("qt_dll"))
277 if(configs.findIndex("qt") == -1) configs.append("qt");
278 if ( project->isActiveConfig("qt") ) {
279 if ( project->isActiveConfig("plugin") ) {
280 project->variables()["CONFIG"].append("dll");
281 project->variables()["DEFINES"].append("QT_PLUGIN");
282 }
283 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
284 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
285 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
286 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
287 project->variables()["QMAKE_QT_DLL"].append("1");
288 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
289 project->variables()["CONFIG"].append("dll");
290 }
291 }
292 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
293 project->variables()["CONFIG"].remove("staticlib");
294 project->variables()["QMAKE_APP_OR_DLL"].append("1");
295 } else {
296 project->variables()["CONFIG"].append("staticlib");
297 }
298 if ( project->isActiveConfig("warn_off") ) {
299 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
300 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
301 } else if ( project->isActiveConfig("warn_on") ) {
302 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
303 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
304 }
305 if(project->isActiveConfig("qt")) {
306 if ( project->isActiveConfig("thread") )
307 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
308 if ( project->isActiveConfig("accessibility" ) )
309 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
310 if ( project->isActiveConfig("tablet") )
311 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
312 }
313
314 if ( project->isActiveConfig("debug") ) {
315 if ( project->isActiveConfig("thread") ) {
316 if ( project->isActiveConfig("dll") ) {
317 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
318 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
319 } else {
320 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
321 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
322 }
323 }
324 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
325 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
326 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
327 } else {
328 if ( project->isActiveConfig("thread") ) {
329 if ( project->isActiveConfig("dll") ) {
330 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
331 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
332 } else {
333 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
334 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
335 }
336 }
337 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
338 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
339 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
340 }
341
342 if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) {
343 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
344 }
345 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) {
346 project->variables()["CONFIG"].append("windows");
347 }
348 if ( project->isActiveConfig("qt") ) {
349 project->variables()["CONFIG"].append("moc");
350 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
351 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
352 if ( !project->isActiveConfig("debug") )
353 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
354 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
355 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
356 project->variables()["DEFINES"].append("QT_MAKEDLL");
357 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
358 }
359 } else {
360 if(project->isActiveConfig("thread"))
361 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
362 else
363 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
364 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
365 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
366 if ( hver == -1 )
367 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
368 if(hver != -1) {
369 QString ver;
370 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver);
371 QStringList &libs = project->variables()["QMAKE_LIBS"];
372 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
373 (*libit).replace(QRegExp("qt(mt)?\\.lib"), ver);
374 }
375 }
376 if ( project->isActiveConfig( "activeqt" ) ) {
377 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
378 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
379 if ( project->isActiveConfig( "dll" ) )
380 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
381 }
382 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
383 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
384 }
385 }
386 }
387 if ( project->isActiveConfig("opengl") ) {
388 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
389 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
390 }
391 if ( project->isActiveConfig("dll") ) {
392 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
393 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
394 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
395 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
396 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
397 project->variables()["TARGET_EXT"].append(
398 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
399 } else {
400 project->variables()["TARGET_EXT"].append(".dll");
401 }
402 } else {
403 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
404 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
405 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
406 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
407 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
408 project->variables()["TARGET_EXT"].append(".exe");
409 } else {
410 project->variables()["TARGET_EXT"].append(".lib");
411 }
412 }
413 if ( project->isActiveConfig("windows") ) {
414 if ( project->isActiveConfig("console") ) {
415 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
416 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
417 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
418 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
419 } else {
420 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
421 }
422 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
423 } else {
424 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
425 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
426 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
428 }
429 if ( project->isActiveConfig("thread") ) {
430 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"];
431 } else {
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"];
433 }
434 if ( project->isActiveConfig("moc") ) {
435 setMocAware(TRUE);
436 }
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 }
446
447 if ( !project->variables()["RC_FILE"].isEmpty()) {
448 if ( !project->variables()["RES_FILE"].isEmpty()) {
449 fprintf(stderr, "Both .rc and .res file specified.\n");
450 fprintf(stderr, "Please specify one of them, not both.");
451 exit(666);
452 }
453 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
454 project->variables()["RES_FILE"].first().replace(".rc",".res");
455 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"];
456 }
457 MakefileGenerator::init();
458 if ( !project->variables()["VERSION"].isEmpty()) {
459 QStringList l = QStringList::split('.', project->first("VERSION"));
460 project->variables()["VER_MAJ"].append(l[0]);
461 project->variables()["VER_MIN"].append(l[1]);
462 }
463
464 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
465 // bcc does not generate a .tds file for static libs
466 QString tdsPostfix;
467 if ( !project->variables()["VERSION"].isEmpty() ) {
468 tdsPostfix = QStringList::split( '.', project->first("VERSION") ).join("")
469 + ".tds";
470 } else {
471 tdsPostfix = ".tds";
472 }
473 project->variables()["QMAKE_CLEAN"].append(
474 project->first("DESTDIR") + project->first("TARGET") + tdsPostfix );
475 }
476}
477
diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h
new file mode 100644
index 0000000..90f8229
--- a/dev/null
+++ b/qmake/generators/win32/borland_bmake.h
@@ -0,0 +1,59 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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#ifndef __BORLANDMAKE_H__
38#define __BORLANDMAKE_H__
39
40#include "winmakefile.h"
41
42class BorlandMakefileGenerator : public Win32MakefileGenerator
43{
44 bool init_flag;
45 void writeBorlandParts(QTextStream &);
46
47 bool writeMakefile(QTextStream &);
48 void init();
49
50public:
51 BorlandMakefileGenerator(QMakeProject *p);
52 ~BorlandMakefileGenerator();
53};
54
55inline BorlandMakefileGenerator::~BorlandMakefileGenerator()
56{ }
57
58
59#endif /* __BORLANDMAKE_H__ */
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
45DspMakefileGenerator::DspMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
46{
47
48}
49
50bool
51DspMakefileGenerator::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
72bool
73DspMakefileGenerator::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
503void
504DspMakefileGenerator::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
846QString
847DspMakefileGenerator::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
859void
860DspMakefileGenerator::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
874int
875DspMakefileGenerator::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
912int
913DspMakefileGenerator::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
928bool
929DspMakefileGenerator::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}
diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h
new file mode 100644
index 0000000..a7fc3e7
--- a/dev/null
+++ b/qmake/generators/win32/msvc_dsp.h
@@ -0,0 +1,73 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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#ifndef __DSPMAKE_H__
38#define __DSPMAKE_H__
39
40#include "winmakefile.h"
41#include <qvaluestack.h>
42
43class DspMakefileGenerator : public Win32MakefileGenerator
44{
45 QString currentGroup;
46 int beginGroupForFile(QString file, QTextStream &, const QString filter="");
47 int endGroups(QTextStream &);
48
49 bool init_flag;
50 bool writeDspParts(QTextStream &);
51
52 bool writeMakefile(QTextStream &);
53 QString findTemplate(QString file);
54 void init();
55
56public:
57 DspMakefileGenerator(QMakeProject *p);
58 ~DspMakefileGenerator();
59
60 bool openOutput(QFile &file) const;
61
62protected:
63 virtual void processPrlVariable(const QString &, const QStringList &);
64 virtual bool findLibraries();
65};
66
67inline DspMakefileGenerator::~DspMakefileGenerator()
68{ }
69
70inline bool DspMakefileGenerator::findLibraries()
71{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); }
72
73#endif /* __DSPMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
new file mode 100644
index 0000000..9cc9a69
--- a/dev/null
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -0,0 +1,488 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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_nmake.h"
39#include "option.h"
40#include <qregexp.h>
41#include <qdir.h>
42#include <stdlib.h>
43#include <time.h>
44
45
46NmakeMakefileGenerator::NmakeMakefileGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
47{
48
49}
50
51bool
52NmakeMakefileGenerator::writeMakefile(QTextStream &t)
53{
54 writeHeader(t);
55 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
56 t << "all clean:" << "\n\t"
57 << "@echo \"Some of the required modules ("
58 << var("QMAKE_FAILED_REQUIREMENTS") << ") are not available.\"" << "\n\t"
59 << "@echo \"Skipped.\"" << endl << endl;
60 writeMakeQmake(t);
61 return TRUE;
62 }
63
64 if(project->first("TEMPLATE") == "app" ||
65 project->first("TEMPLATE") == "lib") {
66 writeNmakeParts(t);
67 return MakefileGenerator::writeMakefile(t);
68 }
69 else if(project->first("TEMPLATE") == "subdirs") {
70 writeSubDirs(t);
71 return TRUE;
72 }
73 return FALSE;
74}
75
76void
77NmakeMakefileGenerator::writeNmakeParts(QTextStream &t)
78{
79 t << "####### Compiler, tools and options" << endl << endl;
80 t << "CC =" << var("QMAKE_CC") << endl;
81 t << "CXX =" << var("QMAKE_CXX") << endl;
82 t << "LEX = " << var("QMAKE_LEX") << endl;
83 t << "YACC = " << var("QMAKE_YACC") << endl;
84 t << "CFLAGS =" << var("QMAKE_CFLAGS") << " "
85 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
86 << varGlue("DEFINES","-D"," -D","") << endl;
87 t << "CXXFLAGS =" << var("QMAKE_CXXFLAGS") << " "
88 << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " "
89 << varGlue("DEFINES","-D"," -D","") << endl;
90 t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl;
91 t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl;
92
93 t << "INCPATH =";
94 QStringList &incs = project->variables()["INCLUDEPATH"];
95 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
96 QString inc = (*incit);
97 inc.replace(QRegExp("\\\\$"), "\\\\");
98 inc.replace("\"", "");
99 t << " -I\"" << inc << "\"";
100 }
101 t << " -I\"" << specdir() << "\""
102 << endl;
103 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
104 t << "LINK =" << var("QMAKE_LINK") << endl;
105 t << "LFLAGS =" << var("QMAKE_LFLAGS");
106 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
107 t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"");
108 t << endl;
109 t << "LIBS =";
110 QStringList &libs = project->variables()["QMAKE_LIBS"];
111 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) {
112 QString lib = (*libit);
113 lib.replace(QRegExp("\\\\$"), "\\\\");
114 lib.replace(QRegExp("\""), "");
115 t << " \"" << lib << "\"";
116 }
117 t << endl;
118 }
119 else {
120 t << "LIB =" << var("QMAKE_LIB") << endl;
121 }
122 t << "MOC =" << (project->isEmpty("QMAKE_MOC") ? QString("moc") :
123 Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl;
124 t << "UIC =" << (project->isEmpty("QMAKE_UIC") ? QString("uic") :
125 Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl;
126 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") :
127 Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl;
128 t << "IDC =" << (project->isEmpty("QMAKE_IDC") ? QString("idc") :
129 Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl;
130 t << "IDL =" << (project->isEmpty("QMAKE_IDL") ? QString("midl") :
131 Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl;
132 t << "ZIP =" << var("QMAKE_ZIP") << endl;
133 t << "COPY_FILE= " << var("QMAKE_COPY") << endl;
134 t << "COPY_DIR= " << var("QMAKE_COPY") << endl;
135 t << "DEL_FILE= " << var("QMAKE_DEL_FILE") << endl;
136 t << "DEL_DIR= " << var("QMAKE_DEL_DIR") << endl;
137 t << "MOVE = " << var("QMAKE_MOVE") << endl;
138 t << endl;
139
140 t << "####### Files" << endl << endl;
141 t << "HEADERS =" << varList("HEADERS") << endl;
142 t << "SOURCES =" << varList("SOURCES") << endl;
143 t << "OBJECTS =" << varList("OBJECTS") << endl;
144 t << "FORMS =" << varList("FORMS") << endl;
145 t << "UICDECLS =" << varList("UICDECLS") << endl;
146 t << "UICIMPLS =" << varList("UICIMPLS") << endl;
147 t << "SRCMOC =" << varList("SRCMOC") << endl;
148 t << "OBJMOC =" << varList("OBJMOC") << endl;
149 t << "DIST =" << varList("DISTFILES") << endl;
150 t << "TARGET =";
151 if( !project->variables()[ "DESTDIR" ].isEmpty() )
152 t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT"));
153 else
154 t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first();
155 t << endl;
156 t << endl;
157
158 t << "####### Implicit rules" << endl << endl;
159 t << ".SUFFIXES: .cpp .cxx .cc .c" << endl << endl;
160 t << ".cpp.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
161 t << ".cxx.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
162 t << ".cc.obj:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl;
163 t << ".c.obj:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl;
164
165 t << "####### Build rules" << endl << endl;
166 t << "all: " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl;
167 t << "$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) " << var("TARGETDEPS");
168 if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) {
169 t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t "
170 << "$(OBJECTS) $(OBJMOC) $(LIBS)";
171 } else {
172 t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t "
173 << "$(OBJECTS) $(OBJMOC)";
174 }
175 t << endl << "<<" << endl;
176 if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) {
177 QStringList dlldirs = project->variables()["DLLDESTDIR"];
178 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
179 t << "\n\t" << "-copy $(TARGET) " << *dlldir;
180 }
181 }
182 QString targetfilename = project->variables()["TARGET"].first();
183 if(project->isActiveConfig("activeqt")) {
184 QString version = project->variables()["VERSION"].first();
185 if ( version.isEmpty() )
186 version = "1.0";
187
188 if ( project->isActiveConfig("dll")) {
189 t << "\n\t" << ("-$(IDC) $(TARGET) /idl tmp\\" + targetfilename + ".idl -version " + version);
190 t << "\n\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");
191 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
192 t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" );
193 } else {
194 t << "\n\t" << ("-$(TARGET) -dumpidl tmp\\" + targetfilename + ".idl -version " + version);
195 t << "\n\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");
196 t << "\n\t" << ("-$(IDC) $(TARGET) /tlb tmp\\" + targetfilename + ".tlb");
197 t << "\n\t" << "-$(TARGET) -regserver";
198 }
199 }
200 t << endl << endl;
201
202 if(!project->variables()["RC_FILE"].isEmpty()) {
203 t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t"
204 << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl;
205 }
206
207 t << "mocables: $(SRCMOC)" << endl << endl;
208
209 writeMakeQmake(t);
210
211 t << "dist:" << "\n\t"
212 << "$(ZIP) " << var("PROJECT") << ".zip "
213 << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl;
214
215 t << "clean:"
216 << varGlue("OBJECTS","\n\t-del ","\n\t-del ","")
217 << varGlue("SRCMOC" ,"\n\t-del ","\n\t-del ","")
218 << varGlue("OBJMOC" ,"\n\t-del ","\n\t-del ","")
219 << varGlue("UICDECLS" ,"\n\t-del ","\n\t-del ","")
220 << varGlue("UICIMPLS" ,"\n\t-del ","\n\t-del ","")
221 << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ","")
222 << varGlue("CLEAN_FILES","\n\t-del ","\n\t-del ","");
223 if ( project->isActiveConfig("activeqt")) {
224 t << ("\n\t-del tmp\\" + targetfilename + ".*");
225 t << "\n\t-del tmp\\dump.*";
226 }
227 if(!project->isEmpty("IMAGES"))
228 t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-del ", "\n\t-del ", "");
229
230 // blasted user defined targets
231 QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"];
232 for(QStringList::Iterator it = qut.begin(); it != qut.end(); ++it) {
233 QString targ = var((*it) + ".target"),
234 cmd = var((*it) + ".commands"), deps;
235 if(targ.isEmpty())
236 targ = (*it);
237 QStringList &deplist = project->variables()[(*it) + ".depends"];
238 for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) {
239 QString dep = var((*dep_it) + ".target");
240 if(dep.isEmpty())
241 dep = (*dep_it);
242 deps += " " + dep;
243 }
244 t << "\n\n" << targ << ":" << deps << "\n\t"
245 << cmd;
246 }
247
248 t << endl << endl;
249}
250
251
252void
253NmakeMakefileGenerator::init()
254{
255 if(init_flag)
256 return;
257 init_flag = TRUE;
258
259 /* this should probably not be here, but I'm using it to wrap the .t files */
260 if(project->first("TEMPLATE") == "app")
261 project->variables()["QMAKE_APP_FLAG"].append("1");
262 else if(project->first("TEMPLATE") == "lib")
263 project->variables()["QMAKE_LIB_FLAG"].append("1");
264 else if(project->first("TEMPLATE") == "subdirs") {
265 MakefileGenerator::init();
266 if(project->variables()["MAKEFILE"].isEmpty())
267 project->variables()["MAKEFILE"].append("Makefile");
268 if(project->variables()["QMAKE"].isEmpty())
269 project->variables()["QMAKE"].append("qmake");
270 return;
271 }
272
273 bool is_qt = (project->first("TARGET") == "qt"QTDLL_POSTFIX || project->first("TARGET") == "qt-mt"QTDLL_POSTFIX);
274 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
275
276 QString targetfilename = project->variables()["TARGET"].first();
277 QStringList &configs = project->variables()["CONFIG"];
278 if (project->isActiveConfig("qt") && project->isActiveConfig("shared"))
279 project->variables()["DEFINES"].append("QT_DLL");
280 if (project->isActiveConfig("qt_dll"))
281 if(configs.findIndex("qt") == -1) configs.append("qt");
282 if ( project->isActiveConfig("qt") ) {
283 if ( project->isActiveConfig( "plugin" ) ) {
284 project->variables()["CONFIG"].append("dll");
285 if(project->isActiveConfig("qt"))
286 project->variables()["DEFINES"].append("QT_PLUGIN");
287 }
288 if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) &&
289 ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 ||
290 project->variables()["DEFINES"].findIndex("QT_DLL") != -1) ||
291 (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) {
292 project->variables()["QMAKE_QT_DLL"].append("1");
293 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
294 project->variables()["CONFIG"].append("dll");
295 }
296 if ( project->isActiveConfig("thread") )
297 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT");
298 if ( project->isActiveConfig("accessibility" ) )
299 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
300 if ( project->isActiveConfig("tablet") )
301 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
302 }
303 if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
304 project->variables()["CONFIG"].remove("staticlib");
305 project->variables()["QMAKE_APP_OR_DLL"].append("1");
306 } else {
307 project->variables()["CONFIG"].append("staticlib");
308 }
309 if ( project->isActiveConfig("warn_off") ) {
310 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"];
311 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"];
312 } else if ( project->isActiveConfig("warn_on") ) {
313 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"];
314 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"];
315 }
316 if ( project->isActiveConfig("debug") ) {
317 if ( project->isActiveConfig("thread") ) {
318 // use the DLL RT even here
319 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
320 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"];
321 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"];
322 } else {
323 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"];
324 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"];
325 }
326 }
327 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"];
328 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"];
329 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"];
330 } else {
331 if ( project->isActiveConfig("thread") ) {
332 if ( project->variables()["DEFINES"].contains("QT_DLL") ) {
333 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"];
334 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"];
335 } else {
336 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"];
337 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"];
338 }
339 }
340 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"];
341 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"];
342 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"];
343 }
344 if ( project->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL")
345 && !is_qt && project->first("TARGET") != "qtmain") {
346 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\"");
347 }
348
349 if ( !project->variables()["QMAKE_INCDIR"].isEmpty())
350 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"];
351 if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") )
352 project->variables()["CONFIG"].append("windows");
353 if ( project->isActiveConfig("qt") ) {
354 project->variables()["CONFIG"].append("moc");
355 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
356 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
357 if ( !project->isActiveConfig("debug") )
358 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG");
359 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
360 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) {
361 project->variables()["DEFINES"].append("QT_MAKEDLL");
362 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"];
363 }
364 } else {
365 if(project->isActiveConfig("thread"))
366 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
367 else
368 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
369 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
370 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
371 if ( hver == -1 )
372 hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt-mt");
373 if(hver != -1) {
374 QString ver;
375 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
376 QStringList &libs = project->variables()["QMAKE_LIBS"];
377 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
378 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
379 }
380 }
381 if ( project->isActiveConfig( "activeqt" ) ) {
382 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
383 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
384 if ( project->isActiveConfig( "dll" ) )
385 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
386 }
387 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
388 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
389 }
390 }
391 }
392 if ( project->isActiveConfig("opengl") ) {
393 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
394 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
395 }
396 if ( project->isActiveConfig("dll") ) {
397 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"];
398 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"];
399 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"];
400 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"];
401 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) {
402 project->variables()["TARGET_EXT"].append(
403 QStringList::split('.',project->first("VERSION")).join("") + ".dll");
404 } else {
405 project->variables()["TARGET_EXT"].append(".dll");
406 }
407 } else {
408 project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"];
409 project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"];
410 project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"];
411 project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"];
412 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
413 project->variables()["TARGET_EXT"].append(".exe");
414 } else {
415 project->variables()["TARGET_EXT"].append(".lib");
416 }
417 }
418 if ( project->isActiveConfig("windows") ) {
419 if ( project->isActiveConfig("console") ) {
420 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
421 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
422 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
423 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
424 } else {
425 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"];
426 }
427 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
428 } else {
429 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"];
430 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"];
431 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"];
432 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"];
433 }
434
435 if ( project->isActiveConfig("moc") )
436 setMocAware(TRUE);
437 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
438 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ',
439 "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
440 QStringList &l = project->variables()["QMAKE_FILETAGS"];
441 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
442 QStringList &gdmf = project->variables()[(*it)];
443 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
444 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
445 }
446
447 if ( !project->variables()["DEF_FILE"].isEmpty() )
448 project->variables()["QMAKE_LFLAGS"].append(QString("/DEF:") + project->first("DEF_FILE"));
449 if(!project->isActiveConfig("incremental"))
450 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
451
452 if ( !project->variables()["VERSION"].isEmpty() ) {
453 QString version = project->variables()["VERSION"][0];
454 int firstDot = version.find( "." );
455 QString major = version.left( firstDot );
456 QString minor = version.right( version.length() - firstDot - 1 );
457 minor.replace( ".", "" );
458 project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor );
459 }
460 if ( !project->variables()["RC_FILE"].isEmpty()) {
461 if ( !project->variables()["RES_FILE"].isEmpty()) {
462 fprintf(stderr, "Both .rc and .res file specified.\n");
463 fprintf(stderr, "Please specify one of them, not both.");
464 exit(666);
465 }
466 project->variables()["RES_FILE"] = project->variables()["RC_FILE"];
467 project->variables()["RES_FILE"].first().replace(".rc",".res");
468 project->variables()["TARGETDEPS"] += project->variables()["RES_FILE"];
469 }
470 if ( !project->variables()["RES_FILE"].isEmpty())
471 project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"];
472
473 MakefileGenerator::init();
474 if ( !project->variables()["VERSION"].isEmpty()) {
475 QStringList l = QStringList::split('.', project->first("VERSION"));
476 project->variables()["VER_MAJ"].append(l[0]);
477 project->variables()["VER_MIN"].append(l[1]);
478 }
479 if(project->isActiveConfig("dll")) {
480 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".lib");
481 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".exp");
482 }
483 if(project->isActiveConfig("debug")) {
484 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".pdb");
485 project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + ".ilk");
486 project->variables()["QMAKE_CLEAN"].append("vc*.pdb");
487 }
488}
diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h
new file mode 100644
index 0000000..d3e170f
--- a/dev/null
+++ b/qmake/generators/win32/msvc_nmake.h
@@ -0,0 +1,59 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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#ifndef __NMAKEMAKE_H__
38#define __NMAKEMAKE_H__
39
40#include "winmakefile.h"
41
42class NmakeMakefileGenerator : public Win32MakefileGenerator
43{
44 bool init_flag;
45 void writeNmakeParts(QTextStream &);
46
47 bool writeMakefile(QTextStream &);
48 void init();
49
50public:
51 NmakeMakefileGenerator(QMakeProject *p);
52 ~NmakeMakefileGenerator();
53
54};
55
56inline NmakeMakefileGenerator::~NmakeMakefileGenerator()
57{ }
58
59#endif /* __NMAKEMAKE_H__ */
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
new file mode 100644
index 0000000..c2b9e30
--- a/dev/null
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -0,0 +1,1955 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the network module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#include "msvc_objectmodel.h"
37#include "msvc_vcproj.h"
38#include <qtextstream.h>
39#include <qstringlist.h>
40#include <quuid.h>
41
42#if defined(Q_OS_WIN32)
43#include <objbase.h>
44#ifndef GUID_DEFINED
45#define GUID_DEFINED
46typedef struct _GUID
47{
48 ulong Data1;
49 ushort Data2;
50 ushort Data3;
51 uchar Data4[8];
52} GUID;
53#endif
54#endif
55
56// XML Tags ---------------------------------------------------------
57 const char* _xmlInit = "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>";
58 const char* _begConfiguration = "\n\t\t<Configuration";
59 const char* _begConfigurations = "\n\t<Configurations>";
60 const char* _begFile = "\n\t\t\t<File";
61 const char* _begFileConfiguration = "\n\t\t\t\t<FileConfiguration";
62 const char* _begFiles = "\n\t<Files>";
63 const char* _begFilter = "\n\t\t<Filter";
64 const char* _begGlobals = "\n\t<Globals>";
65 const char* _begPlatform = "\n\t\t<Platform";
66 const char* _begPlatforms = "\n\t<Platforms>";
67 const char* _begTool3 = "\n\t\t\t<Tool";
68 const char* _begTool5 = "\n\t\t\t\t\t<Tool";
69 const char* _begVisualStudioProject = "\n<VisualStudioProject";
70 const char* _endConfiguration = "\n\t\t</Configuration>";
71 const char* _endConfigurations = "\n\t</Configurations>";
72 const char* _endFile = "\n\t\t\t</File>";
73 const char* _endFileConfiguration = "\n\t\t\t\t</FileConfiguration>";
74 const char* _endFiles = "\n\t</Files>";
75 const char* _endFilter = "\n\t\t</Filter>";
76 const char* _endGlobals = "\n\t</Globals>";
77 const char* _endPlatforms = "\n\t</Platforms>";
78 const char* _endVisualStudioProject = "\n</VisualStudioProject>";
79
80// XML Properties ---------------------------------------------------
81 const char* _AddModuleNamesToAssembly = "\n\t\t\t\tAddModuleNamesToAssembly=\"";
82 const char* _AdditionalDependencies4 = "\n\t\t\t\tAdditionalDependencies=\"";
83 const char* _AdditionalDependencies6 = "\n\t\t\t\t\t\tAdditionalDependencies=\"";
84 const char* _AdditionalIncludeDirectories = "\n\t\t\t\tAdditionalIncludeDirectories=\"";
85 const char* _AdditionalLibraryDirectories = "\n\t\t\t\tAdditionalLibraryDirectories=\"";
86 const char* _AdditionalOptions = "\n\t\t\t\tAdditionalOptions=\"";
87 const char* _AdditionalUsingDirectories = "\n\t\t\t\tAdditionalUsingDirectories=\"";
88 const char* _AssemblerListingLocation = "\n\t\t\t\tAssemblerListingLocation=\"";
89 const char* _AssemblerOutput = "\n\t\t\t\tAssemblerOutput=\"";
90 const char* _ATLMinimizesCRunTimeLibraryUsage= "\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\"";
91 const char* _BaseAddress = "\n\t\t\t\tBaseAddress=\"";
92 const char* _BasicRuntimeChecks = "\n\t\t\t\tBasicRuntimeChecks=\"";
93 const char* _BrowseInformation = "\n\t\t\t\tBrowseInformation=\"";
94 const char* _BrowseInformationFile = "\n\t\t\t\tBrowseInformationFile=\"";
95 const char* _BufferSecurityCheck = "\n\t\t\t\tBufferSecurityCheck=\"";
96 const char* _BuildBrowserInformation = "\n\t\t\tBuildBrowserInformation=\"";
97 const char* _CPreprocessOptions = "\n\t\t\t\tCPreprocessOptions=\"";
98 const char* _CallingConvention = "\n\t\t\t\tCallingConvention=\"";
99 const char* _CharacterSet = "\n\t\t\tCharacterSet=\"";
100 const char* _CommandLine4 = "\n\t\t\t\tCommandLine=\"";
101 const char* _CommandLine6 = "\n\t\t\t\t\t\tCommandLine=\"";
102 const char* _CompileAs = "\n\t\t\t\tCompileAs=\"";
103 const char* _CompileAsManaged = "\n\t\t\t\tCompileAsManaged=\"";
104 const char* _CompileOnly = "\n\t\t\t\tCompileOnly=\"";
105 const char* _ConfigurationType = "\n\t\t\tConfigurationType=\"";
106 const char* _Culture = "\n\t\t\t\tCulture=\"";
107 const char* _DLLDataFileName = "\n\t\t\t\tDLLDataFileName=\"";
108 const char* _DebugInformationFormat = "\n\t\t\t\tDebugInformationFormat=\"";
109 const char* _DefaultCharIsUnsigned = "\n\t\t\t\tDefaultCharIsUnsigned=\"";
110 const char* _DefaultCharType = "\n\t\t\t\tDefaultCharType=\"";
111 const char* _DelayLoadDLLs = "\n\t\t\t\tDelayLoadDLLs=\"";
112 const char* _DeleteExtensionsOnClean = "\n\t\t\tDeleteExtensionsOnClean=\"";
113 const char* _Description4 = "\n\t\t\t\tDescription=\"";
114 const char* _Description6 = "\n\t\t\t\t\t\tDescription=\"";
115 const char* _Detect64BitPortabilityProblems = "\n\t\t\t\tDetect64BitPortabilityProblems=\"";
116 const char* _DisableLanguageExtensions = "\n\t\t\t\tDisableLanguageExtensions=\"";
117 const char* _DisableSpecificWarnings = "\n\t\t\t\tDisableSpecificWarnings=\"";
118 const char* _EnableCOMDATFolding = "\n\t\t\t\tEnableCOMDATFolding=\"";
119 const char* _EnableErrorChecks = "\n\t\t\t\tEnableErrorChecks=\"";
120 const char* _EnableFiberSafeOptimizations = "\n\t\t\t\tEnableFiberSafeOptimizations=\"";
121 const char* _EnableFunctionLevelLinking = "\n\t\t\t\tEnableFunctionLevelLinking=\"";
122 const char* _EnableIntrinsicFunctions = "\n\t\t\t\tEnableIntrinsicFunctions=\"";
123 const char* _EntryPointSymbol = "\n\t\t\t\tEntryPointSymbol=\"";
124 const char* _ErrorCheckAllocations = "\n\t\t\t\tErrorCheckAllocations=\"";
125 const char* _ErrorCheckBounds = "\n\t\t\t\tErrorCheckBounds=\"";
126 const char* _ErrorCheckEnumRange = "\n\t\t\t\tErrorCheckEnumRange=\"";
127 const char* _ErrorCheckRefPointers = "\n\t\t\t\tErrorCheckRefPointers=\"";
128 const char* _ErrorCheckStubData = "\n\t\t\t\tErrorCheckStubData=\"";
129 const char* _ExceptionHandling = "\n\t\t\t\tExceptionHandling=\"";
130 const char* _ExcludedFromBuild = "\n\t\t\t\tExcludedFromBuild=\"";
131 const char* _ExpandAttributedSource = "\n\t\t\t\tExpandAttributedSource=\"";
132 const char* _ExportNamedFunctions = "\n\t\t\t\tExportNamedFunctions=\"";
133 const char* _FavorSizeOrSpeed = "\n\t\t\t\tFavorSizeOrSpeed=\"";
134 const char* _Filter = "\n\t\t\tFilter=\"";
135 const char* _ForceConformanceInForLoopScope = "\n\t\t\t\tForceConformanceInForLoopScope=\"";
136 const char* _ForceSymbolReferences = "\n\t\t\t\tForceSymbolReferences=\"";
137 const char* _ForcedIncludeFiles = "\n\t\t\t\tForcedIncludeFiles=\"";
138 const char* _ForcedUsingFiles = "\n\t\t\t\tForcedUsingFiles=\"";
139 const char* _FullIncludePath = "\n\t\t\t\tFullIncludePath=\"";
140 const char* _FunctionOrder = "\n\t\t\t\tFunctionOrder=\"";
141 const char* _GenerateDebugInformation = "\n\t\t\t\tGenerateDebugInformation=\"";
142 const char* _GenerateMapFile = "\n\t\t\t\tGenerateMapFile=\"";
143 const char* _GeneratePreprocessedFile = "\n\t\t\t\tGeneratePreprocessedFile=\"";
144 const char* _GenerateStublessProxies = "\n\t\t\t\tGenerateStublessProxies=\"";
145 const char* _GenerateTypeLibrary = "\n\t\t\t\tGenerateTypeLibrary=\"";
146 const char* _GlobalOptimizations = "\n\t\t\t\tGlobalOptimizations=\"";
147 const char* _HeaderFileName = "\n\t\t\t\tHeaderFileName=\"";
148 const char* _HeapCommitSize = "\n\t\t\t\tHeapCommitSize=\"";
149 const char* _HeapReserveSize = "\n\t\t\t\tHeapReserveSize=\"";
150 const char* _IgnoreAllDefaultLibraries = "\n\t\t\t\tIgnoreAllDefaultLibraries=\"";
151 const char* _IgnoreDefaultLibraryNames = "\n\t\t\t\tIgnoreDefaultLibraryNames=\"";
152 const char* _IgnoreEmbeddedIDL = "\n\t\t\t\tIgnoreEmbeddedIDL=\"";
153 const char* _IgnoreImportLibrary = "\n\t\t\t\tIgnoreImportLibrary=\"";
154 const char* _IgnoreStandardIncludePath = "\n\t\t\t\tIgnoreStandardIncludePath=\"";
155 const char* _ImportLibrary = "\n\t\t\t\tImportLibrary=\"";
156 const char* _ImproveFloatingPointConsistency = "\n\t\t\t\tImproveFloatingPointConsistency=\"";
157 const char* _InlineFunctionExpansion = "\n\t\t\t\tInlineFunctionExpansion=\"";
158 const char* _InterfaceIdentifierFileName = "\n\t\t\t\tInterfaceIdentifierFileName=\"";
159 const char* _IntermediateDirectory = "\n\t\t\tIntermediateDirectory=\"";
160 const char* _KeepComments = "\n\t\t\t\tKeepComments=\"";
161 const char* _LargeAddressAware = "\n\t\t\t\tLargeAddressAware=\"";
162 const char* _LinkDLL = "\n\t\t\t\tLinkDLL=\"";
163 const char* _LinkIncremental = "\n\t\t\t\tLinkIncremental=\"";
164 const char* _LinkTimeCodeGeneration = "\n\t\t\t\tLinkTimeCodeGeneration=\"";
165 const char* _LinkToManagedResourceFile = "\n\t\t\t\tLinkToManagedResourceFile=\"";
166 const char* _MapExports = "\n\t\t\t\tMapExports=\"";
167 const char* _MapFileName = "\n\t\t\t\tMapFileName=\"";
168 const char* _MapLines = "\n\t\t\t\tMapLines =\"";
169 const char* _MergeSections = "\n\t\t\t\tMergeSections=\"";
170 const char* _MergedIDLBaseFileName = "\n\t\t\t\tMergedIDLBaseFileName=\"";
171 const char* _MidlCommandFile = "\n\t\t\t\tMidlCommandFile=\"";
172 const char* _MinimalRebuild = "\n\t\t\t\tMinimalRebuild=\"";
173 const char* _MkTypLibCompatible = "\n\t\t\t\tMkTypLibCompatible=\"";
174 const char* _ModuleDefinitionFile = "\n\t\t\t\tModuleDefinitionFile=\"";
175 const char* _Name1 = "\n\tName=\"";
176 const char* _Name2 = "\n\t\tName=\"";
177 const char* _Name3 = "\n\t\t\tName=\"";
178 const char* _Name4 = "\n\t\t\t\tName=\"";
179 const char* _Name5 = "\n\t\t\t\t\tName=\"";
180 const char* _ObjectFile = "\n\t\t\t\tObjectFile=\"";
181 const char* _OmitFramePointers = "\n\t\t\t\tOmitFramePointers=\"";
182 const char* _Optimization = "\n\t\t\t\tOptimization =\"";
183 const char* _OptimizeForProcessor = "\n\t\t\t\tOptimizeForProcessor=\"";
184 const char* _OptimizeForWindows98 = "\n\t\t\t\tOptimizeForWindows98=\"";
185 const char* _OptimizeForWindowsApplication = "\n\t\t\t\tOptimizeForWindowsApplication=\"";
186 const char* _OptimizeReferences = "\n\t\t\t\tOptimizeReferences=\"";
187 const char* _OutputDirectory3 = "\n\t\t\tOutputDirectory=\"";
188 const char* _OutputDirectory4 = "\n\t\t\t\tOutputDirectory=\"";
189 const char* _OutputFile = "\n\t\t\t\tOutputFile=\"";
190 const char* _Outputs4 = "\n\t\t\t\tOutputs=\"";
191 const char* _Outputs6 = "\n\t\t\t\t\t\tOutputs=\"";
192 const char* _ParseFiles = "\n\t\t\tParseFiles=\"";
193 const char* _PrecompiledHeaderFile = "\n\t\t\t\tPrecompiledHeaderFile=\"";
194 const char* _PrecompiledHeaderThrough = "\n\t\t\t\tPrecompiledHeaderThrough=\"";
195 const char* _PreprocessorDefinitions = "\n\t\t\t\tPreprocessorDefinitions=\"";
196 const char* _PrimaryOutput = "\n\t\t\tPrimaryOutput=\"";
197 const char* _ProjectGUID = "\n\tProjectGUID=\"";
198 const char* _ProjectType = "\n\tProjectType=\"Visual C++\"";
199 const char* _ProgramDatabase = "\n\t\t\tProgramDatabase=\"";
200 const char* _ProgramDataBaseFileName = "\n\t\t\t\tProgramDataBaseFileName=\"";
201 const char* _ProgramDatabaseFile = "\n\t\t\t\tProgramDatabaseFile=\"";
202 const char* _ProxyFileName = "\n\t\t\t\tProxyFileName=\"";
203 const char* _RedirectOutputAndErrors = "\n\t\t\t\tRedirectOutputAndErrors=\"";
204 const char* _RegisterOutput = "\n\t\t\t\tRegisterOutput=\"";
205 const char* _RelativePath = "\n\t\t\t\tRelativePath=\"";
206 const char* _ResourceOnlyDLL = "\n\t\t\t\tResourceOnlyDLL=\"";
207 const char* _ResourceOutputFileName = "\n\t\t\t\tResourceOutputFileName=\"";
208 const char* _RuntimeLibrary = "\n\t\t\t\tRuntimeLibrary=\"";
209 const char* _RuntimeTypeInfo = "\n\t\t\t\tRuntimeTypeInfo=\"";
210 const char* _SccProjectName = "\n\tSccProjectName=\"";
211 const char* _SccLocalPath = "\n\tSccLocalPath=\"";
212 const char* _SetChecksum = "\n\t\t\t\tSetChecksum=\"";
213 const char* _ShowIncludes = "\n\t\t\t\tShowIncludes=\"";
214 const char* _ShowProgress = "\n\t\t\t\tShowProgress=\"";
215 const char* _SmallerTypeCheck = "\n\t\t\t\tSmallerTypeCheck=\"";
216 const char* _StackCommitSize = "\n\t\t\t\tStackCommitSize=\"";
217 const char* _StackReserveSize = "\n\t\t\t\tStackReserveSize=\"";
218 const char* _StringPooling = "\n\t\t\t\tStringPooling=\"";
219 const char* _StripPrivateSymbols = "\n\t\t\t\tStripPrivateSymbols=\"";
220 const char* _StructMemberAlignment = "\n\t\t\t\tStructMemberAlignment=\"";
221 const char* _SubSystem = "\n\t\t\t\tSubSystem=\"";
222 const char* _SupportUnloadOfDelayLoadedDLL = "\n\t\t\t\tSupportUnloadOfDelayLoadedDLL=\"";
223 const char* _SuppressStartupBanner = "\n\t\t\t\tSuppressStartupBanner=\"";
224 const char* _SwapRunFromCD = "\n\t\t\t\tSwapRunFromCD=\"";
225 const char* _SwapRunFromNet = "\n\t\t\t\tSwapRunFromNet=\"";
226 const char* _TargetEnvironment = "\n\t\t\t\tTargetEnvironment=\"";
227 const char* _TargetMachine = "\n\t\t\t\tTargetMachine=\"";
228 const char* _TerminalServerAware = "\n\t\t\t\tTerminalServerAware=\"";
229 const char* _ToolName = "\n\t\t\t\tName=\"";
230 const char* _ToolPath = "\n\t\t\t\tPath=\"";
231 const char* _TreatWChar_tAsBuiltInType = "\n\t\t\t\tTreatWChar_tAsBuiltInType=\"";
232 const char* _TurnOffAssemblyGeneration = "\n\t\t\t\tTurnOffAssemblyGeneration=\"";
233 const char* _TypeLibraryFile = "\n\t\t\t\tTypeLibraryFile=\"";
234 const char* _TypeLibraryName = "\n\t\t\t\tTypeLibraryName=\"";
235 const char* _TypeLibraryResourceID = "\n\t\t\t\tTypeLibraryResourceID=\"";
236const char* _UndefineAllPreprocessorDefinitions = "\n\t\t\t\tUndefineAllPreprocessorDefinitions=\"";
237 const char* _UndefinePreprocessorDefinitions = "\n\t\t\t\tUndefinePreprocessorDefinitions=\"";
238 const char* _UseOfATL = "\n\t\t\tUseOfATL=\"";
239 const char* _UseOfMfc = "\n\t\t\tUseOfMfc=\"";
240 const char* _UsePrecompiledHeader = "\n\t\t\t\tUsePrecompiledHeader=\"";
241 const char* _ValidateParameters = "\n\t\t\t\tValidateParameters=\"";
242 const char* _VCCLCompilerToolName = "\n\t\t\t\tName=\"VCCLCompilerTool\"";
243 const char* _VCCustomBuildTool = "\n\t\t\t\t\t\tName=\"VCCustomBuildTool\"";
244 const char* _VCLinkerToolName = "\n\t\t\t\tName=\"VCLinkerTool\"";
245 const char* _VCResourceCompilerToolName = "\n\t\t\t\tName=\"VCResourceCompilerTool\"";
246 const char* _VCMIDLToolName = "\n\t\t\t\tName=\"VCMIDLTool\"";
247 const char* _Version1 = "\n\tVersion=\"";
248 const char* _Version4 = "\n\t\t\t\tVersion=\"";
249 const char* _WarnAsError = "\n\t\t\t\tWarnAsError=\"";
250 const char* _WarnLevel = "\n\t\t\t\tWarnLevel=\"";
251 const char* _WarningLevel = "\n\t\t\t\tWarningLevel=\"";
252 const char* _WholeProgramOptimization = "\n\t\t\t\tWholeProgramOptimization=\"";
253
254// Property name and value as Pairs ---------------------------------
255struct TPair {
256 TPair( const char* n, const triState v ) : name(n), value(v) {};
257 const char* name;
258 const triState value;
259};
260struct EPair {
261 EPair( const char* n, const int v ) : name(n), value(v) {};
262 const char* name;
263 const int value;
264};
265struct LPair {
266 LPair( const char* n, const long v ) : name(n), value(v) {};
267 const char* name;
268 const long value;
269};
270struct SPair {
271 SPair( const char* n, const QString& v ) : name(n), value(v) {};
272 const char* name;
273 const QString& value;
274};
275struct XPair {
276 XPair( const char* n, const QStringList& v, const char* s = "," ) : name(n), value(v), sep(s) {};
277 const char* name;
278 const QStringList& value;
279 const char* sep;
280};
281
282// void streamSPair( QTextStream &strm, const char *n, const QString &s )
283
284
285// Streaming operators for property Pairs ---------------------------
286QTextStream &operator<<( QTextStream &strm, const TPair &prop )
287{
288 switch( prop.value ) {
289 case _False:
290 strm << prop.name << "FALSE\"";
291 break;
292 case _True:
293 strm << prop.name << "TRUE\"";
294 break;
295 case unset:
296 default:
297 break;
298 }
299 return strm;
300}
301
302/* Be sure to check that each enum is not set to
303 default before streaming it out. Defaults seem
304 to not be in the XML file.
305*/
306QTextStream &operator<<( QTextStream &strm, const EPair &prop )
307{
308 strm << prop.name << prop.value << "\"";
309 return strm;
310}
311
312QTextStream &operator<<( QTextStream &strm, const LPair &prop )
313{
314 strm << prop.name << prop.value << "\"";
315 return strm;
316}
317
318QTextStream &operator<<( QTextStream &strm, const SPair &prop )
319{
320 if ( !prop.value.isEmpty() )
321 strm << prop.name << prop.value.latin1() << "\"";
322 return strm;
323}
324
325QTextStream &operator<<( QTextStream &strm, const XPair &prop )
326{
327 if ( !prop.value.isEmpty() )
328 strm << prop.name << prop.value.join(prop.sep).latin1() << "\"";
329 return strm;
330}
331
332// VCCLCompilerTool -------------------------------------------------
333VCCLCompilerTool::VCCLCompilerTool()
334 :AssemblerOutput( asmListingNone ),
335 BasicRuntimeChecks( runtimeBasicCheckNone ),
336 BrowseInformation( brInfoNone ),
337 BufferSecurityCheck( unset ),
338 CallingConvention( callConventionDefault ),
339 CompileAs( compileAsDefault ),
340 CompileAsManaged( managedDefault ),
341 CompileOnly( unset ),
342 DebugInformationFormat( debugDisabled ),
343 DefaultCharIsUnsigned( unset ),
344 Detect64BitPortabilityProblems( unset ),
345 DisableLanguageExtensions( unset ),
346 EnableFiberSafeOptimizations( unset ),
347 EnableFunctionLevelLinking( unset ),
348 EnableIntrinsicFunctions( unset ),
349 ExceptionHandling( unset ),
350 ExpandAttributedSource( unset ),
351 FavorSizeOrSpeed( favorNone ),
352 ForceConformanceInForLoopScope( unset ),
353 GeneratePreprocessedFile( preprocessNo ),
354 GlobalOptimizations( unset ),
355 IgnoreStandardIncludePath( unset ),
356 ImproveFloatingPointConsistency( unset ),
357 InlineFunctionExpansion( expandOnlyInline ),
358 KeepComments( unset ),
359 MinimalRebuild( unset ),
360 OmitFramePointers( unset ),
361 Optimization( optimizeDisabled ),
362 OptimizeForProcessor( procOptimizeBlended ),
363 OptimizeForWindowsApplication( unset ),
364 RuntimeLibrary( rtMultiThreaded ),
365 RuntimeTypeInfo( unset ),
366 ShowIncludes( unset ),
367 SmallerTypeCheck( unset ),
368 StringPooling( unset ),
369 StructMemberAlignment( alignNotSet ),
370 SuppressStartupBanner( unset ),
371 TreatWChar_tAsBuiltInType( unset ),
372 TurnOffAssemblyGeneration( unset ),
373 UndefineAllPreprocessorDefinitions( unset ),
374 UsePrecompiledHeader( pchGenerateAuto ),
375 WarnAsError( unset ),
376 WarningLevel( warningLevel_0 ),
377 WholeProgramOptimization( unset )
378{
379}
380
381QTextStream &operator<<( QTextStream &strm, const VCCLCompilerTool &tool )
382{
383 strm << _begTool3;
384 strm << _VCCLCompilerToolName;
385 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
386 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
387 strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories );
388 strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation );
389 if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput );
390 if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks );
391 if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation );
392 strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile );
393 strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck );
394 if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention );
395 if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs );
396 if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged );
397 strm << TPair( _CompileOnly, tool.CompileOnly );
398 strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat );
399 strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned );
400 strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems );
401 strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions );
402 strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings );
403 strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations );
404 strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking );
405 strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions );
406 strm << TPair( _ExceptionHandling, tool.ExceptionHandling );
407 strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource );
408 if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed );
409 strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope );
410 strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles );
411 strm << XPair( _ForcedUsingFiles, tool.ForcedUsingFiles );
412 strm << EPair( _GeneratePreprocessedFile, tool.GeneratePreprocessedFile );
413 strm << TPair( _GlobalOptimizations, tool.GlobalOptimizations );
414 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
415 strm << TPair( _ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency );
416 strm << EPair( _InlineFunctionExpansion, tool.InlineFunctionExpansion );
417 strm << TPair( _KeepComments, tool.KeepComments );
418 strm << TPair( _MinimalRebuild, tool.MinimalRebuild );
419 strm << SPair( _ObjectFile, tool.ObjectFile );
420 strm << TPair( _OmitFramePointers, tool.OmitFramePointers );
421 strm << EPair( _Optimization, tool.Optimization );
422 if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor );
423 strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication );
424 strm << SPair( _OutputFile, tool.OutputFile );
425 strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile );
426 strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough );
427 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
428 strm << SPair( _ProgramDataBaseFileName, tool.ProgramDataBaseFileName );
429 strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary );
430 strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo );
431 strm << TPair( _ShowIncludes, tool.ShowIncludes );
432 strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck );
433 strm << TPair( _StringPooling, tool.StringPooling );
434 if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
435 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
436 strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType );
437 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
438 strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions );
439 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
440 if ( !tool.PrecompiledHeaderFile.isEmpty() ||
441 !tool.PrecompiledHeaderThrough.isEmpty() )
442 strm << EPair( _UsePrecompiledHeader, tool.UsePrecompiledHeader );
443 strm << TPair( _WarnAsError, tool.WarnAsError );
444 strm << EPair( _WarningLevel, tool.WarningLevel );
445 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
446 strm << "/>";
447return strm;
448}
449
450bool VCCLCompilerTool::parseOption( const char* option )
451{
452 // skip index 0 ('/' or '-')
453 char first = option[1];
454 char second = option[2];
455 char third = option[3];
456 char fourth = option[4];
457
458 switch ( first ) {
459 case '?':
460 case 'h':
461 qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" );
462 return FALSE;
463 case '@':
464 qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" );
465 return FALSE;
466 case 'l':
467 qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" );
468 return FALSE;
469
470 case 'A':
471 if ( second != 'I' )
472 return FALSE;
473 AdditionalUsingDirectories += option+2;
474 break;
475 case 'C':
476 KeepComments = _True;
477 break;
478 case 'D':
479 PreprocessorDefinitions += option+1;
480 break;
481 case 'E':
482 if ( second == 'H' ) {
483 if ( third == 'a' || third == 'c' || third == 's' ) {
484 // ExceptionHandling must be false, or it will override
485 // with an /EHsc option
486 ExceptionHandling = _False;
487 AdditionalOptions += option;
488 break;
489 }
490 return FALSE;
491 }
492 GeneratePreprocessedFile = preprocessYes;
493 break;
494 case 'F':
495 if ( second <= '9' && second >= '0' ) {
496 AdditionalOptions += option;
497 break;
498 } else {
499 switch ( second ) {
500 case 'A':
501 if ( third == 'c' ) {
502 AssemblerOutput = asmListingAsmMachine;
503 if ( fourth == 's' )
504 AssemblerOutput = asmListingAsmMachineSrc;
505 } else if ( third == 's' ) {
506 AssemblerOutput = asmListingAsmSrc;
507 } else {
508 AssemblerOutput = asmListingAssemblyOnly;
509 }
510 break;
511 case 'a':
512 AssemblerListingLocation = option+3;
513 break;
514 case 'I':
515 ForcedIncludeFiles += option+3;
516 break;
517 case 'R':
518 BrowseInformation = brAllInfo;
519 BrowseInformationFile = option+3;
520 break;
521 case 'r':
522 BrowseInformation = brNoLocalSymbols;
523 BrowseInformationFile = option+3;
524 break;
525 case 'U':
526 ForcedUsingFiles += option+3;
527 break;
528 case 'd':
529 ProgramDataBaseFileName = option+3;
530 break;
531 case 'e':
532 OutputFile = option+3;
533 break;
534 case 'm':
535 AdditionalOptions += option;
536 break;
537 case 'o':
538 ObjectFile = option+3;
539 break;
540 case 'p':
541 PrecompiledHeaderFile = option+3;
542 break;
543 case 'x':
544 ExpandAttributedSource = _True;
545 break;
546 default:
547 return FALSE;
548 }
549 }
550 break;
551 case 'G':
552 switch ( second ) {
553 case '3':
554 case '4':
555 qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" );
556 return FALSE;
557 case '5':
558 OptimizeForProcessor = procOptimizePentium;
559 break;
560 case '6':
561 case 'B':
562 OptimizeForProcessor = procOptimizePentiumProAndAbove;
563 break;
564 case 'A':
565 OptimizeForWindowsApplication = _True;
566 break;
567 case 'F':
568 StringPooling = _True;
569 break;
570 case 'H':
571 AdditionalOptions += option;
572 break;
573 case 'L':
574 WholeProgramOptimization = _True;
575 if ( third == '-' )
576 WholeProgramOptimization = _False;
577 break;
578 case 'R':
579 RuntimeTypeInfo = _True;
580 if ( third == '-' )
581 RuntimeTypeInfo = _False;
582 break;
583 case 'S':
584 BufferSecurityCheck = _True;
585 break;
586 case 'T':
587 EnableFiberSafeOptimizations = _True;
588 break;
589 case 'X':
590 case 'Z':
591 case 'e':
592 case 'h':
593 AdditionalOptions += option;
594 break;
595 case 'd':
596 CallingConvention = callConventionCDecl;
597 break;
598 case 'f':
599 StringPooling = _True;
600 AdditionalOptions += option;
601 break;
602 case 'm':
603 MinimalRebuild = _True;
604 if ( third == '-' )
605 MinimalRebuild = _False;
606 break;
607 case 'r':
608 CallingConvention = callConventionFastCall;
609 break;
610 case 's':
611 // Warning: following [num] is not used,
612 // were should we put it?
613 BufferSecurityCheck = _True;
614 break;
615 case 'y':
616 EnableFunctionLevelLinking = _True;
617 break;
618 case 'z':
619 CallingConvention = callConventionStdCall;
620 break;
621 default:
622 return FALSE;
623 }
624 break;
625 case 'H':
626 AdditionalOptions += option;
627 break;
628 case 'I':
629 AdditionalIncludeDirectories += option+2;
630 break;
631 case 'L':
632 if ( second == 'D' ) {
633 AdditionalOptions += option;
634 break;
635 }
636 return FALSE;
637 case 'M':
638 if ( second == 'D' ) {
639 RuntimeLibrary = rtMultiThreadedDLL;
640 if ( third == 'd' )
641 RuntimeLibrary = rtMultiThreadedDebugDLL;
642 break;
643 } else if ( second == 'L' ) {
644 RuntimeLibrary = rtSingleThreaded;
645 if ( third == 'd' )
646 RuntimeLibrary = rtSingleThreadedDebug;
647 break;
648 } else if ( second == 'T' ) {
649 RuntimeLibrary = rtMultiThreaded;
650 if ( third == 'd' )
651 RuntimeLibrary = rtMultiThreadedDebug;
652 break;
653 }
654 return FALSE;
655 case 'O':
656 switch ( second ) {
657 case '1':
658 Optimization = optimizeMinSpace;
659 break;
660 case '2':
661 Optimization = optimizeMaxSpeed;
662 break;
663 case 'a':
664 AdditionalOptions += option;
665 break;
666 case 'b':
667 if ( third == '0' )
668 InlineFunctionExpansion = expandDisable;
669 else if ( third == '1' )
670 InlineFunctionExpansion = expandOnlyInline;
671 else if ( third == '2' )
672 InlineFunctionExpansion = expandAnySuitable;
673 else
674 return FALSE;
675 break;
676 case 'd':
677 Optimization = optimizeDisabled;
678 break;
679 case 'g':
680 GlobalOptimizations = _True;
681 break;
682 case 'i':
683 EnableIntrinsicFunctions = _True;
684 break;
685 case 'p':
686 ImproveFloatingPointConsistency = _True;
687 if ( third == '-' )
688 ImproveFloatingPointConsistency = _False;
689 break;
690 case 's':
691 FavorSizeOrSpeed = favorSize;
692 break;
693 case 't':
694 FavorSizeOrSpeed = favorSpeed;
695 break;
696 case 'w':
697 AdditionalOptions += option;
698 break;
699 case 'x':
700 Optimization = optimizeFull;
701 break;
702 case 'y':
703 OmitFramePointers = _True;
704 if ( third == '-' )
705 OmitFramePointers = _False;
706 break;
707 default:
708 return FALSE;
709 }
710 break;
711 case 'P':
712 GeneratePreprocessedFile = preprocessYes;
713 break;
714 case 'Q':
715 if ( second == 'I' ) {
716 AdditionalOptions += option;
717 break;
718 }
719 return FALSE;
720 case 'R':
721 if ( second == 'T' && third == 'C' ) {
722 if ( fourth == '1' )
723 BasicRuntimeChecks = runtimeBasicCheckAll;
724 else if ( fourth == 'c' )
725 SmallerTypeCheck = _True;
726 else if ( fourth == 's' )
727 BasicRuntimeChecks = runtimeCheckStackFrame;
728 else if ( fourth == 'u' )
729 BasicRuntimeChecks = runtimeCheckUninitVariables;
730 else
731 return FALSE;
732 }
733 break;
734 case 'T':
735 if ( second == 'C' ) {
736 CompileAs = compileAsC;
737 } else if ( second == 'P' ) {
738 CompileAs = compileAsCPlusPlus;
739 } else {
740 qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" );
741 return FALSE;
742 }
743 break;
744 case 'U':
745 UndefinePreprocessorDefinitions += option+2;
746 break;
747 case 'V':
748 AdditionalOptions += option;
749 break;
750 case 'W':
751 switch ( second ) {
752 case 'a':
753 case '4':
754 WarningLevel = warningLevel_4;
755 break;
756 case '3':
757 WarningLevel = warningLevel_3;
758 break;
759 case '2':
760 WarningLevel = warningLevel_2;
761 break;
762 case '1':
763 WarningLevel = warningLevel_1;
764 break;
765 case '0':
766 WarningLevel = warningLevel_0;
767 break;
768 case 'L':
769 AdditionalOptions += option;
770 break;
771 case 'X':
772 WarnAsError = _True;
773 break;
774 case 'p':
775 if ( third == '6' && fourth == '4' ) {
776 Detect64BitPortabilityProblems = _True;
777 break;
778 }
779 // Fallthrough
780 default:
781 return FALSE;
782 }
783 break;
784 case 'X':
785 IgnoreStandardIncludePath = _True;
786 break;
787 case 'Y':
788 switch ( second ) {
789 case '\0':
790 case '-':
791 AdditionalOptions += option;
792 break;
793 case 'X':
794 UsePrecompiledHeader = pchGenerateAuto;
795 PrecompiledHeaderFile = option+3;
796 break;
797 case 'c':
798 UsePrecompiledHeader = pchCreateUsingSpecific;
799 PrecompiledHeaderFile = option+3;
800 break;
801 case 'd':
802 case 'l':
803 AdditionalOptions =+ option;
804 break;
805 case 'u':
806 UsePrecompiledHeader = pchUseUsingSpecific;
807 PrecompiledHeaderFile = option+3;
808 break;
809 default:
810 return FALSE;
811 }
812 break;
813 case 'Z':
814 switch ( second ) {
815 case '7':
816 DebugInformationFormat = debugOldStyleInfo;
817 break;
818 case 'I':
819 DebugInformationFormat = debugEditAndContinue;
820 break;
821 case 'd':
822 DebugInformationFormat = debugLineInfoOnly;
823 break;
824 case 'i':
825 DebugInformationFormat = debugEnabled;
826 break;
827 case 'l':
828 DebugInformationFormat = debugEditAndContinue;
829 break;
830 case 'a':
831 DisableLanguageExtensions = _True;
832 break;
833 case 'e':
834 DisableLanguageExtensions = _False;
835 break;
836 case 'c':
837 if ( third == ':' ) {
838 if ( fourth == 'f' )
839 ForceConformanceInForLoopScope = _True;
840 else if ( fourth == 'w' )
841 TreatWChar_tAsBuiltInType = _True;
842 else
843 return FALSE;
844 } else {
845 return FALSE;
846 }
847 break;
848 case 'g':
849 case 'm':
850 case 's':
851 AdditionalOptions += option;
852 break;
853 case 'p':
854 switch ( third )
855 {
856 case '\0':
857 case '1':
858 StructMemberAlignment = alignSingleByte;
859 if ( fourth == '6' )
860 StructMemberAlignment = alignSixteenBytes;
861 break;
862 case '2':
863 StructMemberAlignment = alignTwoBytes;
864 break;
865 case '4':
866 StructMemberAlignment = alignFourBytes;
867 break;
868 case '8':
869 StructMemberAlignment = alignEightBytes;
870 break;
871 default:
872 return FALSE;
873 }
874 break;
875 default:
876 return FALSE;
877 }
878 break;
879 case 'c':
880 if ( second == '\0' ) {
881 CompileOnly = _True;
882 } else if ( second == 'l' ) {
883 if ( *(option+5) == 'n' ) {
884 CompileAsManaged = managedAssembly;
885 TurnOffAssemblyGeneration = _True;
886 } else {
887 CompileAsManaged = managedAssembly;
888 }
889 } else {
890 return FALSE;
891 }
892 break;
893 case 'd':
894 if ( second != 'r' )
895 return FALSE;
896 CompileAsManaged = managedAssembly;
897 break;
898 case 'n':
899 if ( second == 'o' && third == 'B' && fourth == 'o' ) {
900 AdditionalOptions += "/noBool";
901 break;
902 }
903 if ( second == 'o' && third == 'l' && fourth == 'o' ) {
904 SuppressStartupBanner = _True;
905 break;
906 }
907 return FALSE;
908 case 's':
909 if ( second == 'h' && third == 'o' && fourth == 'w' ) {
910 ShowIncludes = _True;
911 break;
912 }
913 return FALSE;
914 case 'u':
915 UndefineAllPreprocessorDefinitions = _True;
916 break;
917 case 'v':
918 if ( second == 'd' || second == 'm' ) {
919 AdditionalOptions += option;
920 break;
921 }
922 return FALSE;
923 case 'w':
924 switch ( second ) {
925 case '\0':
926 WarningLevel = warningLevel_0;
927 break;
928 case 'd':
929 DisableSpecificWarnings += option+3;
930 break;
931 default:
932 AdditionalOptions += option;
933 }
934 break;
935 default:
936 return FALSE;
937 }
938 return TRUE;
939}
940
941// VCLinkerTool -----------------------------------------------------
942VCLinkerTool::VCLinkerTool()
943 :EnableCOMDATFolding( optFoldingDefault ),
944 GenerateDebugInformation( unset ),
945 GenerateMapFile( unset ),
946 HeapCommitSize( -1 ),
947 HeapReserveSize( -1 ),
948 IgnoreAllDefaultLibraries( unset ),
949 IgnoreEmbeddedIDL( unset ),
950 IgnoreImportLibrary( unset ),
951 LargeAddressAware( addrAwareDefault ),
952 LinkDLL( unset ),
953 LinkIncremental( linkIncrementalYes ),
954 LinkTimeCodeGeneration( unset ),
955 MapExports( unset ),
956 MapLines( unset ),
957 OptimizeForWindows98( optWin98Default ),
958 OptimizeReferences( optReferencesDefault ),
959 RegisterOutput( unset ),
960 ResourceOnlyDLL( unset ),
961 SetChecksum( unset ),
962 ShowProgress( linkProgressNotSet ),
963 StackCommitSize( -1 ),
964 StackReserveSize( -1 ),
965 SubSystem( subSystemNotSet ),
966 SupportUnloadOfDelayLoadedDLL( unset ),
967 SuppressStartupBanner( unset ),
968 SwapRunFromCD( unset ),
969 SwapRunFromNet( unset ),
970 TargetMachine( machineNotSet ),
971 TerminalServerAware( termSvrAwareDefault ),
972 TurnOffAssemblyGeneration( unset ),
973 TypeLibraryResourceID( 0 )
974{
975}
976
977QTextStream &operator<<( QTextStream &strm, const VCLinkerTool &tool )
978{
979 strm << _begTool3;
980 strm << _VCLinkerToolName;
981 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " );
982 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
983 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
984 strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly );
985 strm << SPair( _BaseAddress, tool.BaseAddress );
986 strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs );
987 if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding );
988 strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol );
989 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
990 strm << SPair( _FunctionOrder, tool.FunctionOrder );
991 strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation );
992 strm << TPair( _GenerateMapFile, tool.GenerateMapFile );
993 if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize );
994 if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize );
995 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
996 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
997 strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL );
998 strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary );
999 strm << SPair( _ImportLibrary, tool.ImportLibrary );
1000 if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware );
1001 strm << TPair( _LinkDLL, tool.LinkDLL );
1002 if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental );
1003 strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration );
1004 strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile );
1005 strm << TPair( _MapExports, tool.MapExports );
1006 strm << SPair( _MapFileName, tool.MapFileName );
1007 strm << TPair( _MapLines, tool.MapLines );
1008 strm << SPair( _MergedIDLBaseFileName, tool.MergedIDLBaseFileName );
1009 strm << SPair( _MergeSections, tool.MergeSections );
1010 strm << SPair( _MidlCommandFile, tool.MidlCommandFile );
1011 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
1012 if ( tool.OptimizeForWindows98 != optWin98Default ) strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 );
1013 if ( tool.OptimizeReferences != optReferencesDefault ) strm << EPair( _OptimizeReferences, tool.OptimizeReferences );
1014 strm << SPair( _OutputFile, tool.OutputFile );
1015 strm << SPair( _ProgramDatabaseFile, tool.ProgramDatabaseFile );
1016 strm << TPair( _RegisterOutput, tool.RegisterOutput );
1017 strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL );
1018 strm << TPair( _SetChecksum, tool.SetChecksum );
1019 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress );
1020 if ( tool.StackCommitSize != -1 ) strm << LPair( _StackCommitSize, tool.StackCommitSize );
1021 if ( tool.StackReserveSize != -1 ) strm << LPair( _StackReserveSize, tool.StackReserveSize );
1022 strm << SPair( _StripPrivateSymbols, tool.StripPrivateSymbols );
1023 strm << EPair( _SubSystem, tool.SubSystem );
1024 strm << TPair( _SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL );
1025 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1026 strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD );
1027 strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet );
1028 if ( tool.TargetMachine != machineNotSet ) strm << EPair( _TargetMachine, tool.TargetMachine );
1029 if ( tool.TerminalServerAware != termSvrAwareDefault ) strm << EPair( _TerminalServerAware, tool.TerminalServerAware );
1030 strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration );
1031 strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile );
1032 if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID );
1033 strm << SPair( _Version4, tool.Version );
1034 strm << "/>";
1035 return strm;
1036}
1037
1038// Hashing routine to do fast option lookups ----
1039// Slightly rewritten to stop on ':' ',' and '\0'
1040// Original routine in qtranslator.cpp ----------
1041static uint elfHash( const char* name )
1042{
1043 const uchar *k;
1044 uint h = 0;
1045 uint g;
1046
1047 if ( name ) {
1048 k = (const uchar *) name;
1049 while ( (*k) &&
1050 (*k)!= ':' &&
1051 (*k)!=',' &&
1052 (*k)!=' ' ) {
1053 h = ( h << 4 ) + *k++;
1054 if ( (g = (h & 0xf0000000)) != 0 )
1055 h ^= g >> 24;
1056 h &= ~g;
1057 }
1058 }
1059 if ( !h )
1060 h = 1;
1061 return h;
1062}
1063static void displayHash( const char* str )
1064{
1065 printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str );
1066}
1067
1068bool VCLinkerTool::parseOption( const char* option )
1069{
1070#if 0
1071 // Main options
1072 displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" );
1073 displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" );
1074 displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" );
1075 displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" );
1076 displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" );
1077 displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" );
1078 displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" );
1079 displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" );
1080 displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" );
1081 displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" );
1082 displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" );
1083 displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" );
1084 displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" );
1085 displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" );
1086 displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" );
1087 displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" );
1088 displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" );
1089 displayHash( "/VXD" ); displayHash( "/WS " );
1090#endif
1091#if 0
1092 // Sub options
1093 displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" );
1094 displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" );
1095 displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" );
1096 displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" );
1097 displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" );
1098 displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" );
1099 displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" );
1100#endif
1101
1102 switch ( elfHash(option) ) {
1103 case 0x3360dbe: // /ALIGN[:number]
1104 case 0x1485c34: // /ALLOWBIND[:NO]
1105 case 0x6b21972: // /DEFAULTLIB:library
1106 case 0x396ea92: // /DRIVER[:UPONLY | :WDM]
1107 case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386]
1108 case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA]
1109 case 0x33aec94: // /FIXED[:NO]
1110 case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED]
1111 case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#]
1112 case 0x0348992: // /STUB:filename
1113 case 0x0034bc4: // /VXD
1114 case 0x0034c50: // /WS
1115 AdditionalOptions += option;
1116 break;
1117 case 0x679c075: // /ASSEMBLYMODULE:filename
1118 AddModuleNamesToAssembly += option+15;
1119 break;
1120 case 0x062d065: // /ASSEMBLYRESOURCE:filename
1121 LinkToManagedResourceFile = option+18;
1122 break;
1123 case 0x0336675: // /BASE:{address | @filename,key}
1124 // Do we need to do a manual lookup when '@filename,key'?
1125 // Seems BaseAddress only can contain the location...
1126 // We don't use it in Qt, so keep it simple for now
1127 BaseAddress = option+6;
1128 break;
1129 case 0x3389797: // /DEBUG
1130 GenerateDebugInformation = _True;
1131 break;
1132 case 0x0033896: // /DEF:filename
1133 ModuleDefinitionFile = option+5;
1134 break;
1135 case 0x338a069: // /DELAY:{UNLOAD | NOBIND}
1136 // MS documentation does not specify what to do with
1137 // this option, so we'll put it in AdditionalOptions
1138 AdditionalOptions += option;
1139 break;
1140 case 0x06f4bf4: // /DELAYLOAD:dllname
1141 DelayLoadDLLs += option+11;
1142 break;
1143 // case 0x003390c: // /DLL
1144 // This option is not used for vcproj files
1145 //break;
1146 case 0x33a3979: // /ENTRY:function
1147 EntryPointSymbol = option+7;
1148 break;
1149 case 0x033c960: // /HEAP:reserve[,commit]
1150 {
1151 QStringList both = QStringList::split( ",", option+6 );
1152 HeapReserveSize = both[0].toLong();
1153 if ( both.count() == 2 )
1154 HeapCommitSize = both[1].toLong();
1155 }
1156 break;
1157 case 0x3d91494: // /IDLOUT:[path\]filename
1158 MergedIDLBaseFileName = option+8;
1159 break;
1160 case 0x345a04c: // /IGNOREIDL
1161 IgnoreEmbeddedIDL = _True;
1162 break;
1163 case 0x3e250e2: // /IMPLIB:filename
1164 ImportLibrary = option+8;
1165 break;
1166 case 0xe281ab5: // /INCLUDE:symbol
1167 ForceSymbolReferences += option+9;
1168 break;
1169 case 0xb28103c: // /INCREMENTAL[:no]
1170 if ( *(option+12) == ':' &&
1171 *(option+13) == 'n' )
1172 LinkIncremental = linkIncrementalNo;
1173 else
1174 LinkIncremental = linkIncrementalYes;
1175 break;
1176 case 0x26e4675: // /LARGEADDRESSAWARE[:no]
1177 if ( *(option+18) == ':' &&
1178 *(option+19) == 'n' )
1179 LargeAddressAware = addrAwareNoLarge;
1180 else
1181 LargeAddressAware = addrAwareLarge;
1182 break;
1183 case 0x0d745c8: // /LIBPATH:dir
1184 AdditionalLibraryDirectories += option+9;
1185 break;
1186 case 0x0341877: // /LTCG[:NOSTATUS|:STATUS]
1187 config->WholeProgramOptimization = _True;
1188 LinkTimeCodeGeneration = _True;
1189 if ( *(option+5) == ':' &&
1190 *(option+6) == 'S' )
1191 ShowProgress = linkProgressAll;
1192 break;
1193 case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE}
1194 switch ( elfHash(option+9) ) {
1195 // Very limited documentation on all options but X86,
1196 // so we put the others in AdditionalOptions...
1197 case 0x0046063: // AM33
1198 case 0x000466d: // ARM
1199 case 0x0004795: // CEE
1200 case 0x004d494: // IA64
1201 case 0x0050672: // M32R
1202 case 0x0051e53: // MIPS
1203 case 0x51e5646: // MIPS16
1204 case 0x1e57b05: // MIPSFPU
1205 case 0x57b09a6: // MIPSFPU16
1206 case 0x5852738: // MIPSR41XX
1207 case 0x0005543: // PPC
1208 case 0x00057b3: // SH3
1209 case 0x00057b4: // SH4
1210 case 0x00057b5: // SH5
1211 case 0x058da12: // THUMB
1212 case 0x96d8435: // TRICORE
1213 AdditionalOptions += option;
1214 break;
1215 case 0x0005bb6: // X86
1216 TargetMachine = machineX86;
1217 break;
1218 default:
1219 return FALSE;
1220 }
1221 break;
1222 case 0x0034160: // /MAP[:filename]
1223 GenerateMapFile = _True;
1224 MapFileName = option+5;
1225 break;
1226 case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES}
1227 if ( *(option+9) == 'E' )
1228 MapExports = _True;
1229 else if ( *(option+9) == 'L' )
1230 MapLines = _True;
1231 break;
1232 case 0x341a6b5: // /MERGE:from=to
1233 MergeSections = option+7;
1234 break;
1235 case 0x0341d8c: // /MIDL:@file
1236 MidlCommandFile = option+7;
1237 break;
1238 case 0x84e2679: // /NOASSEMBLY
1239 TurnOffAssemblyGeneration = _True;
1240 break;
1241 case 0x2b21942: // /NODEFAULTLIB[:library]
1242 if ( *(option+13) == '\0' )
1243 IgnoreAllDefaultLibraries = _True;
1244 else
1245 IgnoreDefaultLibraryNames += option+14;
1246 break;
1247 case 0x33a3a39: // /NOENTRY
1248 ResourceOnlyDLL = _True;
1249 break;
1250 case 0x434138f: // /NOLOGO
1251 SuppressStartupBanner = _True;
1252 break;
1253 case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98}
1254 {
1255 char third = *(option+7);
1256 switch ( third ) {
1257 case 'F': // REF
1258 if ( *(option+5) == 'R' ) {
1259 OptimizeReferences = optReferences;
1260 } else { // ICF[=iterations]
1261 EnableCOMDATFolding = optFolding;
1262 // [=iterations] case is not documented
1263 }
1264 break;
1265 case 'R': // NOREF
1266 OptimizeReferences = optNoReferences;
1267 break;
1268 case 'I': // NOICF
1269 EnableCOMDATFolding = optNoFolding;
1270 break;
1271 case 'N': // WIN98
1272 OptimizeForWindows98 = optWin98Yes;
1273 break;
1274 case 'W': // NOWIN98
1275 OptimizeForWindows98 = optWin98No;
1276 break;
1277 default:
1278 return FALSE;
1279 }
1280 }
1281 break;
1282 case 0x34468a2: // /ORDER:@filename
1283 FunctionOrder = option+8;
1284 break;
1285 case 0x00344a4: // /OUT:filename
1286 OutputFile = option+5;
1287 break;
1288 case 0x0034482: // /PDB:filename
1289 ProgramDatabaseFile = option+5;
1290 break;
1291 case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name
1292 StripPrivateSymbols = option+13;
1293 break;
1294 case 0x6a09535: // /RELEASE
1295 SetChecksum = _True;
1296 break;
1297 case 0x348857b: // /STACK:reserve[,commit]
1298 {
1299 QStringList both = QStringList::split( ",", option+7 );
1300 StackReserveSize = both[0].toLong();
1301 if ( both.count() == 2 )
1302 StackCommitSize = both[1].toLong();
1303 }
1304 break;
1305 case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]]
1306 {
1307 // Split up in subsystem, and version number
1308 QStringList both = QStringList::split( ",", option+11 );
1309 switch ( elfHash(both[0].latin1()) ) {
1310 case 0x8438445: // CONSOLE
1311 SubSystem = subSystemConsole;
1312 break;
1313 case 0xbe29493: // WINDOWS
1314 SubSystem = subSystemWindows;
1315 break;
1316 // The following are undocumented, so add them to AdditionalOptions
1317 case 0x240949e: // EFI_APPLICATION
1318 case 0xe617652: // EFI_BOOT_SERVICE_DRIVER
1319 case 0x9af477d: // EFI_ROM
1320 case 0xd34df42: // EFI_RUNTIME_DRIVER
1321 case 0x5268ea5: // NATIVE
1322 case 0x05547e8: // POSIX
1323 case 0x2949c95: // WINDOWSCE
1324 AdditionalOptions += option;
1325 break;
1326 default:
1327 return FALSE;
1328 }
1329 }
1330 break;
1331 case 0x8b654de: // /SWAPRUN:{NET | CD}
1332 if ( *(option+9) == 'N' )
1333 SwapRunFromNet = _True;
1334 else if ( *(option+9) == 'C' )
1335 SwapRunFromCD = _True;
1336 else
1337 return FALSE;
1338 break;
1339 case 0x34906d4: // /TLBID:id
1340 TypeLibraryResourceID = QString( option+7 ).toLong();
1341 break;
1342 case 0x4907494: // /TLBOUT:[path\]filename
1343 TypeLibraryFile = option+8;
1344 break;
1345 case 0x976b525: // /TSAWARE[:NO]
1346 if ( *(option+8) == ':' )
1347 TerminalServerAware = termSvrAwareNo;
1348 else
1349 TerminalServerAware = termSvrAwareYes;
1350 break;
1351 case 0xaa67735: // /VERBOSE[:lib]
1352 if ( *(option+9) == ':' ) {
1353 ShowProgress = linkProgressLibs;
1354 AdditionalOptions += option;
1355 } else {
1356 ShowProgress = linkProgressAll;
1357 }
1358 break;
1359 case 0xaa77f7e: // /VERSION:major[.minor]
1360 Version = option+9;
1361 break;
1362 default:
1363 return FALSE;
1364 }
1365 return TRUE;
1366}
1367
1368// VCMIDLTool -------------------------------------------------------
1369VCMIDLTool::VCMIDLTool()
1370 :DefaultCharType( midlCharUnsigned ),
1371 EnableErrorChecks( midlDisableAll ),
1372 ErrorCheckAllocations( unset ),
1373 ErrorCheckBounds( unset ),
1374 ErrorCheckEnumRange( unset ),
1375 ErrorCheckRefPointers( unset ),
1376 ErrorCheckStubData( unset ),
1377 GenerateStublessProxies( unset ),
1378 GenerateTypeLibrary( unset ),
1379 IgnoreStandardIncludePath( unset ),
1380 MkTypLibCompatible( unset ),
1381 StructMemberAlignment( midlAlignNotSet ),
1382 SuppressStartupBanner( unset ),
1383 TargetEnvironment( midlTargetNotSet ),
1384 ValidateParameters( unset ),
1385 WarnAsError( unset ),
1386 WarningLevel( midlWarningLevel_0 )
1387{
1388}
1389
1390QTextStream &operator<<( QTextStream &strm, const VCMIDLTool &tool )
1391{
1392 strm << _begTool3;
1393 strm << _VCMIDLToolName;
1394 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1395 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
1396 strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions );
1397 strm << EPair( _DefaultCharType, tool.DefaultCharType );
1398 strm << SPair( _DLLDataFileName, tool.DLLDataFileName );
1399 strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks );
1400 strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations );
1401 strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds );
1402 strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange );
1403 strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers );
1404 strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData );
1405 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1406 strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies );
1407 strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary );
1408 strm << SPair( _HeaderFileName, tool.HeaderFileName );
1409 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1410 strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName );
1411 strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible );
1412 strm << SPair( _OutputDirectory4, tool.OutputDirectory );
1413 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1414 strm << SPair( _ProxyFileName, tool.ProxyFileName );
1415 strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors );
1416 if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment );
1417 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1418 if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment );
1419 strm << SPair( _TypeLibraryName, tool.TypeLibraryName );
1420 strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions );
1421 strm << TPair( _ValidateParameters, tool.ValidateParameters );
1422 strm << TPair( _WarnAsError, tool.WarnAsError );
1423 strm << EPair( _WarningLevel, tool.WarningLevel );
1424 strm << "/>";
1425 return strm;
1426}
1427
1428bool VCMIDLTool::parseOption( const char* option )
1429{
1430#if 0
1431 displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" );
1432 displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" );
1433 displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" );
1434 displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" );
1435 displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" );
1436 displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" );
1437 displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" );
1438 displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" );
1439 displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" );
1440 displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" );
1441 displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" );
1442 displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" );
1443 displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" );
1444 displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" );
1445 displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" );
1446 displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" );
1447 displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" );
1448 displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" );
1449 displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" );
1450 displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" );
1451 displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" );
1452 displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" );
1453 displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" );
1454 displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" );
1455 displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" );
1456 displayHash( "/win32" ); displayHash( "/win64" );
1457#endif
1458 int offset = 0;
1459 switch( elfHash(option) ) {
1460 case 0x0000334: // /D name[=def]
1461 PreprocessorDefinitions += option+3;
1462 break;
1463 case 0x0000339: // /I directory-list
1464 AdditionalIncludeDirectories += option+3;
1465 break;
1466 case 0x0345f96: // /Oicf
1467 case 0x00345f6: // /Oif
1468 GenerateStublessProxies = _True;
1469 break;
1470 case 0x0000345: // /U name
1471 UndefinePreprocessorDefinitions += option+3;
1472 break;
1473 case 0x00034c8: // /WX
1474 WarnAsError = _True;
1475 break;
1476 case 0x3582fde: // /align {N}
1477 offset = 3; // Fallthrough
1478 case 0x0003510: // /Zp {N}
1479 switch ( *(option+offset+4) ) {
1480 case '1':
1481 StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes;
1482 break;
1483 case '2':
1484 StructMemberAlignment = midlAlignTwoBytes;
1485 break;
1486 case '4':
1487 StructMemberAlignment = midlAlignFourBytes;
1488 break;
1489 case '8':
1490 StructMemberAlignment = midlAlignEightBytes;
1491 break;
1492 default:
1493 return FALSE;
1494 }
1495 break;
1496 case 0x0359e82: // /char {ascii7|signed|unsigned}
1497 switch( *(option+6) ) {
1498 case 'a':
1499 DefaultCharType = midlCharAscii7;
1500 break;
1501 case 's':
1502 DefaultCharType = midlCharSigned;
1503 break;
1504 case 'u':
1505 DefaultCharType = midlCharUnsigned;
1506 break;
1507 default:
1508 return FALSE;
1509 }
1510 break;
1511 case 0xa766524: // /cpp_opt options
1512 CPreprocessOptions += option+9;
1513 break;
1514 case 0xb32abf1: // /dlldata filename
1515 DLLDataFileName = option + 9;
1516 break;
1517 case 0x0035c56: // /env {win32|win64}
1518 TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32;
1519 break;
1520 case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data}
1521 EnableErrorChecks = midlEnableCustom;
1522 switch ( *(option+7) ) {
1523 case 'a':
1524 if ( *(option+10) == '\0' )
1525 EnableErrorChecks = midlEnableAll;
1526 else
1527 ErrorCheckAllocations = _True;
1528 break;
1529 case 'b':
1530 ErrorCheckBounds = _True;
1531 break;
1532 case 'e':
1533 ErrorCheckEnumRange = _True;
1534 break;
1535 case 'n':
1536 EnableErrorChecks = midlDisableAll;
1537 break;
1538 case 'r':
1539 break;
1540 ErrorCheckRefPointers = _True;
1541 case 's':
1542 break;
1543 ErrorCheckStubData = _True;
1544 default:
1545 return FALSE;
1546 }
1547 break;
1548 case 0x5eb7af2: // /header filename
1549 offset = 5;
1550 case 0x0000358: // /h filename
1551 HeaderFileName = option + offset + 3;
1552 break;
1553 case 0x0035ff4: // /iid filename
1554 InterfaceIdentifierFileName = option+5;
1555 break;
1556 case 0x64b7933: // /mktyplib203
1557 MkTypLibCompatible = _True;
1558 break;
1559 case 0x8e0b0a2: // /no_def_idir
1560 IgnoreStandardIncludePath = _True;
1561 break;
1562 case 0x65635ef: // /nologo
1563 SuppressStartupBanner = _True;
1564 break;
1565 case 0x3656b22: // /notlb
1566 GenerateTypeLibrary = _True;
1567 break;
1568 case 0x000035f: // /o filename
1569 RedirectOutputAndErrors = option+3;
1570 break;
1571 case 0x00366c4: // /out directory
1572 OutputDirectory = option+5;
1573 break;
1574 case 0x36796f9: // /proxy filename
1575 ProxyFileName = option+7;
1576 break;
1577 case 0x6959c94: // /robust
1578 ValidateParameters = _True;
1579 break;
1580 case 0x6a88df4: // /target {system}
1581 if ( *(option+11) == '6' )
1582 TargetEnvironment = midlTargetWin64;
1583 else
1584 TargetEnvironment = midlTargetWin32;
1585 break;
1586 case 0x0036b22: // /tlb filename
1587 TypeLibraryName = option+5;
1588 break;
1589 case 0x36e0162: // /win32
1590 TargetEnvironment = midlTargetWin32;
1591 break;
1592 case 0x36e0194: // /win64
1593 TargetEnvironment = midlTargetWin64;
1594 break;
1595 case 0x0003459: // /Oi
1596 case 0x00345f3: // /Oic
1597 case 0x0003463: // /Os
1598 case 0x0003513: // /Zs
1599 case 0x0035796: // /acf filename
1600 case 0x5b1cb97: // /app_config
1601 case 0x3595cf4: // /c_ext
1602 case 0x5a2fc64: // /client {none|stub}
1603 case 0xa64d3dd: // /confirm
1604 case 0xa765b64: // /cpp_cmd cmd_line
1605 case 0x35aabb2: // /cstub filename
1606 case 0x03629f4: // /lcid
1607 case 0x6495cc4: // /ms_ext
1608 case 0x96c7a1e: // /ms_union
1609 case 0x4996fa2: // /msc_ver <nnnn>
1610 case 0x64ceb12: // /newtlb
1611 case 0x6555a40: // /no_cpp
1612 case 0xf64d6a6: // /no_default_epv
1613 case 0x6dd9384: // /no_format_opt
1614 case 0x556dbee: // /no_warn
1615 case 0x3655a70: // /nocpp
1616 case 0x2b455a3: // /oldnames
1617 case 0x662bb12: // /oldtlb
1618 case 0x0036696: // /osf
1619 case 0x036679b: // /pack {N}
1620 case 0x678bd38: // /prefix {all|client|server|switch}
1621 case 0x96b702c: // /protocol {all|dce|ndr64}
1622 case 0x3696aa3: // /rpcss
1623 case 0x698ca60: // /savePP
1624 case 0x69c9cf2: // /server {none|stub}
1625 case 0x36aabb2: // /sstub filename
1626 case 0xce9b12b: // /syntax_check
1627 case 0xc9b5f16: // /use_epv
1628 AdditionalOptions += option;
1629 break;
1630 default:
1631 // /W{0|1|2|3|4} case
1632 if ( *(option+1) == 'W' ) {
1633 switch ( *(option+2) ) {
1634 case '0':
1635 WarningLevel = midlWarningLevel_0;
1636 break;
1637 case '1':
1638 WarningLevel = midlWarningLevel_1;
1639 break;
1640 case '2':
1641 WarningLevel = midlWarningLevel_2;
1642 break;
1643 case '3':
1644 WarningLevel = midlWarningLevel_3;
1645 break;
1646 case '4':
1647 WarningLevel = midlWarningLevel_4;
1648 break;
1649 default:
1650 return FALSE;
1651 }
1652 }
1653 break;
1654 }
1655 return TRUE;
1656}
1657
1658// VCLibrarianTool --------------------------------------------------
1659VCLibrarianTool::VCLibrarianTool()
1660 :IgnoreAllDefaultLibraries( unset ),
1661 SuppressStartupBanner( _True )
1662{
1663}
1664
1665QTextStream &operator<<( QTextStream &strm, const VCLibrarianTool &tool )
1666{
1667 strm << _begTool3;
1668 strm << SPair( _ToolName, QString( "VCLibrarianTool" ) );
1669 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies );
1670 strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories );
1671 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
1672 strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions );
1673 strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences );
1674 strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries );
1675 strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames );
1676 strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile );
1677 strm << SPair( _OutputFile, tool.OutputFile );
1678 strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner );
1679 strm << "/>";
1680 return strm;
1681}
1682
1683// VCCustomBuildTool ------------------------------------------------
1684VCCustomBuildTool::VCCustomBuildTool()
1685{
1686 ToolName = "VCCustomBuildTool";
1687}
1688
1689QTextStream &operator<<( QTextStream &strm, const VCCustomBuildTool &tool )
1690{
1691 strm << _begTool3;
1692 strm << SPair( _ToolName, tool.ToolName );
1693 strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" );
1694 strm << SPair( _CommandLine4, tool.CommandLine );
1695 strm << SPair( _Description4, tool.Description );
1696 strm << SPair( _Outputs4, tool.Outputs );
1697 strm << SPair( _ToolPath, tool.ToolPath );
1698 strm << "/>";
1699 return strm;
1700}
1701
1702// VCResourceCompilerTool -------------------------------------------
1703VCResourceCompilerTool::VCResourceCompilerTool()
1704 : Culture( rcUseDefault ),
1705 IgnoreStandardIncludePath( unset ),
1706 ShowProgress( linkProgressNotSet )
1707{
1708 PreprocessorDefinitions = "NDEBUG";
1709}
1710
1711QTextStream &operator<<( QTextStream &strm, const VCResourceCompilerTool &tool )
1712{
1713 strm << _begTool3;
1714 strm << _VCResourceCompilerToolName;
1715 strm << SPair( _ToolPath, tool.ToolPath );
1716 strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories );
1717 strm << XPair( _AdditionalOptions, tool.AdditionalOptions );
1718 if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture );
1719 strm << XPair( _FullIncludePath, tool.FullIncludePath );
1720 strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath );
1721 strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions );
1722 strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName );
1723 if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress );
1724 strm << "/>";
1725 return strm;
1726}
1727
1728// VCEventTool -------------------------------------------------
1729QTextStream &operator<<( QTextStream &strm, const VCEventTool &tool )
1730{
1731 strm << _begTool3;
1732 strm << SPair( _ToolName, tool.ToolName );
1733 strm << SPair( _ToolPath, tool.ToolPath );
1734 strm << SPair( _CommandLine4, tool.CommandLine );
1735 strm << SPair( _Description4, tool.Description );
1736 strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild );
1737 strm << "/>";
1738 return strm;
1739}
1740
1741// VCPostBuildEventTool ---------------------------------------------
1742VCPostBuildEventTool::VCPostBuildEventTool()
1743{
1744 ToolName = "VCPostBuildEventTool";
1745}
1746
1747// VCPreBuildEventTool ----------------------------------------------
1748VCPreBuildEventTool::VCPreBuildEventTool()
1749{
1750 ToolName = "VCPreBuildEventTool";
1751}
1752
1753// VCPreLinkEventTool -----------------------------------------------
1754VCPreLinkEventTool::VCPreLinkEventTool()
1755{
1756 ToolName = "VCPreLinkEventTool";
1757}
1758
1759// VCConfiguration --------------------------------------------------
1760
1761VCConfiguration::VCConfiguration()
1762 :ATLMinimizesCRunTimeLibraryUsage( unset ),
1763 BuildBrowserInformation( unset ),
1764 CharacterSet( charSetNotSet ),
1765 ConfigurationType( typeApplication ),
1766 RegisterOutput( unset ),
1767 UseOfATL( useATLNotSet ),
1768 UseOfMfc( useMfcStdWin ),
1769 WholeProgramOptimization( unset )
1770{
1771 compiler.config = this;
1772 linker.config = this;
1773 idl.config = this;
1774}
1775
1776QTextStream &operator<<( QTextStream &strm, const VCConfiguration &tool )
1777{
1778 strm << _begConfiguration;
1779 strm << SPair( _Name3, tool.Name );
1780 strm << SPair( _OutputDirectory3, tool.OutputDirectory );
1781 strm << TPair( _ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage );
1782 strm << TPair( _BuildBrowserInformation, tool.BuildBrowserInformation );
1783 if ( tool.CharacterSet != charSetNotSet)strm << EPair( _CharacterSet, tool.CharacterSet );
1784 strm << EPair( _ConfigurationType, tool.ConfigurationType );
1785 strm << SPair( _DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean );
1786 strm << SPair( _ImportLibrary, tool.ImportLibrary );
1787 strm << SPair( _IntermediateDirectory, tool.IntermediateDirectory );
1788 strm << SPair( _PrimaryOutput, tool.PrimaryOutput );
1789 strm << SPair( _ProgramDatabase, tool.ProgramDatabase );
1790 strm << TPair( _RegisterOutput, tool.RegisterOutput );
1791 if ( tool.UseOfATL != useATLNotSet) strm << EPair( _UseOfATL, tool.UseOfATL );
1792 strm << EPair( _UseOfMfc, tool.UseOfMfc );
1793 strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization );
1794 strm << ">";
1795 strm << tool.compiler;
1796 strm << tool.custom;
1797 if ( tool.ConfigurationType == typeStaticLibrary )
1798 strm << tool.librarian;
1799 else
1800 strm << tool.linker;
1801 strm << tool.idl;
1802 strm << tool.postBuild;
1803 strm << tool.preBuild;
1804 strm << tool.preLink;
1805 strm << tool.resource;
1806 strm << _endConfiguration;
1807 return strm;
1808}
1809// VCFilter ---------------------------------------------------------
1810VCFilter::VCFilter()
1811 : ParseFiles( unset )
1812{
1813}
1814
1815void VCFilter::generateMOC( QTextStream &strm, QString str ) const
1816{
1817 QString mocOutput = Project->findMocDestination( str );
1818 QString mocApp = Project->var( "QMAKE_MOC" );
1819
1820 if( mocOutput.isEmpty() ) {
1821 // In specialcases we DO moc .cpp files
1822 // when the result is an .moc file
1823 if ( !str.endsWith(".moc") )
1824 return;
1825 mocOutput = str;
1826 str = Project->findMocSource( mocOutput );
1827 }
1828
1829 strm << _begFileConfiguration;
1830 strm << _Name5;
1831 strm << Config->Name;
1832 strm << "\">";
1833 strm << _begTool5;
1834 strm << _VCCustomBuildTool;
1835 strm << _Description6;
1836 strm << "Moc'ing " << str << "...\"";
1837 strm << _CommandLine6;
1838 strm << mocApp;
1839 strm << " " << str << " -o " << mocOutput << "\"";
1840 strm << _AdditionalDependencies6;
1841 strm << mocApp << "\"";
1842 strm << _Outputs6;
1843 strm << mocOutput << "\"";
1844 strm << "/>";
1845 strm << _endFileConfiguration;
1846}
1847
1848void VCFilter::generateUIC( QTextStream &strm, const QString& str ) const
1849{
1850 QString uicApp = Project->var("QMAKE_UIC");
1851 QString mocApp = Project->var( "QMAKE_MOC" );
1852 QString fname = str.section( '\\', -1 );
1853 QString mocDir = Project->var( "MOC_DIR" );
1854 int dot = fname.findRev( '.' );
1855 if( dot != -1 )
1856 fname.truncate( dot );
1857
1858 int slash = str.findRev( '\\' );
1859 QString pname = ( slash != -1 ) ? str.left( slash+1 ) : QString(".\\");
1860
1861 strm << _begFileConfiguration;
1862 strm << _Name5;
1863 strm << Config->Name;
1864 strm << "\">";
1865 strm << _begTool5;
1866 strm << _VCCustomBuildTool;
1867 strm << _Description6;
1868 strm << "Uic'ing " << str << "...\"";
1869 strm << _CommandLine6;
1870 strm << uicApp << " " << str << " -o " << pname << fname << ".h &amp;&amp; "; // Create .h from .ui file
1871 strm << uicApp << " " << str << " -i " << fname << ".h -o " << pname << fname << ".cpp &amp;&amp; ";// Create .cpp from .ui file
1872 strm << mocApp << " " << pname << fname << ".h -o " << mocDir << "moc_" << fname << ".cpp\"";
1873 strm << _AdditionalDependencies6;
1874 strm << mocApp << ";" << uicApp << "\"";
1875 strm << _Outputs6;
1876 strm << pname << fname << ".h;" << pname << fname << ".cpp;" << mocDir << "moc_" << fname << ".cpp\"";
1877 strm << "/>";
1878 strm << _endFileConfiguration;
1879}
1880
1881QTextStream &operator<<( QTextStream &strm, const VCFilter &tool )
1882{
1883 if ( tool.Files.count() == 0 )
1884 return strm;
1885
1886 strm << _begFilter;
1887 strm << SPair( _Name3, tool.Name );
1888 strm << TPair( _ParseFiles, tool.ParseFiles );
1889 strm << SPair( _Filter, tool.Filter );
1890 strm << ">";
1891 for ( QStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) {
1892 strm << _begFile;
1893 strm << SPair( _RelativePath, *it );
1894 strm << ">";
1895 if ( tool.CustomBuild == moc )
1896 tool.generateMOC( strm, *it );
1897 else if ( tool.CustomBuild == uic )
1898 tool.generateUIC( strm, *it );
1899 strm << _endFile;
1900 }
1901
1902 strm << _endFilter;
1903 return strm;
1904}
1905
1906// VCProject --------------------------------------------------------
1907VCProject::VCProject()
1908{
1909 QUuid uniqueId;
1910#if defined(Q_WS_WIN32)
1911 GUID guid;
1912 HRESULT h = CoCreateGuid( &guid );
1913 if ( h == S_OK )
1914 uniqueId = QUuid( guid );
1915 ProjectGUID = uniqueId.toString();
1916#else
1917 // Qt doesn't support GUID on other platforms yet
1918 ProjectGUID = "";
1919#endif
1920}
1921
1922QTextStream &operator<<( QTextStream &strm, const VCProject &tool )
1923{
1924 strm << _xmlInit;
1925 strm << _begVisualStudioProject;
1926 strm << _ProjectType;
1927 strm << SPair( _Version1, tool.Version );
1928 strm << SPair( _Name1, tool.Name );
1929 strm << SPair( _ProjectGUID, tool.ProjectGUID );
1930 strm << SPair( _SccProjectName, tool.SccProjectName );
1931 strm << SPair( _SccLocalPath, tool.SccLocalPath );
1932 strm << ">";
1933 strm << _begPlatforms;
1934 strm << _begPlatform;
1935 strm << SPair( _Name3, tool.PlatformName );
1936 strm << "/>";
1937 strm << _endPlatforms;
1938 strm << _begConfigurations;
1939 strm << tool.Configuration;
1940 strm << _endConfigurations;
1941 strm << _begFiles;
1942 strm << tool.SourceFiles;
1943 strm << tool.HeaderFiles;
1944 strm << tool.MOCFiles;
1945 strm << tool.UICFiles;
1946 strm << tool.FormFiles;
1947 strm << tool.TranslationFiles;
1948 strm << tool.LexYaccFiles;
1949 strm << tool.ResourceFiles;
1950 strm << _endFiles;
1951 strm << _begGlobals;
1952 strm << _endGlobals;
1953 strm << _endVisualStudioProject;
1954 return strm;
1955}
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
new file mode 100644
index 0000000..2d09280
--- a/dev/null
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -0,0 +1,775 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Copyright (C) 2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the network module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35#ifndef __MSVC_OBJECTMODEL_H__
36#define __MSVC_OBJECTMODEL_H__
37
38#include "project.h"
39#include <qstring.h>
40#include <qstringlist.h>
41
42/*
43 This Object model is of course VERY simplyfied,
44 and does not actually follow the original MSVC
45 object model. However, it fulfilles the basic
46 needs for qmake
47*/
48
49/*
50 If a triState value is 'unset' then the
51 corresponding property is not in the output,
52 forcing the tool to utilize default values.
53 False/True values will be in the output...
54*/
55enum customBuildCheck {
56 none,
57 moc,
58 uic,
59 lexyacc
60};
61enum triState {
62 unset = -1,
63 _False = 0,
64 _True = 1
65};
66enum addressAwarenessType {
67 addrAwareDefault,
68 addrAwareNoLarge,
69 addrAwareLarge
70};
71enum asmListingOption {
72 asmListingNone,
73 asmListingAssemblyOnly,
74 asmListingAsmMachineSrc,
75 asmListingAsmMachine,
76 asmListingAsmSrc
77};
78enum basicRuntimeCheckOption {
79 runtimeBasicCheckNone,
80 runtimeCheckStackFrame,
81 runtimeCheckUninitVariables,
82 runtimeBasicCheckAll
83};
84enum browseInfoOption {
85 brInfoNone,
86 brAllInfo,
87 brNoLocalSymbols
88};
89enum callingConventionOption {
90 callConventionDefault = -1,
91 callConventionCDecl,
92 callConventionFastCall,
93 callConventionStdCall
94};
95enum charSet {
96 charSetNotSet,
97 charSetUnicode,
98 charSetMBCS
99};
100enum compileAsManagedOptions {
101 managedDefault = -1,
102 managedAssembly = 2
103};
104enum CompileAsOptions{
105 compileAsDefault,
106 compileAsC,
107 compileAsCPlusPlus
108};
109enum ConfigurationTypes {
110 typeUnknown = 0,
111 typeApplication = 1,
112 typeDynamicLibrary = 2,
113 typeStaticLibrary = 4,
114 typeGeneric = 10
115};
116enum debugOption {
117 debugDisabled,
118 debugOldStyleInfo,
119 debugLineInfoOnly,
120 debugEnabled,
121 debugEditAndContinue
122};
123enum eAppProtectionOption {
124 eAppProtectUnchanged,
125 eAppProtectLow,
126 eAppProtectMedium,
127 eAppProtectHigh
128};
129enum enumResourceLangID {
130 rcUseDefault = 0,
131 rcAfrikaans = 1078,
132 rcAlbanian = 1052,
133 rcArabicAlgeria = 5121,
134 rcArabicBahrain = 15361,
135 rcArabicEgypt = 3073,
136 rcArabicIraq = 2049,
137 rcArabicJordan = 11265,
138 rcArabicKuwait = 13313,
139 rcArabicLebanon = 12289,
140 rcArabicLibya = 4097,
141 rcArabicMorocco = 6145,
142 rcArabicOman = 8193,
143 rcArabicQatar = 16385,
144 rcArabicSaudi = 1025,
145 rcArabicSyria = 10241,
146 rcArabicTunisia = 7169,
147 rcArabicUnitedArabEmirates= 14337,
148 rcArabicYemen = 9217,
149 rcBasque = 1069,
150 rcBulgarian = 1026,
151 rcByelorussian = 1059,
152 rcCatalan = 1027,
153 rcChineseHongKong = 3076,
154 rcChinesePRC = 2052,
155 rcChineseSingapore = 4100,
156 rcChineseTaiwan = 1028,
157 rcCroatian = 1050,
158 rcCzech = 1029,
159 rcDanish = 1030,
160 rcDutchBelgium = 2067,
161 rcDutchStandard = 1043,
162 rcEnglishAustralia = 3081,
163 rcEnglishBritain = 2057,
164 rcEnglishCanada = 4105,
165 RcEnglishCaribbean = 9225,
166 rcEnglishIreland = 6153,
167 rcEnglishJamaica = 8201,
168 rcEnglishNewZealand = 5129,
169 rcEnglishSouthAfrica= 7177,
170 rcEnglishUS = 1033,
171 rcEstonian = 1061,
172 rcFarsi = 1065,
173 rcFinnish = 1035,
174 rcFrenchBelgium = 2060,
175 rcFrenchCanada = 3084,
176 rcFrenchLuxembourg = 5132,
177 rcFrenchStandard = 1036,
178 rcFrenchSwitzerland = 4108,
179 rcGermanAustria = 3079,
180 rcGermanLichtenstein= 5127,
181 rcGermanLuxembourg = 4103,
182 rcGermanStandard = 1031,
183 rcGermanSwitzerland = 2055,
184 rcGreek = 1032,
185 rcHebrew = 1037,
186 rcHungarian = 1038,
187 rcIcelandic = 1039,
188 rcIndonesian = 1057,
189 rcItalianStandard = 1040,
190 rcItalianSwitzerland= 2064,
191 rcJapanese = 1041,
192 rcKorean = 1042,
193 rcKoreanJohab = 2066,
194 rcLatvian = 1062,
195 rcLithuanian = 1063,
196 rcNorwegianBokmal = 1044,
197 rcNorwegianNynorsk = 2068,
198 rcPolish = 1045,
199 rcPortugueseBrazilian= 1046,
200 rcPortugueseStandard= 2070,
201 rcRomanian = 1048,
202 rcRussian = 1049,
203 rcSerbian = 2074,
204 rcSlovak = 1051,
205 rcSpanishArgentina = 11274,
206 rcSpanishBolivia = 16394,
207 rcSpanishChile = 13322,
208 rcSpanishColombia = 9226,
209 rcSpanishCostaRica = 5130,
210 rcSpanishDominicanRepublic= 7178,
211 rcSpanishEcuador = 12298,
212 rcSpanishGuatemala = 4106,
213 rcSpanishMexico = 2058,
214 rcSpanishModern = 3082,
215 rcSpanishPanama = 6154,
216 rcSpanishParaguay = 15370,
217 rcSpanishPeru = 10250,
218 rcSpanishTraditional= 1034,
219 rcSpanishUruguay = 14346,
220 rcSpanishVenezuela = 8202,
221 rcSwedish = 1053,
222 rcThai = 1054,
223 rcTurkish = 1055,
224 rcUkrainian = 1058,
225 rcUrdu = 1056
226};
227enum enumSccEvent {
228 eProjectInScc,
229 ePreDirtyNotification
230};
231enum favorSizeOrSpeedOption {
232 favorNone,
233 favorSpeed,
234 favorSize
235};
236enum genProxyLanguage {
237 genProxyNative,
238 genProxyManaged
239};
240enum inlineExpansionOption {
241 expandDisable,
242 expandOnlyInline,
243 expandAnySuitable
244};
245enum linkIncrementalType {
246 linkIncrementalDefault,
247 linkIncrementalNo,
248 linkIncrementalYes
249};
250enum linkProgressOption {
251 linkProgressNotSet,
252 linkProgressAll,
253 linkProgressLibs
254};
255enum machineTypeOption {
256 machineNotSet,
257 machineX86
258};
259enum midlCharOption {
260 midlCharUnsigned,
261 midlCharSigned,
262 midlCharAscii7
263};
264enum midlErrorCheckOption {
265 midlEnableCustom,
266 midlDisableAll,
267 midlEnableAll
268};
269enum midlStructMemberAlignOption {
270 midlAlignNotSet,
271 midlAlignSingleByte,
272 midlAlignTwoBytes,
273 midlAlignFourBytes,
274 midlAlignEightBytes,
275 midlAlignSixteenBytes
276};
277enum midlTargetEnvironment {
278 midlTargetNotSet,
279 midlTargetWin32,
280 midlTargetWin64
281};
282enum midlWarningLevelOption {
283 midlWarningLevel_0,
284 midlWarningLevel_1,
285 midlWarningLevel_2,
286 midlWarningLevel_3,
287 midlWarningLevel_4
288};
289enum optFoldingType {
290 optFoldingDefault,
291 optNoFolding,
292 optFolding
293};
294enum optimizeOption {
295 optimizeDisabled,
296 optimizeMinSpace,
297 optimizeMaxSpeed,
298 optimizeFull,
299 optimizeCustom
300};
301enum optRefType {
302 optReferencesDefault,
303 optNoReferences,
304 optReferences
305};
306enum optWin98Type {
307 optWin98Default,
308 optWin98No,
309 optWin98Yes
310};
311enum pchOption {
312 pchNone,
313 pchCreateUsingSpecific,
314 pchGenerateAuto,
315 pchUseUsingSpecific
316};
317enum preprocessOption {
318 preprocessNo,
319 preprocessYes,
320 preprocessNoLineNumbers
321};
322enum ProcessorOptimizeOption {
323 procOptimizeBlended,
324 procOptimizePentium,
325 procOptimizePentiumProAndAbove
326};
327enum RemoteDebuggerType {
328 DbgLocal,
329 DbgRemote,
330 DbgRemoteTCPIP
331};
332enum runtimeLibraryOption {
333 rtMultiThreaded,
334 rtMultiThreadedDebug,
335 rtMultiThreadedDLL,
336 rtMultiThreadedDebugDLL,
337 rtSingleThreaded,
338 rtSingleThreadedDebug
339};
340enum structMemberAlignOption {
341 alignNotSet,
342 alignSingleByte,
343 alignTwoBytes,
344 alignFourBytes,
345 alignEightBytes,
346 alignSixteenBytes
347};
348enum subSystemOption {
349 subSystemNotSet,
350 subSystemConsole,
351 subSystemWindows
352};
353enum termSvrAwarenessType {
354 termSvrAwareDefault,
355 termSvrAwareNo,
356 termSvrAwareYes
357};
358enum toolSetType {
359 toolSetUtility,
360 toolSetMakefile,
361 toolSetLinker,
362 toolSetLibrarian,
363 toolSetAll
364};
365enum TypeOfDebugger {
366 DbgNativeOnly,
367 DbgManagedOnly,
368 DbgMixed,
369 DbgAuto
370};
371enum useOfATL {
372 useATLNotSet,
373 useATLStatic,
374 useATLDynamic
375};
376enum useOfMfc {
377 useMfcStdWin,
378 useMfcStatic,
379 useMfcDynamic
380};
381enum warningLevelOption {
382 warningLevel_0,
383 warningLevel_1,
384 warningLevel_2,
385 warningLevel_3,
386 warningLevel_4
387};
388
389class VCToolBase {
390protected:
391 // Functions
392 VCToolBase(){};
393 ~VCToolBase(){};
394 virtual bool parseOption( const char* option ) = 0;
395public:
396 bool parseOptions( QStringList& options ) {
397 bool result = TRUE;
398 for ( QStringList::ConstIterator it=options.begin(); (it!=options.end()) && result; it++ )
399 result = parseOption( (*it).latin1() );
400 return result;
401 }
402};
403
404class VCConfiguration;
405class VCProject;
406
407class VCCLCompilerTool : public VCToolBase
408{
409public:
410 // Functions
411 VCCLCompilerTool();
412 ~VCCLCompilerTool(){};
413 virtual bool parseOption( const char* option );
414
415 // Variables
416 QStringList AdditionalIncludeDirectories;
417 QStringList AdditionalOptions;
418 QStringList AdditionalUsingDirectories;
419 QString AssemblerListingLocation;
420 asmListingOption AssemblerOutput;
421 basicRuntimeCheckOption BasicRuntimeChecks;
422 browseInfoOption BrowseInformation;
423 QString BrowseInformationFile;
424 triState BufferSecurityCheck;
425 callingConventionOption CallingConvention;
426 CompileAsOptions CompileAs;
427 compileAsManagedOptions CompileAsManaged;
428 triState CompileOnly;
429 debugOption DebugInformationFormat;
430 triState DefaultCharIsUnsigned;
431 triState Detect64BitPortabilityProblems;
432 triState DisableLanguageExtensions;
433 QStringList DisableSpecificWarnings;
434 triState EnableFiberSafeOptimizations;
435 triState EnableFunctionLevelLinking;
436 triState EnableIntrinsicFunctions;
437 triState ExceptionHandling;
438 triState ExpandAttributedSource;
439 favorSizeOrSpeedOption FavorSizeOrSpeed;
440 triState ForceConformanceInForLoopScope;
441 QStringList ForcedIncludeFiles;
442 QStringList ForcedUsingFiles;
443 preprocessOption GeneratePreprocessedFile;
444 triState GlobalOptimizations;
445 triState IgnoreStandardIncludePath;
446 triState ImproveFloatingPointConsistency;
447 inlineExpansionOption InlineFunctionExpansion;
448 triState KeepComments;
449 triState MinimalRebuild;
450 QString ObjectFile;
451 triState OmitFramePointers;
452 optimizeOption Optimization;
453 ProcessorOptimizeOption OptimizeForProcessor;
454 triState OptimizeForWindowsApplication;
455 QString OutputFile;
456 QString PrecompiledHeaderFile;
457 QString PrecompiledHeaderThrough;
458 QStringList PreprocessorDefinitions;
459 QString ProgramDataBaseFileName;
460 runtimeLibraryOption RuntimeLibrary;
461 triState RuntimeTypeInfo;
462 triState ShowIncludes;
463 triState SmallerTypeCheck;
464 triState StringPooling;
465 structMemberAlignOption StructMemberAlignment;
466 triState SuppressStartupBanner;
467 triState TreatWChar_tAsBuiltInType;
468 triState TurnOffAssemblyGeneration;
469 triState UndefineAllPreprocessorDefinitions;
470 QStringList UndefinePreprocessorDefinitions;
471 pchOption UsePrecompiledHeader;
472 triState WarnAsError;
473 warningLevelOption WarningLevel;
474 triState WholeProgramOptimization;
475 VCConfiguration* config;
476};
477
478class VCLinkerTool : public VCToolBase
479{
480public:
481 // Functions
482 VCLinkerTool();
483 ~VCLinkerTool(){};
484 virtual bool parseOption( const char* option );
485
486 // Variables
487 QStringList AdditionalDependencies;
488 QStringList AdditionalLibraryDirectories;
489 QStringList AdditionalOptions;
490 QStringList AddModuleNamesToAssembly;
491 QString BaseAddress;
492 QStringList DelayLoadDLLs;
493 optFoldingType EnableCOMDATFolding;
494 QString EntryPointSymbol;
495 QStringList ForceSymbolReferences;
496 QString FunctionOrder;
497 triState GenerateDebugInformation;
498 triState GenerateMapFile;
499 long HeapCommitSize;
500 long HeapReserveSize;
501 triState IgnoreAllDefaultLibraries;
502 QStringList IgnoreDefaultLibraryNames;
503 triState IgnoreEmbeddedIDL;
504 triState IgnoreImportLibrary;
505 QString ImportLibrary;
506 addressAwarenessType LargeAddressAware;
507 triState LinkDLL;
508 linkIncrementalType LinkIncremental;
509 triState LinkTimeCodeGeneration;
510 QString LinkToManagedResourceFile;
511 triState MapExports;
512 QString MapFileName;
513 triState MapLines;
514 QString MergedIDLBaseFileName;
515 QString MergeSections; // Should be list?
516 QString MidlCommandFile;
517 QString ModuleDefinitionFile; // Should be list?
518 optWin98Type OptimizeForWindows98;
519 optRefType OptimizeReferences;
520 QString OutputFile;
521 QString ProgramDatabaseFile;
522 triState RegisterOutput;
523 triState ResourceOnlyDLL;
524 triState SetChecksum;
525 linkProgressOption ShowProgress;
526 long StackCommitSize;
527 long StackReserveSize;
528 QString StripPrivateSymbols; // Should be list?
529 subSystemOption SubSystem;
530 triState SupportUnloadOfDelayLoadedDLL;
531 triState SuppressStartupBanner;
532 triState SwapRunFromCD;
533 triState SwapRunFromNet;
534 machineTypeOption TargetMachine;
535 termSvrAwarenessType TerminalServerAware;
536 triState TurnOffAssemblyGeneration;
537 QString TypeLibraryFile;
538 long TypeLibraryResourceID;
539 QString Version;
540 VCConfiguration* config;
541};
542
543class VCMIDLTool : public VCToolBase
544{
545public:
546 // Functions
547 VCMIDLTool();
548 ~VCMIDLTool(){};
549 virtual bool parseOption( const char* option );
550
551 // Variables
552 QStringList AdditionalIncludeDirectories;
553 QStringList AdditionalOptions;
554 QStringList CPreprocessOptions;
555 midlCharOption DefaultCharType;
556 QString DLLDataFileName; // Should be list?
557 midlErrorCheckOption EnableErrorChecks;
558 triState ErrorCheckAllocations;
559 triState ErrorCheckBounds;
560 triState ErrorCheckEnumRange;
561 triState ErrorCheckRefPointers;
562 triState ErrorCheckStubData;
563 QStringList FullIncludePath;
564 triState GenerateStublessProxies;
565 triState GenerateTypeLibrary;
566 QString HeaderFileName;
567 triState IgnoreStandardIncludePath;
568 QString InterfaceIdentifierFileName;
569 triState MkTypLibCompatible;
570 QString OutputDirectory;
571 QStringList PreprocessorDefinitions;
572 QString ProxyFileName;
573 QString RedirectOutputAndErrors;
574 midlStructMemberAlignOption StructMemberAlignment;
575 triState SuppressStartupBanner;
576 midlTargetEnvironment TargetEnvironment;
577 QString TypeLibraryName;
578 QStringList UndefinePreprocessorDefinitions;
579 triState ValidateParameters;
580 triState WarnAsError;
581 midlWarningLevelOption WarningLevel;
582 VCConfiguration* config;
583};
584
585class VCLibrarianTool : public VCToolBase
586{
587public:
588 // Functions
589 VCLibrarianTool();
590 ~VCLibrarianTool(){};
591 virtual bool parseOption( const char* option ){ return FALSE; };
592
593 // Variables
594 QStringList AdditionalDependencies;
595 QStringList AdditionalLibraryDirectories;
596 QStringList AdditionalOptions;
597 QStringList ExportNamedFunctions;
598 QStringList ForceSymbolReferences;
599 triState IgnoreAllDefaultLibraries;
600 QStringList IgnoreDefaultLibraryNames;
601 QString ModuleDefinitionFile;
602 QString OutputFile;
603 triState SuppressStartupBanner;
604};
605
606class VCCustomBuildTool : public VCToolBase
607{
608public:
609 // Functions
610 VCCustomBuildTool();
611 ~VCCustomBuildTool(){};
612 virtual bool parseOption( const char* option ){ return FALSE; };
613
614 // Variables
615 QStringList AdditionalDependencies;
616 QString CommandLine;
617 QString Description;
618 QString Outputs;
619 QString ToolName;
620 QString ToolPath;
621};
622
623class VCResourceCompilerTool : public VCToolBase
624{
625public:
626 // Functions
627 VCResourceCompilerTool();
628 ~VCResourceCompilerTool(){};
629 virtual bool parseOption( const char* option ){ return FALSE; };
630
631 // Variables
632 QStringList AdditionalIncludeDirectories;
633 QStringList AdditionalOptions;
634 enumResourceLangID Culture;
635 QStringList FullIncludePath;
636 triState IgnoreStandardIncludePath;
637 QStringList PreprocessorDefinitions;
638 QString ResourceOutputFileName;
639 linkProgressOption ShowProgress;
640 QString ToolPath;
641};
642
643class VCEventTool : public VCToolBase
644{
645protected:
646 // Functions
647 VCEventTool() : ExcludedFromBuild( unset ){};
648 ~VCEventTool(){};
649 virtual bool parseOption( const char* option ){ return FALSE; };
650
651public:
652 // Variables
653 QString CommandLine;
654 QString Description;
655 triState ExcludedFromBuild;
656 QString ToolName;
657 QString ToolPath;
658};
659
660class VCPostBuildEventTool : public VCEventTool
661{
662public:
663 VCPostBuildEventTool();
664 ~VCPostBuildEventTool(){};
665};
666
667class VCPreBuildEventTool : public VCEventTool
668{
669public:
670 VCPreBuildEventTool();
671 ~VCPreBuildEventTool(){};
672};
673
674class VCPreLinkEventTool : public VCEventTool
675{
676public:
677 VCPreLinkEventTool();
678 ~VCPreLinkEventTool(){};
679};
680
681class VCConfiguration
682{
683public:
684 // Functions
685 VCConfiguration();
686 ~VCConfiguration(){};
687
688 // Variables
689 triState ATLMinimizesCRunTimeLibraryUsage;
690 triState BuildBrowserInformation;
691 charSet CharacterSet;
692 ConfigurationTypesConfigurationType;
693 QString DeleteExtensionsOnClean;
694 QString ImportLibrary;
695 QString IntermediateDirectory;
696 QString Name;
697 QString OutputDirectory;
698 QString PrimaryOutput;
699 QString ProgramDatabase;
700 triState RegisterOutput;
701 useOfATL UseOfATL;
702 useOfMfc UseOfMfc;
703 triState WholeProgramOptimization;
704
705 // XML sub-parts
706 VCCLCompilerTool compiler;
707 VCLinkerTool linker;
708 VCLibrarianTool librarian;
709 VCCustomBuildTool custom;
710 VCMIDLTool idl;
711 VCPostBuildEventTool postBuild;
712 VCPreBuildEventTool preBuild;
713 VCPreLinkEventTool preLink;
714 VCResourceCompilerTool resource;
715};
716
717class VcprojGenerator;
718class VCFilter
719{
720public:
721 // Functions
722 VCFilter();
723 ~VCFilter(){};
724 void generateMOC( QTextStream &strm, QString str ) const;
725 void generateUIC( QTextStream &strm, const QString& str ) const;
726
727 // Variables
728 QString Name;
729 QString Filter;
730 triState ParseFiles;
731 QStringList Files;
732 VcprojGenerator*Project;
733 VCConfiguration*Config;
734 customBuildCheckCustomBuild;
735};
736
737class VCProject
738{
739public:
740 // Functions
741 VCProject();
742 ~VCProject(){};
743
744 // Variables
745 QString Name;
746 QString Version;
747 QString ProjectGUID;
748 QString SccProjectName;
749 QString SccLocalPath;
750 QString PlatformName;
751
752 // XML sub-parts
753 VCConfigurationConfiguration;
754 VCFilter SourceFiles;
755 VCFilter HeaderFiles;
756 VCFilter MOCFiles;
757 VCFilter UICFiles;
758 VCFilter FormFiles;
759 VCFilter TranslationFiles;
760 VCFilter LexYaccFiles;
761 VCFilter ResourceFiles;
762};
763
764QTextStream &operator<<( QTextStream &, const VCCLCompilerTool & );
765QTextStream &operator<<( QTextStream &, const VCLinkerTool & );
766QTextStream &operator<<( QTextStream &, const VCMIDLTool & );
767QTextStream &operator<<( QTextStream &, const VCCustomBuildTool & );
768QTextStream &operator<<( QTextStream &, const VCLibrarianTool & );
769QTextStream &operator<<( QTextStream &, const VCResourceCompilerTool & );
770QTextStream &operator<<( QTextStream &, const VCEventTool & );
771QTextStream &operator<<( QTextStream &, const VCConfiguration & );
772QTextStream &operator<<( QTextStream &, const VCFilter & );
773QTextStream &operator<<( QTextStream &, const VCProject & );
774
775#endif //__MSVC_OBJECTMODEL_H__
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
new file mode 100644
index 0000000..a2bb6e9
--- a/dev/null
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -0,0 +1,1050 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of VcprojGenerator class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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_vcproj.h"
39#include "option.h"
40#include <qdir.h>
41#include <stdlib.h>
42#include <qregexp.h>
43
44#if defined(Q_OS_WIN32)
45#include <objbase.h>
46#endif
47
48VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
49{
50}
51
52/* \internal
53 Generates a project file for the given profile.
54 Options are either a Visual Studio projectfiles, or
55 recursive projectfiles.. Maybe we can make .sln files
56 someday?
57*/
58bool VcprojGenerator::writeMakefile(QTextStream &t)
59{
60 // Check if all requirements are fullfilled
61 if(!project->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) {
62 fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n",
63 var("QMAKE_FAILED_REQUIREMENTS").latin1());
64 return TRUE;
65 }
66
67 // Generate full project file
68 if(project->first("TEMPLATE") == "vcapp" ||
69 project->first("TEMPLATE") == "vclib") {
70 debug_msg(1, "Generator: MSVC.NET: Writing project file" );
71 t << vcProject;
72 return TRUE;
73 } else if(project->first("TEMPLATE") == "vcsubdirs") { // Generate recursive project
74 debug_msg(1, "Generator: MSVC.NET: Writing solution file" );
75 writeSubDirs(t);
76 return TRUE;
77 }
78 return FALSE;
79
80}
81
82struct VcsolutionDepend {
83 QString vcprojFile, orig_target, target;
84 QStringList dependencies;
85};
86
87void VcprojGenerator::writeSubDirs(QTextStream &t)
88{
89 if(project->first("TEMPLATE") == "subdirs") {
90 writeHeader(t);
91 Win32MakefileGenerator::writeSubDirs(t);
92 return;
93 }
94
95 QPtrList<VcsolutionDepend> solution_depends;
96 solution_depends.setAutoDelete(TRUE);
97 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath();
99 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
100 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
101 if(fi.exists()) {
102 if(fi.isDir()) {
103 QString profile = (*it);
104 if(!profile.endsWith(Option::dir_sep))
105 profile += Option::dir_sep;
106 profile += fi.baseName() + ".pro";
107 subdirs.append(profile);
108 } else {
109 QMakeProject tmp_proj;
110 QString dir = fi.dirPath(), fn = fi.fileName();
111 if(!dir.isEmpty()) {
112 if(!QDir::setCurrent(dir))
113 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());
114 }
115 if(tmp_proj.read(fn, oldpwd)) {
116 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
117 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]);
118 subdirs += tmp_subdirs;
119 } else if(tmp_proj.first("TEMPLATE") == "vcapp" ||
120 tmp_proj.first("TEMPLATE") == "vclib") {
121 QString vcproj = fi.baseName() + project->first("VCPROJ_EXTENSION");
122 if(QFile::exists(vcproj) || 1) {
123 VcprojGenerator tmp_dsp(&tmp_proj);
124 tmp_dsp.setNoIO(TRUE);
125 tmp_dsp.init();
126 if(Option::debug_level) {
127 QMap<QString, QStringList> &vars = tmp_proj.variables();
128 for(QMap<QString, QStringList>::Iterator it = vars.begin();
129 it != vars.end(); ++it) {
130 if(it.key().left(1) != "." && !it.data().isEmpty())
131 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
132 it.data().join(" :: ").latin1());
133 }
134 }
135 VcsolutionDepend *newDep = new VcsolutionDepend;
136 newDep->vcprojFile = fileFixify(vcproj);
137 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET");
138 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1);
139 if(newDep->target.endsWith(".dll"))
140 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
141 if(!tmp_proj.isEmpty("FORMS"))
142 newDep->dependencies << "uic.exe";
143 {
144 QStringList where("QMAKE_LIBS");
145 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
146 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
147 for(QStringList::iterator wit = where.begin();
148 wit != where.end(); ++wit) {
149 QStringList &l = tmp_proj.variables()[(*wit)];
150 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
151 QString opt = (*it);
152 if(!opt.startsWith("/")) //Not a switch
153 newDep->dependencies << opt.section(Option::dir_sep, -1);
154 }
155 }
156 }
157 solution_depends.append(newDep);
158 }
159 }
160 }
161 QDir::setCurrent(oldpwd);
162 }
163 }
164 }
165
166 VcsolutionDepend *vc;
167 QMap<QString, int> uuids;
168 QRegExp libVersion("[0-9]{3,3}\\.lib$");
169 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) {
170 static int uuid = 666;
171 uuids.insert(vc->target, uuid);
172 if(libVersion.match(vc->target) != -1)
173 uuids.insert(vc->target.left(vc->target.length() - libVersion.matchedLength()) + ".lib",
174 uuid);
175 t << "\"" << vc->orig_target << "\" \"" << vc->vcprojFile << "\" { " << uuid << " }" << endl;
176 uuid++;
177 }
178 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) {
179 int uuid = uuids[vc->target], cnt = 0;
180 for(QStringList::iterator dit = vc->dependencies.begin(); dit != vc->dependencies.end(); ++dit) {
181 if(uuids.contains((*dit)))
182 t << uuid << "." << cnt++ << " = " << uuids[(*dit)] << endl;
183 }
184 }
185}
186
187// ------------------------------------------------------------------------------------------------
188// ------------------------------------------------------------------------------------------------
189
190void VcprojGenerator::init()
191{
192 if( init_flag )
193 return;
194 if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs
195 init_flag = TRUE;
196 return;
197 }
198
199 debug_msg(1, "Generator: MSVC.NET: Initializing variables" );
200
201/*
202 // Once to be nice and clean code...
203 // Wouldn't life be great?
204
205 // Are we building Qt?
206 bool is_qt =
207 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
208 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
209
210 // Are we using Qt?
211 bool isQtActive = project->isActiveConfig("qt");
212
213 if ( isQtActive ) {
214 project->variables()["CONFIG"] += "moc";
215 project->variables()["CONFIG"] += "windows";
216 project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"];
217 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
218
219 if( projectTarget == SharedLib )
220 project->variables()["DEFINES"] += "QT_DLL";
221
222 if( project->isActiveConfig("accessibility" ) )
223 project->variables()["DEFINES"] += "QT_ACCESSIBILITY_SUPPORT";
224
225 if ( project->isActiveConfig("plugin")) {
226 project->variables()["DEFINES"] += "QT_PLUGIN";
227 project->variables()["CONFIG"] += "dll";
228 }
229
230 if( project->isActiveConfig("thread") ) {
231 project->variables()["DEFINES"] += "QT_THREAD_SUPPORT";
232 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
233 } else {
234 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
235 }
236 }
237
238 if ( project->isActiveConfig("opengl") ) {
239 project->variables()["CONFIG"] += "windows"; // <-- Also in 'qt' above
240 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
241 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
242
243 }
244*/
245 initOld(); // Currently calling old DSP code to set variables. CLEAN UP!
246
247 // Figure out what we're trying to build
248 if ( project->first("TEMPLATE") == "vcapp" ) {
249 projectTarget = Application;
250 } else if ( project->first("TEMPLATE") == "vclib") {
251 if ( project->isActiveConfig( "staticlib" ) )
252 projectTarget = StaticLib;
253 else
254 projectTarget = SharedLib;
255 }
256 initProject(); // Fills the whole project with proper data
257}
258
259void VcprojGenerator::initProject()
260{
261 // Initialize XML sub elements
262 // - Do this first since project elements may need
263 // - to know of certain configuration options
264 initConfiguration();
265 initSourceFiles();
266 initHeaderFiles();
267 initMOCFiles();
268 initUICFiles();
269 initFormsFiles();
270 initTranslationFiles();
271 initLexYaccFiles();
272 initResourceFiles();
273
274 // Own elements -----------------------------
275 vcProject.Name = project->first("QMAKE_ORIG_TARGET");
276 vcProject.Version = "7.00";
277 vcProject.PlatformName = ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
278 // These are not used by Qt, but may be used by customers
279 vcProject.SccProjectName = project->first("SCCPROJECTNAME");
280 vcProject.SccLocalPath = project->first("SCCLOCALPATH");
281}
282
283void VcprojGenerator::initConfiguration()
284{
285 // Initialize XML sub elements
286 // - Do this first since main configuration elements may need
287 // - to know of certain compiler/linker options
288 initCompilerTool();
289 if ( projectTarget == StaticLib )
290 initLibrarianTool();
291 else
292 initLinkerTool();
293 initIDLTool();
294
295 // Own elements -----------------------------
296 QString temp = project->first("BuildBrowserInformation");
297 switch ( projectTarget ) {
298 case SharedLib:
299 vcProject.Configuration.ConfigurationType = typeDynamicLibrary;
300 break;
301 case StaticLib:
302 vcProject.Configuration.ConfigurationType = typeStaticLibrary;
303 break;
304 case Application:
305 default:
306 vcProject.Configuration.ConfigurationType = typeApplication;
307 break;
308 }
309 vcProject.Configuration.Name = ( project->isActiveConfig( "release" ) ? "Release|" : "Debug|" );
310 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
311 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True );
312 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? unset : temp.toShort() );
313 temp = project->first("CharacterSet");
314 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? charSetNotSet : temp.toShort() );
315 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
316 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary;
317 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR");
318// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR");
319 vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp );
320 vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput");
321 vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization;
322 temp = project->first("UseOfATL");
323 if ( !temp.isEmpty() )
324 vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() );
325 temp = project->first("UseOfMfc");
326 if ( !temp.isEmpty() )
327 vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() );
328
329 // Configuration does not need parameters from
330 // these sub XML items;
331 initCustomBuildTool();
332 initPreBuildEventTools();
333 initPostBuildEventTools();
334 initPreLinkEventTools();
335}
336
337void VcprojGenerator::initCompilerTool()
338{
339 QString placement = project->first("OBJECTS_DIR");
340 if ( placement.isEmpty() )
341 placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\";
342
343 vcProject.Configuration.compiler.AssemblerListingLocation = placement ;
344 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ;
345 vcProject.Configuration.compiler.ObjectFile = placement ;
346 vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch";
347
348 if ( project->isActiveConfig("debug") ){
349 // Debug version
350 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
351 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] );
352 if ( project->isActiveConfig("thread") ) {
353 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
354 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] );
355 else
356 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] );
357 } else {
358 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] );
359 }
360 } else {
361 // Release version
362 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
363 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] );
364 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
365 if ( project->isActiveConfig("thread") ) {
366 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
367 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
368 else
369 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] );
370 } else {
371 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] );
372 }
373 }
374
375 // Common for both release and debug
376 if ( project->isActiveConfig("warn_off") )
377 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] );
378 else
379 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] );
380 if ( project->isActiveConfig("windows") )
381 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"];
382
383 // Can this be set for ALL configs?
384 // If so, use qmake.conf!
385 if ( projectTarget == SharedLib )
386 vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS";
387
388 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"];
389 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"];
390 vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] );
391}
392
393void VcprojGenerator::initLibrarianTool()
394{
395 vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" );
396 if( vcProject.Configuration.librarian.OutputFile.isEmpty() )
397 vcProject.Configuration.librarian.OutputFile = ".\\";
398
399 if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") )
400 vcProject.Configuration.librarian.OutputFile += '\\';
401
402 vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET");
403}
404
405void VcprojGenerator::initLinkerTool()
406{
407 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] );
408 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"];
409
410 switch ( projectTarget ) {
411 case Application:
412 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" );
413 break;
414 case SharedLib:
415 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] );
416 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" );
417 break;
418 }
419
420 if( vcProject.Configuration.linker.OutputFile.isEmpty() )
421 vcProject.Configuration.linker.OutputFile = ".\\";
422
423 if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") )
424 vcProject.Configuration.linker.OutputFile += '\\';
425
426 vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET");
427 vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb";
428
429 if ( project->isActiveConfig("debug") ){
430 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] );
431 } else {
432 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] );
433 }
434
435 if ( project->isActiveConfig("dll") ){
436 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] );
437 }
438
439 if ( project->isActiveConfig("console") ){
440 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] );
441 } else {
442 vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] );
443 }
444
445}
446
447void VcprojGenerator::initIDLTool()
448{
449}
450
451void VcprojGenerator::initCustomBuildTool()
452{
453}
454
455void VcprojGenerator::initPreBuildEventTools()
456{
457 QString collectionName = project->first("QMAKE_IMAGE_COLLECTION");
458 if( !collectionName.isEmpty() ) {
459 QStringList& list = project->variables()["IMAGES"];
460 vcProject.Configuration.preBuild.Description = "Generate imagecollection";
461 //vcProject.Configuration.preBuild.AdditionalDependencies += list;
462 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " " + list.join(" ") + " -o " + collectionName;
463 //vcProject.Configuration.preBuild.Outputs = collectionName;
464
465 }
466}
467
468void VcprojGenerator::initPostBuildEventTools()
469{
470 if( project->isActiveConfig( "activeqt" ) ) {
471 QString name = project->first( "QMAKE_ORIG_TARGET" );
472 QString nameext = project->first( "TARGET" );
473 QString objdir = project->first( "OBJECTS_DIR" );
474 QString idc = project->first( "QMAKE_IDC" );
475
476 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server...";
477
478 if( project->isActiveConfig( "dll" ) ) { // In process
479 vcProject.Configuration.postBuild.CommandLine =
480 // call idc to generate .idl file from .dll
481 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
482 // call midl to create implementations of the .idl file
483 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir +
484 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
485 objdir + "dump.midl &amp;&amp; " +
486 // call idc to replace tlb...
487 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
488 // register server
489 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver";
490 } else { // out of process
491 vcProject.Configuration.postBuild.CommandLine =
492 // call application to dump idl
493 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
494 // call midl to create implementations of the .idl file
495 project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir +
496 "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " +
497 objdir + "dump.midl &amp;&amp; " +
498 // call idc to replace tlb...
499 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb &amp;&amp; " +
500 // call app to register
501 vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver";
502 }
503 }
504}
505
506void VcprojGenerator::initPreLinkEventTools()
507{
508}
509
510void VcprojGenerator::initSourceFiles()
511{
512 vcProject.SourceFiles.Name = "Source Files";
513 vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat";
514 vcProject.SourceFiles.Files += project->variables()["SOURCES"];
515 vcProject.SourceFiles.Files.sort();
516 vcProject.SourceFiles.Project = this;
517 vcProject.SourceFiles.Config = &(vcProject.Configuration);
518 vcProject.SourceFiles.CustomBuild = none;
519}
520
521void VcprojGenerator::initHeaderFiles()
522{
523 vcProject.HeaderFiles.Name = "Header Files";
524 vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl";
525 vcProject.HeaderFiles.Files += project->variables()["HEADERS"];
526 vcProject.HeaderFiles.Files.sort();
527 vcProject.HeaderFiles.Project = this;
528 vcProject.HeaderFiles.Config = &(vcProject.Configuration);
529 vcProject.HeaderFiles.CustomBuild = moc;
530}
531
532void VcprojGenerator::initMOCFiles()
533{
534 vcProject.MOCFiles.Name = "Generated MOC Files";
535 vcProject.MOCFiles.Filter = "cpp;c;cxx;moc";
536 vcProject.MOCFiles.Files += project->variables()["SRCMOC"];
537 vcProject.MOCFiles.Files.sort();
538 vcProject.MOCFiles.Project = this;
539 vcProject.MOCFiles.Config = &(vcProject.Configuration);
540 vcProject.MOCFiles.CustomBuild = moc;
541}
542
543void VcprojGenerator::initUICFiles()
544{
545 vcProject.UICFiles.Name = "Generated UI Files";
546 vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;";
547 vcProject.UICFiles.Project = this;
548 vcProject.UICFiles.Files += project->variables()["UICDECLS"];
549 vcProject.UICFiles.Files += project->variables()["UICIMPLS"];
550 vcProject.UICFiles.Files.sort();
551 vcProject.UICFiles.Config = &(vcProject.Configuration);
552 vcProject.UICFiles.CustomBuild = none;
553}
554
555void VcprojGenerator::initFormsFiles()
556{
557 vcProject.FormFiles.Name = "Forms";
558 vcProject.FormFiles.ParseFiles = _False;
559 vcProject.FormFiles.Filter = "ui";
560 vcProject.FormFiles.Files += project->variables()["FORMS"];
561 vcProject.FormFiles.Files.sort();
562 vcProject.FormFiles.Project = this;
563 vcProject.FormFiles.Config = &(vcProject.Configuration);
564 vcProject.FormFiles.CustomBuild = uic;
565}
566
567void VcprojGenerator::initTranslationFiles()
568{
569 vcProject.TranslationFiles.Name = "Translations Files";
570 vcProject.TranslationFiles.ParseFiles = _False;
571 vcProject.TranslationFiles.Filter = "ts";
572 vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"];
573 vcProject.TranslationFiles.Files.sort();
574 vcProject.TranslationFiles.Project = this;
575 vcProject.TranslationFiles.Config = &(vcProject.Configuration);
576 vcProject.TranslationFiles.CustomBuild = none;
577}
578
579void VcprojGenerator::initLexYaccFiles()
580{
581 vcProject.LexYaccFiles.Name = "Lex / Yacc Files";
582 vcProject.LexYaccFiles.ParseFiles = _False;
583 vcProject.LexYaccFiles.Filter = "l;y";
584 vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"];
585 vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"];
586 vcProject.LexYaccFiles.Files.sort();
587 vcProject.LexYaccFiles.Project = this;
588 vcProject.LexYaccFiles.CustomBuild = lexyacc;
589}
590
591void VcprojGenerator::initResourceFiles()
592{
593 vcProject.ResourceFiles.Name = "Resources";
594 vcProject.ResourceFiles.ParseFiles = _False;
595 vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts";
596 vcProject.ResourceFiles.Files += project->variables()["RC_FILE"];
597 vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"];
598 vcProject.ResourceFiles.Files += project->variables()["IMAGES"];
599 vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"];
600 vcProject.ResourceFiles.Files.sort();
601 vcProject.ResourceFiles.Project = this;
602 vcProject.ResourceFiles.CustomBuild = none;
603}
604
605/*
606// $$MSVCPROJ_IDLSOURCES ---------------------------------------------
607void VcprojGenerator::writeIDLs( QTextStream &t )
608{
609 QStringList &l = project->variables()["MSVCPROJ_IDLSOURCES"];
610 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
611 t << "# Begin Source File" << endl << endl;
612 t << "SOURCE=" << (*it) << endl;
613 t << "# PROP Exclude_From_Build 1" << endl;
614 t << "# End Source File" << endl << endl;
615 }
616 debug_msg(3, "Generator: MSVC.NET: Added IDLs" );
617}
618*/
619
620/* \internal
621 Sets up all needed variables from the environment and all the different caches and .conf files
622*/
623
624void VcprojGenerator::initOld()
625{
626 if( init_flag )
627 return;
628
629 init_flag = TRUE;
630 QStringList::Iterator it;
631
632 // this should probably not be here, but I'm using it to wrap the .t files
633 if(project->first("TEMPLATE") == "vcapp" )
634 project->variables()["QMAKE_APP_FLAG"].append("1");
635 else if(project->first("TEMPLATE") == "vclib")
636 project->variables()["QMAKE_LIB_FLAG"].append("1");
637 if ( project->variables()["QMAKESPEC"].isEmpty() )
638 project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") );
639
640 bool is_qt =
641 ( project->first("TARGET") == "qt"QTDLL_POSTFIX ||
642 project->first("TARGET") == "qt-mt"QTDLL_POSTFIX );
643
644 QStringList &configs = project->variables()["CONFIG"];
645
646 if ( project->isActiveConfig( "shared" ) )
647 project->variables()["DEFINES"].append( "QT_DLL" );
648
649 if ( project->isActiveConfig( "qt_dll" ) &&
650 configs.findIndex("qt") == -1 )
651 configs.append("qt");
652
653 if ( project->isActiveConfig( "qt" ) ) {
654 if ( project->isActiveConfig( "plugin" ) ) {
655 project->variables()["CONFIG"].append( "dll" );
656 project->variables()["DEFINES"].append( "QT_PLUGIN" );
657 }
658 if ( ( project->variables()["DEFINES"].findIndex( "QT_NODLL" ) == -1 ) &&
659 (( project->variables()["DEFINES"].findIndex( "QT_MAKEDLL" ) != -1 ||
660 project->variables()["DEFINES"].findIndex( "QT_DLL" ) != -1 ) ||
661 ( getenv( "QT_DLL" ) && !getenv( "QT_NODLL" ))) ) {
662 project->variables()["QMAKE_QT_DLL"].append( "1" );
663 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() )
664 project->variables()["CONFIG"].append( "dll" );
665 }
666 }
667
668 // If we are a dll, then we cannot be a staticlib at the same time...
669 if ( project->isActiveConfig( "dll" ) || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
670 project->variables()["CONFIG"].remove( "staticlib" );
671 project->variables()["QMAKE_APP_OR_DLL"].append( "1" );
672 } else {
673 project->variables()["CONFIG"].append( "staticlib" );
674 }
675
676 // If we need 'qt' and/or 'opengl', then we need windows and not console
677 if ( project->isActiveConfig( "qt" ) || project->isActiveConfig( "opengl" ) ) {
678 project->variables()["CONFIG"].append( "windows" );
679 }
680
681 // Decode version, and add it to $$MSVCPROJ_VERSION --------------
682 if ( !project->variables()["VERSION"].isEmpty() ) {
683 QString version = project->variables()["VERSION"][0];
684 int firstDot = version.find( "." );
685 QString major = version.left( firstDot );
686 QString minor = version.right( version.length() - firstDot - 1 );
687 minor.replace( QRegExp( "\\." ), "" );
688 project->variables()["MSVCPROJ_VERSION"].append( "/VERSION:" + major + "." + minor );
689 }
690
691 // QT ------------------------------------------------------------
692 if ( project->isActiveConfig("qt") ) {
693 project->variables()["CONFIG"].append("moc");
694 project->variables()["INCLUDEPATH"] +=project->variables()["QMAKE_INCDIR_QT"];
695 project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"];
696
697 if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
698 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
699 project->variables()["DEFINES"].append("QT_MAKEDLL");
700 project->variables()["QMAKE_LFLAGS"].append("/BASE:0x39D00000");
701 }
702 } else {
703 if(project->isActiveConfig("thread"))
704 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"];
705 else
706 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"];
707 if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) {
708 int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt");
709 if( hver==-1 ) {
710 hver = findHighestVersion( project->first("QMAKE_LIBDIR_QT"), "qt-mt" );
711 }
712
713 if(hver != -1) {
714 QString ver;
715 ver.sprintf("qt%s" QTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver);
716 QStringList &libs = project->variables()["QMAKE_LIBS"];
717 for(QStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit)
718 (*libit).replace(QRegExp("qt(-mt)?\\.lib"), ver);
719 }
720 }
721 if ( project->isActiveConfig( "activeqt" ) ) {
722 project->variables().remove("QMAKE_LIBS_QT_ENTRY");
723 project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib";
724 if ( project->isActiveConfig( "dll" ) ) {
725 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"];
726 project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE"));
727 }
728 }
729 if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) {
730 project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"];
731 }
732 }
733 }
734
735 // Set target directories ----------------------------------------
736 // if ( !project->first("OBJECTS_DIR").isEmpty() )
737 //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->first("OBJECTS_DIR");
738 // else
739 //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->isActiveConfig( "release" )?"Release":"Debug";
740 // if ( !project->first("DESTDIR").isEmpty() )
741 //project->variables()["MSVCPROJ_TARGETDIR"] = project->first("DESTDIR");
742 // else
743 //project->variables()["MSVCPROJ_TARGETDIR"] = project->isActiveConfig( "release" )?"Release":"Debug";
744
745 // OPENGL --------------------------------------------------------
746 if ( project->isActiveConfig("opengl") ) {
747 project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"];
748 project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"];
749 }
750
751 // THREAD --------------------------------------------------------
752 if ( project->isActiveConfig("thread") ) {
753 if(project->isActiveConfig("qt"))
754 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" );
755 if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt
756 && project->first("TARGET") != "qtmain" )
757 project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:libc");
758 }
759
760 // ACCESSIBILITY -------------------------------------------------
761 if(project->isActiveConfig("qt")) {
762 if ( project->isActiveConfig("accessibility" ) )
763 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT");
764 if ( project->isActiveConfig("tablet") )
765 project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT");
766 }
767
768 // DLL -----------------------------------------------------------
769 if ( project->isActiveConfig("dll") ) {
770 if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) {
771 QString ver_xyz(project->first("VERSION"));
772 ver_xyz.replace(QRegExp("\\."), "");
773 project->variables()["TARGET_EXT"].append(ver_xyz + ".dll");
774 } else {
775 project->variables()["TARGET_EXT"].append(".dll");
776 }
777 }
778 // EXE / LIB -----------------------------------------------------
779 else {
780 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() )
781 project->variables()["TARGET_EXT"].append(".exe");
782 else
783 project->variables()["TARGET_EXT"].append(".lib");
784 }
785
786 project->variables()["MSVCPROJ_VER"] = "7.00";
787 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI";
788
789 // INCREMENTAL:NO ------------------------------------------------
790 if(!project->isActiveConfig("incremental")) {
791 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no"));
792 if ( is_qt )
793 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi";
794 }
795
796 // MOC -----------------------------------------------------------
797 if ( project->isActiveConfig("moc") )
798 setMocAware(TRUE);
799
800
801 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
802
803 // Run through all variables containing filepaths, and -----------
804 // slash-slosh them correctly depending on current OS -----------
805 project->variables()["QMAKE_FILETAGS"] += QStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH");
806 QStringList &l = project->variables()["QMAKE_FILETAGS"];
807 for(it = l.begin(); it != l.end(); ++it) {
808 QStringList &gdmf = project->variables()[(*it)];
809 for(QStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner)
810 (*inner) = Option::fixPathToTargetOS((*inner), FALSE);
811 }
812
813 // Get filename w/o extention -----------------------------------
814 QString msvcproj_project = "";
815 QString targetfilename = "";
816 if ( project->variables()["TARGET"].count() ) {
817 msvcproj_project = project->variables()["TARGET"].first();
818 targetfilename = msvcproj_project;
819 }
820
821 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------
822 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
823
824 // TARGET (add extention to $$TARGET) ----------------------------
825 project->variables()["TARGET"].first() += project->first("TARGET_EXT");
826
827 // Init base class too -------------------------------------------
828 MakefileGenerator::init();
829
830
831 if ( msvcproj_project.isEmpty() )
832 msvcproj_project = Option::output.name();
833
834 msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 );
835 msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) );
836 msvcproj_project.replace(QRegExp("-"), "");
837
838 project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project);
839 QStringList &proj = project->variables()["MSVCPROJ_PROJECT"];
840
841 for(it = proj.begin(); it != proj.end(); ++it)
842 (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");
843
844 // SUBSYSTEM -----------------------------------------------------
845 if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) {
846 project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) );
847 if ( project->isActiveConfig("console") ) {
848 project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE");
849 project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE");
850 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103");
851 project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE");
852 } else {
853 project->variables()["MSVCPROJ_CONSOLE"].clear();
854 project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS");
855 project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101");
856 project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS");
857 }
858 } else {
859 if ( project->isActiveConfig("dll") ) {
860 project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) );
861 } else {
862 project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) );
863 }
864 }
865
866 // $$QMAKE.. -> $$MSVCPROJ.. -------------------------------------
867 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"];
868 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
869 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
870 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() )
871 project->variables()["MSVCPROJ_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:"," /LIBPATH:",""));
872 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
873 // We don't use this... Direct manipulation of compiler object
874 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
875 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ",""));
876 QStringList &incs = project->variables()["INCLUDEPATH"];
877 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
878 QString inc = (*incit);
879 inc.replace(QRegExp("\""), "");
880 project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc );
881 }
882 project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir());
883
884 QString dest;
885 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET");
886 if ( !project->variables()["DESTDIR"].isEmpty() ) {
887 project->variables()["TARGET"].first().prepend(project->first("DESTDIR"));
888 Option::fixPathToTargetOS(project->first("TARGET"));
889 dest = project->first("TARGET");
890 if ( project->first("TARGET").startsWith("$(QTDIR)") )
891 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") );
892 project->variables()["MSVCPROJ_TARGET"].append(
893 QString("/OUT:") + dest );
894 if ( project->isActiveConfig("dll") ) {
895 QString imp = dest;
896 imp.replace(QRegExp("\\.dll"), ".lib");
897 project->variables()["MSVCPROJ_LIBOPTIONS"] += (QString("/IMPLIB:") + imp );
898 }
899 }
900
901 // DLL COPY ------------------------------------------------------
902 if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) {
903 QStringList dlldirs = project->variables()["DLLDESTDIR"];
904 QString copydll = "# Begin Special Build Tool\n"
905 "TargetPath=" + dest + "\n"
906 "SOURCE=$(InputPath)\n"
907 "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n"
908 "PostBuild_Cmds=";
909
910 for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) {
911 copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t";
912 }
913
914 copydll += "\n# End Special Build Tool";
915 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll );
916 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll );
917 }
918
919 // ACTIVEQT ------------------------------------------------------
920 if ( project->isActiveConfig("activeqt") ) {
921 QString idl = project->variables()["QMAKE_IDL"].first();
922 QString idc = project->variables()["QMAKE_IDC"].first();
923 QString version = project->variables()["VERSION"].first();
924 if ( version.isEmpty() )
925 version = "1.0";
926
927 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" );
928 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" );
929 project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" );
930 if ( project->isActiveConfig( "dll" ) ) {
931 QString regcmd = "# Begin Special Build Tool\n"
932 "TargetPath=" + targetfilename + "\n"
933 "SOURCE=$(InputPath)\n"
934 "PostBuild_Desc=Finalizing ActiveQt server...\n"
935 "PostBuild_Cmds=" +
936 idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version +
937 "\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"
938 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"
939 "\tregsvr32 /s %1\n"
940 "# End Special Build Tool";
941
942 QString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first();
943 project->variables()["MSVCPROJ_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) );
944
945 executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
946 project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
947 } else {
948 QString regcmd = "# Begin Special Build Tool\n"
949 "TargetPath=" + targetfilename + "\n"
950 "SOURCE=$(InputPath)\n"
951 "PostBuild_Desc=Finalizing ActiveQt server...\n"
952 "PostBuild_Cmds="
953 "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version +
954 "\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"
955 "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb"
956 "\t%1 -regserver\n"
957 "# End Special Build Tool";
958
959 QString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first();
960 project->variables()["MSVCPROJ_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) );
961
962 executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first();
963 project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) );
964 }
965
966 }
967
968 // FORMS ---------------------------------------------------------
969 QStringList &list = project->variables()["FORMS"];
970 for( it = list.begin(); it != list.end(); ++it ) {
971 if ( QFile::exists( *it + ".h" ) )
972 project->variables()["SOURCES"].append( *it + ".h" );
973 }
974
975 project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS";
976
977 // Verbose output if "-d -d"...
978 outputVariables();
979}
980
981// ------------------------------------------------------------------------------------------------
982// ------------------------------------------------------------------------------------------------
983
984bool VcprojGenerator::openOutput(QFile &file) const
985{
986 QString outdir;
987 if(!file.name().isEmpty()) {
988 QFileInfo fi(file);
989 if(fi.isDir())
990 outdir = file.name() + QDir::separator();
991 }
992 if(!outdir.isEmpty() || file.name().isEmpty()) {
993 QString ext = project->first("VCPROJ_EXTENSION");
994 if(project->first("TEMPLATE") == "vcsubdirs")
995 ext = project->first("VCSOLUTION_EXTENSION");
996 file.setName(outdir + project->first("TARGET") + ext);
997 }
998 if(QDir::isRelativePath(file.name())) {
999 QString ofile;
1000 ofile = file.name();
1001 int slashfind = ofile.findRev('\\');
1002 if (slashfind == -1) {
1003 ofile = ofile.replace("-", "_");
1004 } else {
1005 int hypenfind = ofile.find('-', slashfind);
1006 while (hypenfind != -1 && slashfind < hypenfind) {
1007 ofile = ofile.replace(hypenfind, 1, "_");
1008 hypenfind = ofile.find('-', hypenfind + 1);
1009 }
1010 }
1011 file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile));
1012 }
1013 return Win32MakefileGenerator::openOutput(file);
1014}
1015
1016QString VcprojGenerator::findTemplate(QString file)
1017{
1018 QString ret;
1019 if(!QFile::exists((ret = file)) &&
1020 !QFile::exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&
1021 !QFile::exists((ret = QString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) &&
1022 !QFile::exists((ret = (QString(getenv("HOME")) + "/.tmake/" + file))))
1023 return "";
1024 debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() );
1025 return ret;
1026}
1027
1028
1029void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l)
1030{
1031 if(var == "QMAKE_PRL_DEFINES") {
1032 QStringList &out = project->variables()["MSVCPROJ_DEFINES"];
1033 for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
1034 if(out.findIndex((*it)) == -1)
1035 out.append((" /D " + *it ));
1036 }
1037 } else {
1038 MakefileGenerator::processPrlVariable(var, l);
1039 }
1040}
1041
1042void VcprojGenerator::outputVariables()
1043{
1044#if 0
1045 debug_msg(3, "Generator: MSVC.NET: List of current variables:" );
1046 for ( QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) {
1047 debug_msg(3, "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() );
1048 }
1049#endif
1050}
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
new file mode 100644
index 0000000..583b164
--- a/dev/null
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -0,0 +1,129 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of VcprojGenerator class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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#ifndef __VCPROJMAKE_H__
38#define __VCPROJMAKE_H__
39
40#include "winmakefile.h"
41#include "msvc_objectmodel.h"
42
43enum target {
44 Application,
45 SharedLib,
46 StaticLib
47};
48
49class VcprojGenerator : public Win32MakefileGenerator
50{
51 bool init_flag;
52 bool writeVcprojParts(QTextStream &);
53
54 bool writeMakefile(QTextStream &);
55 virtual void writeSubDirs(QTextStream &t);
56 QString findTemplate(QString file);
57 void init();
58
59public:
60 VcprojGenerator(QMakeProject *p);
61 ~VcprojGenerator();
62
63 QString defaultMakefile() const;
64 virtual bool doDepends() const { return FALSE; } //never necesary
65
66protected:
67 virtual bool openOutput(QFile &file) const;
68 virtual void processPrlVariable(const QString &, const QStringList &);
69 virtual bool findLibraries();
70 virtual void outputVariables();
71
72 void initOld();
73 void initProject();
74 void initConfiguration();
75 void initCompilerTool();
76 void initLinkerTool();
77 void initLibrarianTool();
78 void initIDLTool();
79 void initCustomBuildTool();
80 void initPreBuildEventTools();
81 void initPostBuildEventTools();
82 void initPreLinkEventTools();
83 void initSourceFiles();
84 void initHeaderFiles();
85 void initMOCFiles();
86 void initUICFiles();
87 void initFormsFiles();
88 void initTranslationFiles();
89 void initLexYaccFiles();
90 void initResourceFiles();
91
92 /*
93 void writeGuid( QTextStream &t );
94 void writeAdditionalOptions( QTextStream &t );
95 void writeHeaders( QTextStream &t );
96 void writeSources( QTextStream &t );
97 void writeMocs( QTextStream &t );
98 void writeLexs( QTextStream &t );
99 void writeYaccs( QTextStream &t );
100 void writePictures( QTextStream &t );
101 void writeImages( QTextStream &t );
102 void writeIDLs( QTextStream &t );
103
104 void writeForms( QTextStream &t );
105 void writeFormsSourceHeaders( QString &variable, QTextStream &t );
106 void writeTranslations( QTextStream &t );
107 void writeStrippedTranslations( QTextStream &t );
108 */
109
110 VCProject vcProject;
111 target projectTarget;
112
113 friend class VCFilter;
114};
115
116inline VcprojGenerator::~VcprojGenerator()
117{ }
118
119inline QString VcprojGenerator::defaultMakefile() const
120{
121 return project->first("TARGET") + project->first("VCPROJ_EXTENSION");
122}
123
124inline bool VcprojGenerator::findLibraries()
125{
126 return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS");
127}
128
129#endif /* __VCPROJMAKE_H__ */
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
new file mode 100644
index 0000000..a07c921
--- a/dev/null
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -0,0 +1,360 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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 "winmakefile.h"
39#include "option.h"
40#include "project.h"
41#include <qtextstream.h>
42#include <qstring.h>
43#include <qdict.h>
44#include <qregexp.h>
45#include <qstringlist.h>
46#include <qdir.h>
47
48
49Win32MakefileGenerator::Win32MakefileGenerator(QMakeProject *p) : MakefileGenerator(p)
50{
51
52}
53
54
55struct SubDir
56{
57 QString directory, profile, target, makefile;
58};
59
60void
61Win32MakefileGenerator::writeSubDirs(QTextStream &t)
62{
63 QPtrList<SubDir> subdirs;
64 {
65 QStringList subdirs_in = project->variables()["SUBDIRS"];
66 for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) {
67 QString file = (*it);
68 file = fileFixify(file);
69 SubDir *sd = new SubDir;
70 subdirs.append(sd);
71 sd->makefile = "$(MAKEFILE)";
72 if((*it).right(4) == ".pro") {
73 int slsh = file.findRev(Option::dir_sep);
74 if(slsh != -1) {
75 sd->directory = file.left(slsh+1);
76 sd->profile = file.mid(slsh+1);
77 } else {
78 sd->profile = file;
79 }
80 } else {
81 sd->directory = file;
82 }
83 while(sd->directory.right(1) == Option::dir_sep)
84 sd->directory = sd->directory.left(sd->directory.length() - 1);
85 if(!sd->profile.isEmpty()) {
86 QString basename = sd->directory;
87 int new_slsh = basename.findRev(Option::dir_sep);
88 if(new_slsh != -1)
89 basename = basename.mid(new_slsh+1);
90 if(sd->profile != basename + ".pro")
91 sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro
92 }
93 sd->target = "sub-" + (*it);
94 sd->target.replace('/', '-');
95 sd->target.replace('.', '_');
96 }
97 }
98 QPtrListIterator<SubDir> it(subdirs);
99
100 if(!project->isEmpty("MAKEFILE"))
101 t << "MAKEFILE=" << var("MAKEFILE") << endl;
102 t << "QMAKE =" << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl;
103 t << "SUBTARGETS= ";
104 for( it.toFirst(); it.current(); ++it)
105 t << " \\\n\t\t" << it.current()->target;
106 t << endl << endl;
107 t << "all: qmake_all $(SUBTARGETS)" << endl << endl;
108
109 for( it.toFirst(); it.current(); ++it) {
110 bool have_dir = !(*it)->directory.isEmpty();
111
112 //make the makefile
113 QString mkfile = (*it)->makefile;
114 if(have_dir)
115 mkfile.prepend((*it)->directory + Option::dir_sep);
116 t << mkfile << ":";
117 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
118 t << " FORCE";
119 if(have_dir)
120 t << "\n\t" << "cd " << (*it)->directory;
121 t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs();
122 if((*it)->makefile != "$(MAKEFILE)")
123 t << " -o " << (*it)->makefile;
124 if(have_dir) {
125 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
126 t << "\n\t" << "@cd ..";
127 for(int i = 1; i < subLevels; i++ )
128 t << Option::dir_sep << "..";
129 }
130 t << endl;
131
132 //now actually build
133 t << (*it)->target << ": " << mkfile;
134 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
135 t << " FORCE";
136 if(have_dir)
137 t << "\n\t" << "cd " << (*it)->directory;
138 t << "\n\t" << "$(MAKE)";
139 if((*it)->makefile != "$(MAKEFILE)")
140 t << " -f " << (*it)->makefile;
141 if(have_dir) {
142 int subLevels = it.current()->directory.contains(Option::dir_sep) + 1;
143 t << "\n\t" << "@cd ..";
144 for(int i = 1; i < subLevels; i++ )
145 t << Option::dir_sep << "..";
146 }
147 t << endl << endl;
148 }
149
150 if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1)
151 project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all");
152 writeMakeQmake(t);
153
154 t << "qmake_all:";
155 if ( !subdirs.isEmpty() ) {
156 for( it.toFirst(); it.current(); ++it) {
157 QString subdir = (*it)->directory;
158 int subLevels = subdir.contains(Option::dir_sep) + 1;
159 t << "\n\t"
160 << "cd " << subdir << "\n\t";
161 int lastSlash = subdir.findRev(Option::dir_sep);
162 if(lastSlash != -1)
163 subdir = subdir.mid( lastSlash + 1 );
164 t << "$(QMAKE) " << subdir << ".pro"
165 << (!project->isEmpty("MAKEFILE") ? QString(" -o ") + var("MAKEFILE") : QString(""))
166 << " " << buildArgs() << "\n\t"
167 << "@cd ..";
168 for(int i = 1; i < subLevels; i++ )
169 t << Option::dir_sep << "..";
170 }
171 } else {
172 // Borland make does not like empty an empty command section, so insert
173 // a dummy command.
174 t << "\n\t" << "@cd .";
175 }
176 t << endl << endl;
177
178 QString targs[] = { QString("clean"), QString("install"), QString("mocclean"), QString::null };
179 for(int x = 0; targs[x] != QString::null; x++) {
180 t << targs[x] << ": qmake_all";
181 if(targs[x] == "clean")
182 t << varGlue("QMAKE_CLEAN","\n\t-del ","\n\t-del ", "");
183 if (!subdirs.isEmpty()) {
184 for( it.toFirst(); it.current(); ++it) {
185 int subLevels = (*it)->directory.contains(Option::dir_sep) + 1;
186 bool have_dir = !(*it)->directory.isEmpty();
187 if(have_dir)
188 t << "\n\t" << "cd " << (*it)->directory;
189 QString in_file;
190 if((*it)->makefile != "$(MAKEFILE)")
191 in_file = " -f " + (*it)->makefile;
192 t << "\n\t" << "$(MAKE) " << in_file << " " << targs[x];
193 if(have_dir) {
194 t << "\n\t" << "@cd ..";
195 for(int i = 1; i < subLevels; i++ )
196 t << Option::dir_sep << "..";
197 }
198 }
199 } else {
200 // Borland make does not like empty an empty command section, so
201 // insert a dummy command.
202 t << "\n\t" << "@cd .";
203 }
204 t << endl << endl;
205 }
206
207 if(project->variables()["QMAKE_NOFORCE"].isEmpty())
208 t << "FORCE:" << endl << endl;
209}
210
211
212int
213Win32MakefileGenerator::findHighestVersion(const QString &d, const
214 QString &stem)
215{
216 if(!QFile::exists(Option::fixPathToLocalOS(d)))
217 return -1;
218 if(!project->variables()["QMAKE_" + stem.upper() +
219 "_VERSION_OVERRIDE"].isEmpty())
220 return project->variables()["QMAKE_" + stem.upper() +
221 "_VERSION_OVERRIDE"].first().toInt();
222 QString bd = d;
223 fixEnvVariables(bd);
224 QDir dir(bd);
225 int biggest=-1;
226 QStringList entries = dir.entryList();
227 QRegExp regx( "(" + stem + "([0-9]*)).lib", FALSE );
228 for(QStringList::Iterator it = entries.begin(); it != entries.end();
229 ++it) {
230 if(regx.exactMatch((*it)))
231 biggest = QMAX(biggest, (regx.cap(1) == stem ||
232 regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt());
233 }
234 return biggest;
235}
236
237
238bool
239Win32MakefileGenerator::findLibraries(const QString &where)
240{
241
242 QStringList &l = project->variables()[where];
243 QPtrList<MakefileDependDir> dirs;
244 dirs.setAutoDelete(TRUE);
245 for(QStringList::Iterator it = l.begin(); it != l.end(); ) {
246 QString opt = (*it);
247 bool remove = FALSE;
248 if(opt.startsWith("-L") || opt.startsWith("/L")) {
249 QString r = opt.right(opt.length() - 2), l = Option::fixPathToLocalOS(r);
250 dirs.append(new MakefileDependDir(r.replace("\"",""),
251 l.replace("\"","")));
252 remove = TRUE;
253 } else if(opt.startsWith("-l") || opt.startsWith("/l")) {
254 QString lib = opt.right(opt.length() - 2), out;
255 if(!lib.isEmpty()) {
256 for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) {
257 int ver = findHighestVersion(mdd->local_dir, lib);
258 if(ver > 0)
259 lib += QString::number(ver);
260 lib += ".lib";
261 if(QFile::exists(mdd->local_dir + Option::dir_sep + lib)) {
262 out = mdd->real_dir + Option::dir_sep + lib;
263 break;
264 }
265 }
266 }
267 if(out.isEmpty())
268 remove = TRUE;
269 else
270 (*it) = out;
271 } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) {
272 QString dir, file = opt;
273 int slsh = file.findRev(Option::dir_sep);
274 if(slsh != -1) {
275 dir = file.left(slsh+1);
276 file = file.right(file.length() - slsh - 1);
277 }
278 if ( !(project->variables()["QMAKE_QT_DLL"].isEmpty() && (file == "qt.lib" || file == "qt-mt.lib")) ) {
279 if(file.endsWith(".lib")) {
280 file = file.left(file.length() - 4);
281 if(!file.at(file.length()-1).isNumber()) {
282 int ver = findHighestVersion(dir, file);
283 if(ver != -1) {
284 file = QString(dir + file + "%1" + ".lib");
285 if(ver)
286 (*it) = file.arg(ver);
287 else
288 (*it) = file.arg("");
289 }
290 }
291 }
292 }
293 }
294 if(remove)
295 it = l.remove(it);
296 else
297 ++it;
298 }
299 return TRUE;
300}
301
302void
303Win32MakefileGenerator::processPrlFiles()
304{
305 QDict<void> processed;
306 QPtrList<MakefileDependDir> libdirs;
307 libdirs.setAutoDelete(TRUE);
308 {
309 QStringList &libpaths = project->variables()["QMAKE_LIBDIR"];
310 for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) {
311 QString r = (*libpathit), l = r;
312 fixEnvVariables(l);
313 libdirs.append(new MakefileDependDir(r.replace("\"",""),
314 l.replace("\"","")));
315 }
316 }
317 for(bool ret = FALSE; TRUE; ret = FALSE) {
318 //read in any prl files included..
319 QStringList l_out;
320 QString where = "QMAKE_LIBS";
321 if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
322 where = project->first("QMAKE_INTERNAL_PRL_LIBS");
323 QStringList &l = project->variables()[where];
324 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
325 QString opt = (*it);
326 if(opt.left(1) == "/") {
327 if(opt.left(9) == "/LIBPATH:") {
328 QString r = opt.mid(9), l = r;
329 fixEnvVariables(l);
330 libdirs.append(new MakefileDependDir(r.replace("\"",""),
331 l.replace("\"","")));
332 }
333 } else {
334 if(!processed[opt]) {
335 if(processPrlFile(opt)) {
336 processed.insert(opt, (void*)1);
337 ret = TRUE;
338 } else {
339 for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) {
340 QString prl = mdd->local_dir + Option::dir_sep + opt;
341 if(processed[prl]) {
342 break;
343 } else if(processPrlFile(prl)) {
344 processed.insert(prl, (void*)1);
345 ret = TRUE;
346 break;
347 }
348 }
349 }
350 }
351 }
352 if(!opt.isEmpty())
353 l_out.append(opt);
354 }
355 if(ret)
356 l = l_out;
357 else
358 break;
359 }
360}
diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h
new file mode 100644
index 0000000..75ba0e0
--- a/dev/null
+++ b/qmake/generators/win32/winmakefile.h
@@ -0,0 +1,72 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of ________ class.
5**
6** Created : 970521
7**
8** Copyright (C) 1992-2000 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#ifndef __WINMAKEFILE_H__
38#define __WINMAKEFILE_H__
39
40#include "makefile.h"
41
42// In the Qt evaluation and educational version, we have a postfix in the
43// library name (e.g. qtmteval301.dll). QTDLL_POSTFIX is used for this.
44// A script modifies these lines when building eval/edu version, so be careful
45// when changing them.
46#ifndef QTDLL_POSTFIX
47#define QTDLL_POSTFIX ""
48#endif
49
50class Win32MakefileGenerator : public MakefileGenerator
51{
52protected:
53 virtual void writeSubDirs(QTextStream &t);
54 int findHighestVersion(const QString &dir, const QString &stem);
55 bool findLibraries(const QString &);
56 virtual bool findLibraries();
57 virtual void processPrlFiles();
58
59public:
60 Win32MakefileGenerator(QMakeProject *p);
61 ~Win32MakefileGenerator();
62};
63
64inline Win32MakefileGenerator::~Win32MakefileGenerator()
65{ }
66
67inline bool Win32MakefileGenerator::findLibraries()
68{ return findLibraries("QMAKE_LIBS"); }
69
70
71
72#endif /* __WINMAKEFILE_H__ */