summaryrefslogtreecommitdiff
path: root/qmake/generators/win32/msvc_vcproj.cpp
Unidiff
Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp412
1 files changed, 288 insertions, 124 deletions
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index a2bb6e9..d2cbc31 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -5,7 +5,7 @@
5** 5**
6** Created : 970521 6** Created : 970521
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the network module of the Qt GUI Toolkit. 10** This file is part of the network module of the Qt GUI Toolkit.
11** 11**
@@ -38,13 +38,55 @@
38#include "msvc_vcproj.h" 38#include "msvc_vcproj.h"
39#include "option.h" 39#include "option.h"
40#include <qdir.h> 40#include <qdir.h>
41#include <stdlib.h>
42#include <qregexp.h> 41#include <qregexp.h>
42#include <qdict.h>
43#include <quuid.h>
44#include <stdlib.h>
43 45
44#if defined(Q_OS_WIN32) 46#if defined(Q_OS_WIN32)
45#include <objbase.h> 47#include <objbase.h>
48#ifndef GUID_DEFINED
49#define GUID_DEFINED
50typedef struct _GUID
51{
52 ulong Data1;
53 ushort Data2;
54 ushort Data3;
55 uchar Data4[8];
56} GUID;
57#endif
46#endif 58#endif
47 59
60// Flatfile Tags ----------------------------------------------------
61 const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version 7.00";
62 // The following UUID _may_ change for later servicepacks...
63 // If so we need to search through the registry at
64 // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects
65 // to find the subkey that contains a "PossibleProjectExtension"
66 // containing "vcproj"...
67 // Use the hardcoded value for now so projects generated on other
68 // platforms are actually usable.
69const char* _snlMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
70 const char* _snlProjectBeg= "\nProject(\"";
71 const char* _snlProjectMid= "\") = ";
72 const char* _snlProjectEnd= "\nEndProject";
73 const char* _snlGlobalBeg= "\nGlobal";
74 const char* _snlGlobalEnd= "\nEndGlobal";
75 const char* _snlSolutionConf= "\n\tGlobalSection(SolutionConfiguration) = preSolution"
76 "\n\t\tConfigName.0 = Release"
77 "\n\tEndGlobalSection";
78 const char* _snlProjDepBeg= "\n\tGlobalSection(ProjectDependencies) = postSolution";
79 const char* _snlProjDepEnd= "\n\tEndGlobalSection";
80 const char* _snlProjConfBeg= "\n\tGlobalSection(ProjectConfiguration) = postSolution";
81 const char* _snlProjConfTag1= ".Release.ActiveCfg = Release|Win32";
82 const char* _snlProjConfTag2= ".Release.Build.0 = Release|Win32";
83 const char* _snlProjConfEnd= "\n\tEndGlobalSection";
84 const char* _snlExtSections= "\n\tGlobalSection(ExtensibilityGlobals) = postSolution"
85 "\n\tEndGlobalSection"
86 "\n\tGlobalSection(ExtensibilityAddIns) = postSolution"
87 "\n\tEndGlobalSection";
88// ------------------------------------------------------------------
89
48VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) 90VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE)
49{ 91{
50} 92}
@@ -52,8 +94,7 @@ VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), i
52/* \internal 94/* \internal
53 Generates a project file for the given profile. 95 Generates a project file for the given profile.
54 Options are either a Visual Studio projectfiles, or 96 Options are either a Visual Studio projectfiles, or
55 recursive projectfiles.. Maybe we can make .sln files 97 solutionfiles by parsing recursive projectdirectories.
56 someday?
57*/ 98*/
58bool VcprojGenerator::writeMakefile(QTextStream &t) 99bool VcprojGenerator::writeMakefile(QTextStream &t)
59{ 100{
@@ -64,13 +105,15 @@ bool VcprojGenerator::writeMakefile(QTextStream &t)
64 return TRUE; 105 return TRUE;
65 } 106 }
66 107
67 // Generate full project file 108 // Generate project file
68 if(project->first("TEMPLATE") == "vcapp" || 109 if(project->first("TEMPLATE") == "vcapp" ||
69 project->first("TEMPLATE") == "vclib") { 110 project->first("TEMPLATE") == "vclib") {
70 debug_msg(1, "Generator: MSVC.NET: Writing project file" ); 111 debug_msg(1, "Generator: MSVC.NET: Writing project file" );
71 t << vcProject; 112 t << vcProject;
72 return TRUE; 113 return TRUE;
73 } else if(project->first("TEMPLATE") == "vcsubdirs") { // Generate recursive project 114 }
115 // Generate solution file
116 else if(project->first("TEMPLATE") == "vcsubdirs") {
74 debug_msg(1, "Generator: MSVC.NET: Writing solution file" ); 117 debug_msg(1, "Generator: MSVC.NET: Writing solution file" );
75 writeSubDirs(t); 118 writeSubDirs(t);
76 return TRUE; 119 return TRUE;
@@ -80,10 +123,38 @@ bool VcprojGenerator::writeMakefile(QTextStream &t)
80} 123}
81 124
82struct VcsolutionDepend { 125struct VcsolutionDepend {
126 QString uuid;
83 QString vcprojFile, orig_target, target; 127 QString vcprojFile, orig_target, target;
128 ::target targetType;
84 QStringList dependencies; 129 QStringList dependencies;
85}; 130};
86 131
132QUuid VcprojGenerator::increaseUUID( const QUuid &id )
133{
134 QUuid result( id );
135 Q_LONG dataFirst = (result.data4[0] << 24) +
136 (result.data4[1] << 16) +
137 (result.data4[2] << 8) +
138 result.data4[3];
139 Q_LONG dataLast = (result.data4[4] << 24) +
140 (result.data4[5] << 16) +
141 (result.data4[6] << 8) +
142 result.data4[7];
143
144 if ( !(dataLast++) )
145 dataFirst++;
146
147 result.data4[0] = uchar((dataFirst >> 24) & 0xff);
148 result.data4[1] = uchar((dataFirst >> 16) & 0xff);
149 result.data4[2] = uchar((dataFirst >> 8) & 0xff);
150 result.data4[3] = uchar( dataFirst & 0xff);
151 result.data4[4] = uchar((dataLast >> 24) & 0xff);
152 result.data4[5] = uchar((dataLast >> 16) & 0xff);
153 result.data4[6] = uchar((dataLast >> 8) & 0xff);
154 result.data4[7] = uchar( dataLast & 0xff);
155 return result;
156}
157
87void VcprojGenerator::writeSubDirs(QTextStream &t) 158void VcprojGenerator::writeSubDirs(QTextStream &t)
88{ 159{
89 if(project->first("TEMPLATE") == "subdirs") { 160 if(project->first("TEMPLATE") == "subdirs") {
@@ -92,8 +163,22 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
92 return; 163 return;
93 } 164 }
94 165
95 QPtrList<VcsolutionDepend> solution_depends; 166 t << _snlHeader;
96 solution_depends.setAutoDelete(TRUE); 167 QUuid solutionGUID;
168#if defined(Q_WS_WIN32)
169 GUID guid;
170 HRESULT h = CoCreateGuid( &guid );
171 if ( h == S_OK )
172 solutionGUID = QUuid( guid );
173#else
174 // Qt doesn't support GUID on other platforms yet,
175 // so we use the all-zero uuid, and increase that.
176#endif
177
178
179 QDict<VcsolutionDepend> solution_depends;
180 QPtrList<VcsolutionDepend> solution_cleanup;
181 solution_cleanup.setAutoDelete(TRUE);
97 QStringList subdirs = project->variables()["SUBDIRS"]; 182 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath(); 183 QString oldpwd = QDir::currentDirPath();
99 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { 184 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
@@ -116,72 +201,103 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
116 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { 201 if(tmp_proj.first("TEMPLATE") == "vcsubdirs") {
117 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]); 202 QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]);
118 subdirs += tmp_subdirs; 203 subdirs += tmp_subdirs;
119 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || 204 } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") {
120 tmp_proj.first("TEMPLATE") == "vclib") { 205 // Initialize a 'fake' project to get the correct variables
121 QString vcproj = fi.baseName() + project->first("VCPROJ_EXTENSION"); 206 // and to be able to extract all the dependencies
122 if(QFile::exists(vcproj) || 1) { 207 VcprojGenerator tmp_vcproj(&tmp_proj);
123 VcprojGenerator tmp_dsp(&tmp_proj); 208 tmp_vcproj.setNoIO(TRUE);
124 tmp_dsp.setNoIO(TRUE); 209 tmp_vcproj.init();
125 tmp_dsp.init(); 210 if(Option::debug_level) {
126 if(Option::debug_level) { 211 QMap<QString, QStringList> &vars = tmp_proj.variables();
127 QMap<QString, QStringList> &vars = tmp_proj.variables(); 212 for(QMap<QString, QStringList>::Iterator it = vars.begin();
128 for(QMap<QString, QStringList>::Iterator it = vars.begin(); 213 it != vars.end(); ++it) {
129 it != vars.end(); ++it) { 214 if(it.key().left(1) != "." && !it.data().isEmpty())
130 if(it.key().left(1) != "." && !it.data().isEmpty()) 215 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
131 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(), 216 it.data().join(" :: ").latin1());
132 it.data().join(" :: ").latin1());
133 }
134 } 217 }
135 VcsolutionDepend *newDep = new VcsolutionDepend; 218 }
136 newDep->vcprojFile = fileFixify(vcproj); 219
137 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); 220 // We assume project filename is [QMAKE_ORIG_TARGET].vcproj
138 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1); 221 QString vcproj = fixFilename(tmp_vcproj.project->first("QMAKE_ORIG_TARGET")) + project->first("VCPROJ_EXTENSION");
139 if(newDep->target.endsWith(".dll")) 222
140 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; 223 // If file doesn't exsist, then maybe the users configuration
141 if(!tmp_proj.isEmpty("FORMS")) 224 // doesn't allow it to be created. Skip to next...
142 newDep->dependencies << "uic.exe"; 225 if(!QFile::exists(QDir::currentDirPath() + Option::dir_sep + vcproj)) {
143 { 226 qDebug( "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() );
144 QStringList where("QMAKE_LIBS"); 227 goto nextfile; // # Dirty!
145 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) 228 }
146 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; 229
147 for(QStringList::iterator wit = where.begin(); 230 VcsolutionDepend *newDep = new VcsolutionDepend;
148 wit != where.end(); ++wit) { 231 newDep->vcprojFile = fileFixify(vcproj);
149 QStringList &l = tmp_proj.variables()[(*wit)]; 232 newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET");
150 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { 233 newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1);
151 QString opt = (*it); 234 newDep->targetType = tmp_vcproj.projectTarget;
152 if(!opt.startsWith("/")) //Not a switch 235 {
153 newDep->dependencies << opt.section(Option::dir_sep, -1); 236 static QUuid uuid = solutionGUID;
154 } 237 uuid = increaseUUID( uuid );
238 newDep->uuid = uuid.toString().upper();
239 }
240 if(newDep->target.endsWith(".dll"))
241 newDep->target = newDep->target.left(newDep->target.length()-3) + "lib";
242 if(!tmp_proj.isEmpty("FORMS"))
243 newDep->dependencies << "uic.exe";
244 {
245 QStringList where("QMAKE_LIBS");
246 if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
247 where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"];
248 for(QStringList::iterator wit = where.begin();
249 wit != where.end(); ++wit) {
250 QStringList &l = tmp_proj.variables()[(*wit)];
251 for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
252 QString opt = (*it);
253 if(!opt.startsWith("/")) //Not a switch
254 newDep->dependencies << opt.section(Option::dir_sep, -1);
155 } 255 }
156 } 256 }
157 solution_depends.append(newDep);
158 } 257 }
258 solution_cleanup.append(newDep);
259 solution_depends.insert(newDep->target, newDep);
260 {
261 QRegExp libVersion("[0-9]{3,3}\\.lib$");
262 if(libVersion.search(newDep->target) != -1)
263 solution_depends.insert(newDep->target.left(newDep->target.length() -
264 libVersion.matchedLength()) + ".lib", newDep);
265 }
266 t << _snlProjectBeg << _snlMSVCvcprojGUID << _snlProjectMid
267 << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile
268 << "\", \"" << newDep->uuid << "\"";
269 t << _snlProjectEnd;
159 } 270 }
160 } 271 }
272nextfile:
161 QDir::setCurrent(oldpwd); 273 QDir::setCurrent(oldpwd);
162 } 274 }
163 } 275 }
164 } 276 }
165 277 t << _snlGlobalBeg;
166 VcsolutionDepend *vc; 278 t << _snlSolutionConf;
167 QMap<QString, int> uuids; 279 t << _snlProjDepBeg;
168 QRegExp libVersion("[0-9]{3,3}\\.lib$"); 280 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
169 for(vc = solution_depends.first(); vc; vc = solution_depends.next()) { 281 int cnt = 0;
170 static int uuid = 666; 282 for(QStringList::iterator dit = solution_cleanup.current()->dependencies.begin();
171 uuids.insert(vc->target, uuid); 283 dit != solution_cleanup.current()->dependencies.end();
172 if(libVersion.match(vc->target) != -1) 284 ++dit) {
173 uuids.insert(vc->target.left(vc->target.length() - libVersion.matchedLength()) + ".lib", 285 VcsolutionDepend *vc;
174 uuid); 286 if((vc=solution_depends[*dit])) {
175 t << "\"" << vc->orig_target << "\" \"" << vc->vcprojFile << "\" { " << uuid << " }" << endl; 287 if(solution_cleanup.current()->targetType != StaticLib || vc->targetType == Application)
176 uuid++; 288 t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid;
177 } 289 }
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 } 290 }
184 } 291 }
292 t << _snlProjDepEnd;
293 t << _snlProjConfBeg;
294 for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) {
295 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag1;
296 t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag2;
297 }
298 t << _snlProjConfEnd;
299 t << _snlExtSections;
300 t << _snlGlobalEnd;
185} 301}
186 302
187// ------------------------------------------------------------------------------------------------ 303// ------------------------------------------------------------------------------------------------
@@ -306,12 +422,12 @@ void VcprojGenerator::initConfiguration()
306 vcProject.Configuration.ConfigurationType = typeApplication; 422 vcProject.Configuration.ConfigurationType = typeApplication;
307 break; 423 break;
308 } 424 }
309 vcProject.Configuration.Name = ( project->isActiveConfig( "release" ) ? "Release|" : "Debug|" ); 425 vcProject.Configuration.Name = ( project->isActiveConfig( "debug" ) ? "Debug|" : "Release|" );
310 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); 426 vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" );
311 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); 427 vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True );
312 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? unset : temp.toShort() ); 428 vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() );
313 temp = project->first("CharacterSet"); 429 temp = project->first("CharacterSet");
314 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? charSetNotSet : temp.toShort() ); 430 vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() );
315 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); 431 vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean");
316 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary; 432 vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary;
317 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR"); 433 vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR");
@@ -338,7 +454,7 @@ void VcprojGenerator::initCompilerTool()
338{ 454{
339 QString placement = project->first("OBJECTS_DIR"); 455 QString placement = project->first("OBJECTS_DIR");
340 if ( placement.isEmpty() ) 456 if ( placement.isEmpty() )
341 placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\"; 457 placement = ".\\";
342 458
343 vcProject.Configuration.compiler.AssemblerListingLocation = placement ; 459 vcProject.Configuration.compiler.AssemblerListingLocation = placement ;
344 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ; 460 vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ;
@@ -362,6 +478,7 @@ void VcprojGenerator::initCompilerTool()
362 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); 478 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] );
363 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); 479 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] );
364 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; 480 vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG";
481 vcProject.Configuration.compiler.PreprocessorDefinitions += "NDEBUG";
365 if ( project->isActiveConfig("thread") ) { 482 if ( project->isActiveConfig("thread") ) {
366 if ( (projectTarget == Application) || (projectTarget == StaticLib) ) 483 if ( (projectTarget == Application) || (projectTarget == StaticLib) )
367 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); 484 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] );
@@ -375,7 +492,7 @@ void VcprojGenerator::initCompilerTool()
375 // Common for both release and debug 492 // Common for both release and debug
376 if ( project->isActiveConfig("warn_off") ) 493 if ( project->isActiveConfig("warn_off") )
377 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); 494 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] );
378 else 495 else if ( project->isActiveConfig("warn_on") )
379 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); 496 vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] );
380 if ( project->isActiveConfig("windows") ) 497 if ( project->isActiveConfig("windows") )
381 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; 498 vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"];
@@ -408,13 +525,15 @@ void VcprojGenerator::initLinkerTool()
408 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; 525 vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"];
409 526
410 switch ( projectTarget ) { 527 switch ( projectTarget ) {
411 case Application: 528 case Application:
412 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" ); 529 vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" );
413 break; 530 break;
414 case SharedLib: 531 case SharedLib:
415 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); 532 vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] );
416 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" ); 533 vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" );
417 break; 534 break;
535 case StaticLib: //unhandled - added to remove warnings..
536 break;
418 } 537 }
419 538
420 if( vcProject.Configuration.linker.OutputFile.isEmpty() ) 539 if( vcProject.Configuration.linker.OutputFile.isEmpty() )
@@ -459,7 +578,17 @@ void VcprojGenerator::initPreBuildEventTools()
459 QStringList& list = project->variables()["IMAGES"]; 578 QStringList& list = project->variables()["IMAGES"];
460 vcProject.Configuration.preBuild.Description = "Generate imagecollection"; 579 vcProject.Configuration.preBuild.Description = "Generate imagecollection";
461 //vcProject.Configuration.preBuild.AdditionalDependencies += list; 580 //vcProject.Configuration.preBuild.AdditionalDependencies += list;
462 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " " + list.join(" ") + " -o " + collectionName; 581
582 QFile imgs( ".imgcol" );
583 imgs.open( IO_WriteOnly );
584 QTextStream s( &imgs );
585 QStringList::ConstIterator it = list.begin();
586 while( it!=list.end() ) {
587 s << *it << " ";
588 it++;
589 }
590
591 vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " -f .imgcol -o " + collectionName;
463 //vcProject.Configuration.preBuild.Outputs = collectionName; 592 //vcProject.Configuration.preBuild.Outputs = collectionName;
464 593
465 } 594 }
@@ -467,6 +596,10 @@ void VcprojGenerator::initPreBuildEventTools()
467 596
468void VcprojGenerator::initPostBuildEventTools() 597void VcprojGenerator::initPostBuildEventTools()
469{ 598{
599 if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) {
600 vcProject.Configuration.postBuild.Description = var("QMAKE_POST_LINK");
601 vcProject.Configuration.postBuild.CommandLine = var("QMAKE_POST_LINK");
602 }
470 if( project->isActiveConfig( "activeqt" ) ) { 603 if( project->isActiveConfig( "activeqt" ) ) {
471 QString name = project->first( "QMAKE_ORIG_TARGET" ); 604 QString name = project->first( "QMAKE_ORIG_TARGET" );
472 QString nameext = project->first( "TARGET" ); 605 QString nameext = project->first( "TARGET" );
@@ -474,9 +607,11 @@ void VcprojGenerator::initPostBuildEventTools()
474 QString idc = project->first( "QMAKE_IDC" ); 607 QString idc = project->first( "QMAKE_IDC" );
475 608
476 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server..."; 609 vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server...";
610 if ( !vcProject.Configuration.postBuild.CommandLine.isEmpty() )
611 vcProject.Configuration.postBuild.CommandLine += " &amp;&amp; ";
477 612
478 if( project->isActiveConfig( "dll" ) ) { // In process 613 if( project->isActiveConfig( "dll" ) ) { // In process
479 vcProject.Configuration.postBuild.CommandLine = 614 vcProject.Configuration.postBuild.CommandLine +=
480 // call idc to generate .idl file from .dll 615 // call idc to generate .idl file from .dll
481 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " + 616 idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 &amp;&amp; " +
482 // call midl to create implementations of the .idl file 617 // call midl to create implementations of the .idl file
@@ -602,21 +737,6 @@ void VcprojGenerator::initResourceFiles()
602 vcProject.ResourceFiles.CustomBuild = none; 737 vcProject.ResourceFiles.CustomBuild = none;
603} 738}
604 739
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 740/* \internal
621 Sets up all needed variables from the environment and all the different caches and .conf files 741 Sets up all needed variables from the environment and all the different caches and .conf files
622*/ 742*/
@@ -629,6 +749,28 @@ void VcprojGenerator::initOld()
629 init_flag = TRUE; 749 init_flag = TRUE;
630 QStringList::Iterator it; 750 QStringList::Iterator it;
631 751
752 if ( project->isActiveConfig("stl") ) {
753 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"];
754 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"];
755 } else {
756 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"];
757 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"];
758 }
759 if ( project->isActiveConfig("exceptions") ) {
760 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"];
761 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"];
762 } else {
763 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"];
764 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"];
765 }
766 if ( project->isActiveConfig("rtti") ) {
767 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"];
768 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"];
769 } else {
770 project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"];
771 project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"];
772 }
773
632 // this should probably not be here, but I'm using it to wrap the .t files 774 // this should probably not be here, but I'm using it to wrap the .t files
633 if(project->first("TEMPLATE") == "vcapp" ) 775 if(project->first("TEMPLATE") == "vcapp" )
634 project->variables()["QMAKE_APP_FLAG"].append("1"); 776 project->variables()["QMAKE_APP_FLAG"].append("1");
@@ -788,7 +930,7 @@ void VcprojGenerator::initOld()
788 930
789 // INCREMENTAL:NO ------------------------------------------------ 931 // INCREMENTAL:NO ------------------------------------------------
790 if(!project->isActiveConfig("incremental")) { 932 if(!project->isActiveConfig("incremental")) {
791 project->variables()["QMAKE_LFLAGS"].append(QString("/incremental:no")); 933 project->variables()["QMAKE_LFLAGS"].append(QString("/INCREMENTAL:no"));
792 if ( is_qt ) 934 if ( is_qt )
793 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi"; 935 project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi";
794 } 936 }
@@ -799,6 +941,19 @@ void VcprojGenerator::initOld()
799 941
800 942
801 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; 943 project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"];
944 // Update -lname to name.lib, and -Ldir to
945 QStringList &libList = project->variables()["QMAKE_LIBS"];
946 for( it = libList.begin(); it != libList.end(); ) {
947 QString s = *it;
948 if( s.startsWith( "-l" ) ) {
949 it = libList.remove( it );
950 it = libList.insert( it, s.mid( 2 ) + ".lib" );
951 } else if( s.startsWith( "-L" ) ) {
952 it = libList.remove( it );
953 } else {
954 it++;
955 }
956 }
802 957
803 // Run through all variables containing filepaths, and ----------- 958 // Run through all variables containing filepaths, and -----------
804 // slash-slosh them correctly depending on current OS ----------- 959 // slash-slosh them correctly depending on current OS -----------
@@ -821,8 +976,8 @@ void VcprojGenerator::initOld()
821 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------ 976 // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------
822 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; 977 project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"];
823 978
824 // TARGET (add extention to $$TARGET) ---------------------------- 979 // TARGET (add extention to $$TARGET)
825 project->variables()["TARGET"].first() += project->first("TARGET_EXT"); 980 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue(".first() += project->first("TARGET_EXT");
826 981
827 // Init base class too ------------------------------------------- 982 // Init base class too -------------------------------------------
828 MakefileGenerator::init(); 983 MakefileGenerator::init();
@@ -867,8 +1022,15 @@ void VcprojGenerator::initOld()
867 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"]; 1022 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"];
868 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; 1023 project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"];
869 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; 1024 project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"];
870 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) 1025 if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) {
871 project->variables()["MSVCPROJ_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:"," /LIBPATH:","")); 1026 QStringList strl = project->variables()["QMAKE_LIBDIR"];
1027 QStringList::iterator stri;
1028 for ( stri = strl.begin(); stri != strl.end(); ++stri ) {
1029 if ( !(*stri).startsWith("/LIBPATH:") )
1030 (*stri).prepend( "/LIBPATH:" );
1031 }
1032 project->variables()["MSVCPROJ_LFLAGS"] += strl;
1033 }
872 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; 1034 project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"];
873 // We don't use this... Direct manipulation of compiler object 1035 // We don't use this... Direct manipulation of compiler object
874 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); 1036 //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ",""));
@@ -883,19 +1045,18 @@ void VcprojGenerator::initOld()
883 1045
884 QString dest; 1046 QString dest;
885 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET"); 1047 project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET");
886 if ( !project->variables()["DESTDIR"].isEmpty() ) { 1048 Option::fixPathToTargetOS(project->first("TARGET"));
887 project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); 1049 dest = project->first("TARGET") + project->first( "TARGET_EXT" );
888 Option::fixPathToTargetOS(project->first("TARGET")); 1050 if ( project->first("TARGET").startsWith("$(QTDIR)") )
889 dest = project->first("TARGET"); 1051 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") );
890 if ( project->first("TARGET").startsWith("$(QTDIR)") ) 1052 project->variables()["MSVCPROJ_TARGET"] = dest;
891 dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); 1053 if ( project->isActiveConfig("dll") ) {
892 project->variables()["MSVCPROJ_TARGET"].append( 1054 QString imp = project->first( "DESTDIR" );
893 QString("/OUT:") + dest ); 1055 if( !imp.isNull() && !imp.endsWith( "\\" ) )
894 if ( project->isActiveConfig("dll") ) { 1056 imp += "\\";
895 QString imp = dest; 1057 imp += dest;
896 imp.replace(QRegExp("\\.dll"), ".lib"); 1058 imp.replace(QRegExp("\\.dll"), ".lib");
897 project->variables()["MSVCPROJ_LIBOPTIONS"] += (QString("/IMPLIB:") + imp ); 1059 project->variables()["MSVCPROJ_LIBOPTIONS"] += QString("/IMPLIB:") + imp;
898 }
899 } 1060 }
900 1061
901 // DLL COPY ------------------------------------------------------ 1062 // DLL COPY ------------------------------------------------------
@@ -996,23 +1157,26 @@ bool VcprojGenerator::openOutput(QFile &file) const
996 file.setName(outdir + project->first("TARGET") + ext); 1157 file.setName(outdir + project->first("TARGET") + ext);
997 } 1158 }
998 if(QDir::isRelativePath(file.name())) { 1159 if(QDir::isRelativePath(file.name())) {
999 QString ofile; 1160 file.setName( Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + fixFilename(file.name())) );
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 } 1161 }
1013 return Win32MakefileGenerator::openOutput(file); 1162 return Win32MakefileGenerator::openOutput(file);
1014} 1163}
1015 1164
1165QString VcprojGenerator::fixFilename(QString ofile) const
1166{
1167 int slashfind = ofile.findRev('\\');
1168 if (slashfind == -1) {
1169 ofile = ofile.replace('-', '_');
1170 } else {
1171 int hypenfind = ofile.find('-', slashfind);
1172 while (hypenfind != -1 && slashfind < hypenfind) {
1173 ofile = ofile.replace(hypenfind, 1, '_');
1174 hypenfind = ofile.find('-', hypenfind + 1);
1175 }
1176 }
1177 return ofile;
1178}
1179
1016QString VcprojGenerator::findTemplate(QString file) 1180QString VcprojGenerator::findTemplate(QString file)
1017{ 1181{
1018 QString ret; 1182 QString ret;
@@ -1042,9 +1206,9 @@ void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &
1042void VcprojGenerator::outputVariables() 1206void VcprojGenerator::outputVariables()
1043{ 1207{
1044#if 0 1208#if 0
1045 debug_msg(3, "Generator: MSVC.NET: List of current variables:" ); 1209 qDebug( "Generator: MSVC.NET: List of current variables:" );
1046 for ( QMap<QString, QStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) { 1210 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() ); 1211 qDebug( "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() );
1048 } 1212 }
1049#endif 1213#endif
1050} 1214}