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
@@ -7,3 +7,3 @@
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9** 9**
@@ -40,4 +40,6 @@
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
@@ -45,4 +47,44 @@
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)
@@ -54,4 +96,3 @@ VcprojGenerator::VcprojGenerator(QMakeProject *p) : Win32MakefileGenerator(p), i
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*/
@@ -66,3 +107,3 @@ bool VcprojGenerator::writeMakefile(QTextStream &t)
66 107
67 // Generate full project file 108 // Generate project file
68 if(project->first("TEMPLATE") == "vcapp" || 109 if(project->first("TEMPLATE") == "vcapp" ||
@@ -72,3 +113,5 @@ bool VcprojGenerator::writeMakefile(QTextStream &t)
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" );
@@ -82,3 +125,5 @@ bool VcprojGenerator::writeMakefile(QTextStream &t)
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;
@@ -86,2 +131,28 @@ struct VcsolutionDepend {
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)
@@ -94,4 +165,18 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
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"];
@@ -118,44 +203,71 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
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);
@@ -164,22 +276,26 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
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}
@@ -308,8 +424,8 @@ void VcprojGenerator::initConfiguration()
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");
@@ -340,3 +456,3 @@ void VcprojGenerator::initCompilerTool()
340 if ( placement.isEmpty() ) 456 if ( placement.isEmpty() )
341 placement = project->isActiveConfig( "release" )? ".\\Release\\":".\\Debug\\"; 457 placement = ".\\";
342 458
@@ -364,2 +480,3 @@ void VcprojGenerator::initCompilerTool()
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") ) {
@@ -377,3 +494,3 @@ void VcprojGenerator::initCompilerTool()
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"] );
@@ -410,9 +527,11 @@ void VcprojGenerator::initLinkerTool()
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 }
@@ -461,3 +580,13 @@ void VcprojGenerator::initPreBuildEventTools()
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;
@@ -469,2 +598,6 @@ void 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" ) ) {
@@ -476,5 +609,7 @@ void VcprojGenerator::initPostBuildEventTools()
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
@@ -604,17 +739,2 @@ void VcprojGenerator::initResourceFiles()
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
@@ -631,2 +751,24 @@ void VcprojGenerator::initOld()
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
@@ -790,3 +932,3 @@ void VcprojGenerator::initOld()
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 )
@@ -801,2 +943,15 @@ void VcprojGenerator::initOld()
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
@@ -823,4 +978,4 @@ void VcprojGenerator::initOld()
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
@@ -869,4 +1024,11 @@ void VcprojGenerator::initOld()
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"];
@@ -885,15 +1047,14 @@ void VcprojGenerator::initOld()
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 }
@@ -998,15 +1159,3 @@ bool VcprojGenerator::openOutput(QFile &file) const
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 }
@@ -1015,2 +1164,17 @@ bool VcprojGenerator::openOutput(QFile &file) const
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)
@@ -1044,5 +1208,5 @@ void VcprojGenerator::outputVariables()
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 }