Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 1050 |
1 files changed, 1050 insertions, 0 deletions
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 | |||
48 | VcprojGenerator::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 | */ | ||
58 | bool 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 | |||
82 | struct VcsolutionDepend { | ||
83 | QString vcprojFile, orig_target, target; | ||
84 | QStringList dependencies; | ||
85 | }; | ||
86 | |||
87 | void 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 | |||
190 | void 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 | |||
259 | void 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 | |||
283 | void 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 | |||
337 | void 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 | |||
393 | void 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 | |||
405 | void 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 | |||
447 | void VcprojGenerator::initIDLTool() | ||
448 | { | ||
449 | } | ||
450 | |||
451 | void VcprojGenerator::initCustomBuildTool() | ||
452 | { | ||
453 | } | ||
454 | |||
455 | void 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 | |||
468 | void 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 && " + | ||
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 && " + | ||
486 | // call idc to replace tlb... | ||
487 | idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb && " + | ||
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 && " + | ||
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 && " + | ||
498 | // call idc to replace tlb... | ||
499 | idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb && " + | ||
500 | // call app to register | ||
501 | vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver"; | ||
502 | } | ||
503 | } | ||
504 | } | ||
505 | |||
506 | void VcprojGenerator::initPreLinkEventTools() | ||
507 | { | ||
508 | } | ||
509 | |||
510 | void 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 | |||
521 | void 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 | |||
532 | void 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 | |||
543 | void 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 | |||
555 | void 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 | |||
567 | void 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 | |||
579 | void 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 | |||
591 | void 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 --------------------------------------------- | ||
607 | void 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 | |||
624 | void 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 | |||
984 | bool 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 | |||
1016 | QString 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 | |||
1029 | void 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 | |||
1042 | void 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 | } | ||