From 323e9a7472a110b4befba7320540263147505bae Mon Sep 17 00:00:00 2001 From: zecke Date: Thu, 15 Jul 2004 17:36:57 +0000 Subject: Manually updatet to qmake1.06a which includes support for precompiled headers. Opies 'PRO' keyword was already reintroduced --- (limited to 'qmake/generators/win32/msvc_vcproj.cpp') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index d2cbc31..aa8fe16 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1,13 +1,11 @@ /**************************************************************************** -** $Id$ +** ** -** Definition of VcprojGenerator class. +** Implementation of VcprojGenerator class. ** -** Created : 970521 +** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. ** -** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. -** -** This file is part of the network module of the Qt GUI Toolkit. +** This file is part of qmake. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file @@ -37,28 +35,68 @@ #include "msvc_vcproj.h" #include "option.h" +#include "qtmd5.h" // SG's MD5 addon #include #include #include #include #include +#include + +//#define DEBUG_SOLUTION_GEN +//#define DEBUG_PROJECT_GEN + +// Registry keys for .NET version detection ------------------------- +const char* _regNet2002 = "Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"; +const char* _regNet2003 = "Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"; -#if defined(Q_OS_WIN32) -#include -#ifndef GUID_DEFINED -#define GUID_DEFINED -typedef struct _GUID +bool use_net2003_version() { - ulong Data1; - ushort Data2; - ushort Data3; - uchar Data4[8]; -} GUID; -#endif +#ifndef Q_OS_WIN32 + return FALSE; // Always generate 7.0 versions on other platforms +#else + // Only search for the version once + static int current_version = -1; + if (current_version!=-1) + return (current_version==71); + + // Fallback to .NET 2002 + current_version = 70; + + // Get registry entries for both versions + bool ok = false; + QSettings setting; + QString path2002 = setting.readEntry(_regNet2002); + QString path2003 = setting.readEntry(_regNet2003); + + if ( path2002.isNull() || path2003.isNull() ) { + // Only have one MSVC, so use that one + current_version = (path2003.isNull() ? 70 : 71); + } else { + // Have both, so figure out the current + QString paths = getenv("PATH"); + QStringList pathlist = QStringList::split(";", paths.lower()); + + path2003 = path2003.lower(); + QStringList::iterator it; + for(it=pathlist.begin(); it!=pathlist.end(); ++it) { + if ((*it).contains(path2003)) { + current_version = 71; + } else if ((*it).contains(path2002) + && current_version == 71) { + fprintf( stderr, "Both .NET 2002 & .NET 2003 directories for VC found in you PATH variable!\nFallback to .NET 2002 project generation" ); + current_version = 70; + break; + } + } + } + return (current_version==71); #endif +}; // Flatfile Tags ---------------------------------------------------- -const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version 7.00"; +const char* _slnHeader70 = "Microsoft Visual Studio Solution File, Format Version 7.00"; +const char* _slnHeader71 = "Microsoft Visual Studio Solution File, Format Version 8.00"; // The following UUID _may_ change for later servicepacks... // If so we need to search through the registry at // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects @@ -66,22 +104,25 @@ const char* _snlHeader = "Microsoft Visual Studio Solution File, Format Version // containing "vcproj"... // Use the hardcoded value for now so projects generated on other // platforms are actually usable. -const char* _snlMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; -const char* _snlProjectBeg = "\nProject(\""; -const char* _snlProjectMid = "\") = "; -const char* _snlProjectEnd = "\nEndProject"; -const char* _snlGlobalBeg = "\nGlobal"; -const char* _snlGlobalEnd = "\nEndGlobal"; -const char* _snlSolutionConf = "\n\tGlobalSection(SolutionConfiguration) = preSolution" - "\n\t\tConfigName.0 = Release" +const char* _slnMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; +const char* _slnProjectBeg = "\nProject(\""; +const char* _slnProjectMid = "\") = "; +const char* _slnProjectEnd = "\nEndProject"; +const char* _slnGlobalBeg = "\nGlobal"; +const char* _slnGlobalEnd = "\nEndGlobal"; +const char* _slnSolutionConf = "\n\tGlobalSection(SolutionConfiguration) = preSolution" + "\n\t\tConfigName.0 = Debug" + "\n\t\tConfigName.1 = Release" "\n\tEndGlobalSection"; -const char* _snlProjDepBeg = "\n\tGlobalSection(ProjectDependencies) = postSolution"; -const char* _snlProjDepEnd = "\n\tEndGlobalSection"; -const char* _snlProjConfBeg = "\n\tGlobalSection(ProjectConfiguration) = postSolution"; -const char* _snlProjConfTag1 = ".Release.ActiveCfg = Release|Win32"; -const char* _snlProjConfTag2 = ".Release.Build.0 = Release|Win32"; -const char* _snlProjConfEnd = "\n\tEndGlobalSection"; -const char* _snlExtSections = "\n\tGlobalSection(ExtensibilityGlobals) = postSolution" +const char* _slnProjDepBeg = "\n\tGlobalSection(ProjectDependencies) = postSolution"; +const char* _slnProjDepEnd = "\n\tEndGlobalSection"; +const char* _slnProjConfBeg = "\n\tGlobalSection(ProjectConfiguration) = postSolution"; +const char* _slnProjRelConfTag1 = ".Release.ActiveCfg = Release|Win32"; +const char* _slnProjRelConfTag2 = ".Release.Build.0 = Release|Win32"; +const char* _slnProjDbgConfTag1 = ".Debug.ActiveCfg = Debug|Win32"; +const char* _slnProjDbgConfTag2 = ".Debug.Build.0 = Debug|Win32"; +const char* _slnProjConfEnd = "\n\tEndGlobalSection"; +const char* _slnExtSections = "\n\tGlobalSection(ExtensibilityGlobals) = postSolution" "\n\tEndGlobalSection" "\n\tGlobalSection(ExtensibilityAddIns) = postSolution" "\n\tEndGlobalSection"; @@ -126,9 +167,39 @@ struct VcsolutionDepend { QString uuid; QString vcprojFile, orig_target, target; ::target targetType; + bool debugBuild; QStringList dependencies; }; +QUuid VcprojGenerator::getProjectUUID(const QString &filename) +{ + bool validUUID = true; + + // Read GUID from variable-space + QUuid uuid = project->first("GUID"); + + // If none, create one based on the MD5 of absolute project path + if (uuid.isNull() || !filename.isNull()) { + QString abspath = filename.isNull()?project->first("QMAKE_MAKEFILE"):filename; + qtMD5(abspath.utf8(), (unsigned char*)(&uuid)); + validUUID = !uuid.isNull(); + uuid.data4[0] = (uuid.data4[0] & 0x3F) | 0x80; // UV_DCE variant + uuid.data3 = (uuid.data3 & 0x0FFF) | (QUuid::Name<<12); + } + + // If still not valid, generate new one, and suggest adding to .pro + if (uuid.isNull() || !validUUID) { + uuid = QUuid::createUuid(); + fprintf(stderr, + "qmake couldn't create a GUID based on filepath, and we couldn't\nfind a valid GUID in the .pro file (Consider adding\n'GUID = %s' to the .pro file)\n", + uuid.toString().upper().latin1()); + } + + // Store GUID in variable-space + project->values("GUID") = uuid.toString().upper(); + return uuid; +} + QUuid VcprojGenerator::increaseUUID( const QUuid &id ) { QUuid result( id ); @@ -163,24 +234,17 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) return; } - t << _snlHeader; - QUuid solutionGUID; -#if defined(Q_WS_WIN32) - GUID guid; - HRESULT h = CoCreateGuid( &guid ); - if ( h == S_OK ) - solutionGUID = QUuid( guid ); -#else - // Qt doesn't support GUID on other platforms yet, - // so we use the all-zero uuid, and increase that. -#endif - + t << (use_net2003_version() ? _slnHeader71 : _slnHeader70); QDict solution_depends; + QPtrList solution_cleanup; solution_cleanup.setAutoDelete(TRUE); + + QStringList subdirs = project->variables()["SUBDIRS"]; QString oldpwd = QDir::currentDirPath(); + for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE)); if(fi.exists()) { @@ -199,8 +263,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } if(tmp_proj.read(fn, oldpwd)) { if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { - QStringList tmp_subdirs = fileFixify(tmp_proj.variables()["SUBDIRS"]); - subdirs += tmp_subdirs; + subdirs += fileFixify(tmp_proj.variables()["SUBDIRS"]); } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") { // Initialize a 'fake' project to get the correct variables // and to be able to extract all the dependencies @@ -223,50 +286,67 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) // If file doesn't exsist, then maybe the users configuration // doesn't allow it to be created. Skip to next... if(!QFile::exists(QDir::currentDirPath() + Option::dir_sep + vcproj)) { - qDebug( "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() ); + warn_msg(WarnLogic, "Ignored (not found) '%s'", QString(QDir::currentDirPath() + Option::dir_sep + vcproj).latin1() ); goto nextfile; // # Dirty! } VcsolutionDepend *newDep = new VcsolutionDepend; newDep->vcprojFile = fileFixify(vcproj); newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); - newDep->target = tmp_proj.first("TARGET").section(Option::dir_sep, -1); + newDep->target = tmp_proj.first("MSVCPROJ_TARGET").section(Option::dir_sep, -1); newDep->targetType = tmp_vcproj.projectTarget; - { - static QUuid uuid = solutionGUID; - uuid = increaseUUID( uuid ); - newDep->uuid = uuid.toString().upper(); - } + newDep->debugBuild = tmp_proj.isActiveConfig("debug"); + newDep->uuid = getProjectUUID(Option::fixPathToLocalOS(QDir::currentDirPath() + QDir::separator() + vcproj)).toString().upper(); + + // We want to store it as the .lib name. if(newDep->target.endsWith(".dll")) newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; + + // All projects using Forms are dependent on uic.exe if(!tmp_proj.isEmpty("FORMS")) newDep->dependencies << "uic.exe"; - { - QStringList where("QMAKE_LIBS"); - if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) - where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; - for(QStringList::iterator wit = where.begin(); - wit != where.end(); ++wit) { - QStringList &l = tmp_proj.variables()[(*wit)]; - for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { - QString opt = (*it); - if(!opt.startsWith("/")) //Not a switch - newDep->dependencies << opt.section(Option::dir_sep, -1); + + // Add all unknown libs to the deps + QStringList where("QMAKE_LIBS"); + if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) + where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; + for(QStringList::iterator wit = where.begin(); + wit != where.end(); ++wit) { + QStringList &l = tmp_proj.variables()[(*wit)]; + for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + QString opt = (*it); + if(!opt.startsWith("/") && // Not a switch + opt != newDep->target && // Not self + opt != "opengl32.lib" && // We don't care about these libs + opt != "glu32.lib" && // to make depgen alittle faster + opt != "kernel32.lib" && + opt != "user32.lib" && + opt != "gdi32.lib" && + opt != "comdlg32.lib" && + opt != "advapi32.lib" && + opt != "shell32.lib" && + opt != "ole32.lib" && + opt != "oleaut32.lib" && + opt != "uuid.lib" && + opt != "imm32.lib" && + opt != "winmm.lib" && + opt != "wsock32.lib" && + opt != "winspool.lib" && + opt != "delayimp.lib" ) + { + newDep->dependencies << opt.section(Option::dir_sep, -1); } } } +#ifdef DEBUG_SOLUTION_GEN + qDebug( "Deps for %20s: [%s]", newDep->target.latin1(), newDep->dependencies.join(" :: " ).latin1() ); +#endif solution_cleanup.append(newDep); solution_depends.insert(newDep->target, newDep); - { - QRegExp libVersion("[0-9]{3,3}\\.lib$"); - if(libVersion.search(newDep->target) != -1) - solution_depends.insert(newDep->target.left(newDep->target.length() - - libVersion.matchedLength()) + ".lib", newDep); - } - t << _snlProjectBeg << _snlMSVCvcprojGUID << _snlProjectMid + t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile << "\", \"" << newDep->uuid << "\""; - t << _snlProjectEnd; + t << _slnProjectEnd; } } nextfile: @@ -274,30 +354,35 @@ nextfile: } } } - t << _snlGlobalBeg; - t << _snlSolutionConf; - t << _snlProjDepBeg; + t << _slnGlobalBeg; + t << _slnSolutionConf; + t << _slnProjDepBeg; + + // Figure out dependencies for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) { + if(solution_cleanup.current()->targetType == StaticLib) + continue; // Shortcut, Static libs are not dep. int cnt = 0; for(QStringList::iterator dit = solution_cleanup.current()->dependencies.begin(); dit != solution_cleanup.current()->dependencies.end(); - ++dit) { - VcsolutionDepend *vc; - if((vc=solution_depends[*dit])) { - if(solution_cleanup.current()->targetType != StaticLib || vc->targetType == Application) - t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid; - } + ++dit) + { + VcsolutionDepend *vc = solution_depends[*dit]; + if(vc) + t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid; } } - t << _snlProjDepEnd; - t << _snlProjConfBeg; + t << _slnProjDepEnd; + t << _slnProjConfBeg; for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) { - t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag1; - t << "\n\t\t" << solution_cleanup.current()->uuid << _snlProjConfTag2; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjDbgConfTag1; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjDbgConfTag2; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjRelConfTag1; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjRelConfTag2; } - t << _snlProjConfEnd; - t << _snlExtSections; - t << _snlGlobalEnd; + t << _slnProjConfEnd; + t << _slnExtSections; + t << _slnGlobalEnd; } // ------------------------------------------------------------------------------------------------ @@ -369,6 +454,24 @@ void VcprojGenerator::init() else projectTarget = SharedLib; } + + // Setup PCH variables + precompH = project->first("PRECOMPILED_HEADER"); + usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + if (usePCH) { + precompHFilename = QFileInfo(precompH).fileName(); + // Created files + QString origTarget = project->first("QMAKE_ORIG_TARGET"); + precompObj = origTarget + Option::obj_ext; + precompPch = origTarget + ".pch"; + // Add PRECOMPILED_HEADER to HEADERS + if (!project->variables()["HEADERS"].contains(precompH)) + project->variables()["HEADERS"] += precompH; + // Return to variable pool + project->variables()["PRECOMPILED_OBJECT"] = precompObj; + project->variables()["PRECOMPILED_PCH"] = precompPch; + } + initProject(); // Fills the whole project with proper data } @@ -389,8 +492,9 @@ void VcprojGenerator::initProject() // Own elements ----------------------------- vcProject.Name = project->first("QMAKE_ORIG_TARGET"); - vcProject.Version = "7.00"; - vcProject.PlatformName = ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); + vcProject.Version = use_net2003_version() ? "7.10" : "7.00"; + vcProject.ProjectGUID = getProjectUUID().toString().upper(); + vcProject.PlatformName = ( vcProject.Configuration[0].idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); // These are not used by Qt, but may be used by customers vcProject.SccProjectName = project->first("SCCPROJECTNAME"); vcProject.SccLocalPath = project->first("SCCLOCALPATH"); @@ -412,35 +516,37 @@ void VcprojGenerator::initConfiguration() QString temp = project->first("BuildBrowserInformation"); switch ( projectTarget ) { case SharedLib: - vcProject.Configuration.ConfigurationType = typeDynamicLibrary; + vcProject.Configuration[0].ConfigurationType = typeDynamicLibrary; break; case StaticLib: - vcProject.Configuration.ConfigurationType = typeStaticLibrary; + vcProject.Configuration[0].ConfigurationType = typeStaticLibrary; break; case Application: default: - vcProject.Configuration.ConfigurationType = typeApplication; + vcProject.Configuration[0].ConfigurationType = typeApplication; break; } - vcProject.Configuration.Name = ( project->isActiveConfig( "debug" ) ? "Debug|" : "Release|" ); - vcProject.Configuration.Name += ( vcProject.Configuration.idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); - vcProject.Configuration.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); - vcProject.Configuration.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() ); + + // Release version of the Configuration --------------- + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.Name = "Release"; + RConf.Name += ( RConf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32" ); + RConf.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); + RConf.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() ); temp = project->first("CharacterSet"); - vcProject.Configuration.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() ); - vcProject.Configuration.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); - vcProject.Configuration.ImportLibrary = vcProject.Configuration.linker.ImportLibrary; - vcProject.Configuration.IntermediateDirectory = project->first("OBJECTS_DIR"); -// temp = (projectTarget == StaticLib) ? project->first("DESTDIR"):project->first("DLLDESTDIR"); - vcProject.Configuration.OutputDirectory = "."; //( temp.isEmpty() ? QString(".") : temp ); - vcProject.Configuration.PrimaryOutput = project->first("PrimaryOutput"); - vcProject.Configuration.WholeProgramOptimization = vcProject.Configuration.compiler.WholeProgramOptimization; + RConf.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() ); + RConf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); + RConf.ImportLibrary = RConf.linker.ImportLibrary; + RConf.IntermediateDirectory = project->first("OBJECTS_DIR"); + RConf.OutputDirectory = "."; + RConf.PrimaryOutput = project->first("PrimaryOutput"); + RConf.WholeProgramOptimization = RConf.compiler.WholeProgramOptimization; temp = project->first("UseOfATL"); if ( !temp.isEmpty() ) - vcProject.Configuration.UseOfATL = useOfATL( temp.toShort() ); + RConf.UseOfATL = useOfATL( temp.toShort() ); temp = project->first("UseOfMfc"); if ( !temp.isEmpty() ) - vcProject.Configuration.UseOfMfc = useOfMfc( temp.toShort() ); + RConf.UseOfMfc = useOfMfc( temp.toShort() ); // Configuration does not need parameters from // these sub XML items; @@ -448,6 +554,39 @@ void VcprojGenerator::initConfiguration() initPreBuildEventTools(); initPostBuildEventTools(); initPreLinkEventTools(); + + // Debug version of the Configuration ----------------- + VCConfiguration DConf = vcProject.Configuration[0]; // Create copy configuration for debug + DConf.Name = "Debug"; + DConf.Name += ( DConf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32" ); + + // Set definite values in both configurations + DConf.compiler.PreprocessorDefinitions.remove("NDEBUG"); + RConf.compiler.PreprocessorDefinitions += "NDEBUG"; + RConf.linker.GenerateDebugInformation = _False; + DConf.linker.GenerateDebugInformation = _True; + + // Modify configurations, based on Qt build + if ( project->isActiveConfig("debug") ) { + RConf.IntermediateDirectory = + RConf.compiler.AssemblerListingLocation = + RConf.compiler.ObjectFile = "Release\\"; + RConf.librarian.OutputFile = + RConf.linker.OutputFile = RConf.IntermediateDirectory + "\\" + project->first("MSVCPROJ_TARGET"); + RConf.linker.parseOptions(project->variables()["QMAKE_LFLAGS_RELEASE"]); + RConf.compiler.parseOptions(project->variables()["QMAKE_CFLAGS_RELEASE"]); + } else { + DConf.IntermediateDirectory = + DConf.compiler.AssemblerListingLocation = + DConf.compiler.ObjectFile = "Debug\\"; + DConf.librarian.OutputFile = + DConf.linker.OutputFile = DConf.IntermediateDirectory + "\\" + project->first("MSVCPROJ_TARGET"); + DConf.linker.DelayLoadDLLs.clear(); + DConf.compiler.parseOptions(project->variables()["QMAKE_CFLAGS_DEBUG"]); + } + + // Add Debug configuration to project + vcProject.Configuration += DConf; } void VcprojGenerator::initCompilerTool() @@ -456,109 +595,129 @@ void VcprojGenerator::initCompilerTool() if ( placement.isEmpty() ) placement = ".\\"; - vcProject.Configuration.compiler.AssemblerListingLocation = placement ; - vcProject.Configuration.compiler.ProgramDataBaseFileName = placement ; - vcProject.Configuration.compiler.ObjectFile = placement ; - vcProject.Configuration.compiler.PrecompiledHeaderFile = placement + project->first("QMAKE_ORIG_TARGET") + ".pch"; + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.compiler.AssemblerListingLocation = placement ; + RConf.compiler.ProgramDataBaseFileName = ".\\" ; + RConf.compiler.ObjectFile = placement ; + // PCH + if ( usePCH ) { + RConf.compiler.UsePrecompiledHeader = pchUseUsingSpecific; + RConf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch; + RConf.compiler.PrecompiledHeaderThrough = precompHFilename; + RConf.compiler.ForcedIncludeFiles = precompHFilename; + // Minimal build option triggers an Internal Compiler Error + // when used in conjunction with /FI and /Yu, so remove it + project->variables()["QMAKE_CFLAGS_DEBUG"].remove("-Gm"); + project->variables()["QMAKE_CFLAGS_DEBUG"].remove("/Gm"); + project->variables()["QMAKE_CXXFLAGS_DEBUG"].remove("-Gm"); + project->variables()["QMAKE_CXXFLAGS_DEBUG"].remove("/Gm"); + } if ( project->isActiveConfig("debug") ){ // Debug version - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); if ( project->isActiveConfig("thread") ) { if ( (projectTarget == Application) || (projectTarget == StaticLib) ) - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); else - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); } else { - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST_DBG"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); } } else { // Release version - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); - vcProject.Configuration.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; - vcProject.Configuration.compiler.PreprocessorDefinitions += "NDEBUG"; + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); + RConf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; + RConf.compiler.PreprocessorDefinitions += "NDEBUG"; if ( project->isActiveConfig("thread") ) { if ( (projectTarget == Application) || (projectTarget == StaticLib) ) - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); else - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); } else { - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_ST"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); } } // Common for both release and debug if ( project->isActiveConfig("warn_off") ) - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); else if ( project->isActiveConfig("warn_on") ) - vcProject.Configuration.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); if ( project->isActiveConfig("windows") ) - vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; + RConf.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; // Can this be set for ALL configs? // If so, use qmake.conf! if ( projectTarget == SharedLib ) - vcProject.Configuration.compiler.PreprocessorDefinitions += "_WINDOWS"; - - vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; - vcProject.Configuration.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"]; - vcProject.Configuration.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] ); + RConf.compiler.PreprocessorDefinitions += "_WINDOWS"; + + RConf.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; + RConf.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"]; + QStringList::iterator it; + for(it=RConf.compiler.PreprocessorDefinitions.begin(); + it!=RConf.compiler.PreprocessorDefinitions.end(); + ++it) + (*it).replace('\"', """); + + RConf.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] ); } void VcprojGenerator::initLibrarianTool() { - vcProject.Configuration.librarian.OutputFile = project->first( "DESTDIR" ); - if( vcProject.Configuration.librarian.OutputFile.isEmpty() ) - vcProject.Configuration.librarian.OutputFile = ".\\"; + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.librarian.OutputFile = project->first( "DESTDIR" ); + if( RConf.librarian.OutputFile.isEmpty() ) + RConf.librarian.OutputFile = ".\\"; - if( !vcProject.Configuration.librarian.OutputFile.endsWith("\\") ) - vcProject.Configuration.librarian.OutputFile += '\\'; + if( !RConf.librarian.OutputFile.endsWith("\\") ) + RConf.librarian.OutputFile += '\\'; - vcProject.Configuration.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); + RConf.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); } void VcprojGenerator::initLinkerTool() { - vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); - vcProject.Configuration.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); + RConf.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; switch ( projectTarget ) { case Application: - vcProject.Configuration.linker.OutputFile = project->first( "DESTDIR" ); + RConf.linker.OutputFile = project->first( "DESTDIR" ); break; case SharedLib: - vcProject.Configuration.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); - vcProject.Configuration.linker.OutputFile = project->first( "DLLDESTDIR" ); + RConf.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); + RConf.linker.OutputFile = project->first( "DESTDIR" ); break; case StaticLib: //unhandled - added to remove warnings.. break; } - if( vcProject.Configuration.linker.OutputFile.isEmpty() ) - vcProject.Configuration.linker.OutputFile = ".\\"; + if( RConf.linker.OutputFile.isEmpty() ) + RConf.linker.OutputFile = ".\\"; - if( !vcProject.Configuration.linker.OutputFile.endsWith("\\") ) - vcProject.Configuration.linker.OutputFile += '\\'; + if( !RConf.linker.OutputFile.endsWith("\\") ) + RConf.linker.OutputFile += '\\'; - vcProject.Configuration.linker.OutputFile += project->first("MSVCPROJ_TARGET"); - vcProject.Configuration.linker.ProgramDatabaseFile = project->first("OBJECTS_DIR") + project->first("QMAKE_ORIG_TARGET") + ".pdb"; + RConf.linker.OutputFile += project->first("MSVCPROJ_TARGET"); if ( project->isActiveConfig("debug") ){ - vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); } else { - vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); } if ( project->isActiveConfig("dll") ){ - vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); } if ( project->isActiveConfig("console") ){ - vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); } else { - vcProject.Configuration.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); } } @@ -573,32 +732,22 @@ void VcprojGenerator::initCustomBuildTool() void VcprojGenerator::initPreBuildEventTools() { - QString collectionName = project->first("QMAKE_IMAGE_COLLECTION"); - if( !collectionName.isEmpty() ) { - QStringList& list = project->variables()["IMAGES"]; - vcProject.Configuration.preBuild.Description = "Generate imagecollection"; - //vcProject.Configuration.preBuild.AdditionalDependencies += list; - - QFile imgs( ".imgcol" ); - imgs.open( IO_WriteOnly ); - QTextStream s( &imgs ); - QStringList::ConstIterator it = list.begin(); - while( it!=list.end() ) { - s << *it << " "; - it++; - } - - vcProject.Configuration.preBuild.CommandLine = project->first("QMAKE_UIC") + " -embed " + project->first("QMAKE_ORIG_TARGET") + " -f .imgcol -o " + collectionName; - //vcProject.Configuration.preBuild.Outputs = collectionName; - - } } void VcprojGenerator::initPostBuildEventTools() { + VCConfiguration &RConf = vcProject.Configuration[0]; if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) { - vcProject.Configuration.postBuild.Description = var("QMAKE_POST_LINK"); - vcProject.Configuration.postBuild.CommandLine = var("QMAKE_POST_LINK"); + RConf.postBuild.Description = var("QMAKE_POST_LINK"); + RConf.postBuild.CommandLine = var("QMAKE_POST_LINK"); + RConf.postBuild.Description.replace(" && ", " && "); + RConf.postBuild.CommandLine.replace(" && ", " && "); + } + if ( !project->variables()["MSVCPROJ_COPY_DLL"].isEmpty() ) { + if ( !RConf.postBuild.CommandLine.isEmpty() ) + RConf.postBuild.CommandLine += " && "; + RConf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC"); + RConf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL"); } if( project->isActiveConfig( "activeqt" ) ) { QString name = project->first( "QMAKE_ORIG_TARGET" ); @@ -606,34 +755,30 @@ void VcprojGenerator::initPostBuildEventTools() QString objdir = project->first( "OBJECTS_DIR" ); QString idc = project->first( "QMAKE_IDC" ); - vcProject.Configuration.postBuild.Description = "Finalizing ActiveQt server..."; - if ( !vcProject.Configuration.postBuild.CommandLine.isEmpty() ) - vcProject.Configuration.postBuild.CommandLine += " && "; + RConf.postBuild.Description = "Finalizing ActiveQt server..."; + if ( !RConf.postBuild.CommandLine.isEmpty() ) + RConf.postBuild.CommandLine += " && "; if( project->isActiveConfig( "dll" ) ) { // In process - vcProject.Configuration.postBuild.CommandLine += + RConf.postBuild.CommandLine += // call idc to generate .idl file from .dll - idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " -idl " + objdir + name + ".idl -version 1.0 && " + + idc + " "$(TargetPath)" -idl " + objdir + name + ".idl -version 1.0 && " + // call midl to create implementations of the .idl file - project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + - "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + - objdir + "dump.midl && " + + project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb && " + // call idc to replace tlb... - idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb && " + + idc + " "$(TargetPath)" /tlb " + objdir + name + ".tlb && " + // register server - idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /regserver"; + idc + " "$(TargetPath)" /regserver"; } else { // out of process - vcProject.Configuration.postBuild.CommandLine = + RConf.postBuild.CommandLine = // call application to dump idl - vcProject.Configuration.OutputDirectory + "\\" + nameext + " -dumpidl " + objdir + name + ".idl -version 1.0 && " + + ""$(TargetPath)" -dumpidl " + objdir + name + ".idl -version 1.0 && " + // call midl to create implementations of the .idl file - project->first( "QMAKE_IDL" ) + " " + objdir + name + ".idl /nologo /o " + objdir + name + ".midl /tlb " + objdir + name + ".tlb /iid " + objdir + - "dump.midl /dlldata " + objdir + "dump.midl /cstub " + objdir + "dump.midl /header " + objdir + "dump.midl /proxy " + objdir + "dump.midl /sstub " + - objdir + "dump.midl && " + + project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb && " + // call idc to replace tlb... - idc + " " + vcProject.Configuration.OutputDirectory + "\\" + nameext + " /tlb " + objdir + name + ".tlb && " + + idc + " "$(TargetPath)" /tlb " + objdir + name + ".tlb && " + // call app to register - vcProject.Configuration.OutputDirectory + "\\" + nameext + " -regserver"; + ""$(TargetPath)" -regserver"; } } } @@ -642,12 +787,88 @@ void VcprojGenerator::initPreLinkEventTools() { } + +// ------------------------------------------------------------------ +// Helper functions to do proper sorting of the +// qstringlists, for both flat and non-flat modes. +inline bool XLessThanY( QString &x, QString &y, bool flat_mode ) +{ + if ( flat_mode ) { + QString subX = x.mid( x.findRev('\\')+1 ); + QString subY = y.mid( y.findRev('\\')+1 ); + return QString::compare(subX, subY) < 0; + } + + int xPos = 0; + int yPos = 0; + int xSlashPos; + int ySlashPos; + for (;;) { + xSlashPos = x.find('\\', xPos); + ySlashPos = y.find('\\', yPos); + + if (xSlashPos == -1 && ySlashPos != -1) { + return false; + } else if (xSlashPos != -1 && ySlashPos == -1) { + return true; + } else if (xSlashPos == -1 /* && yySlashPos == -1 */) { + QString subX = x.mid(xPos); + QString subY = y.mid(yPos); + return QString::compare(subX, subY) < 0; + } else { + QString subX = x.mid(xPos, xSlashPos - xPos); + QString subY = y.mid(yPos, ySlashPos - yPos); + int cmp = QString::compare(subX, subY); + if (cmp != 0) + return cmp < 0; + } + xPos = xSlashPos + 1; + yPos = ySlashPos + 1; + } + return false; +} +void nonflatDir_BubbleSort( QStringList& list, bool flat_mode ) +{ + QStringList::Iterator b = list.begin(); + QStringList::Iterator e = list.end(); + QStringList::Iterator last = e; + --last; // goto last + if ( last == b ) // shortcut + return; + while( b != last ) {// sort them + bool swapped = FALSE; + QStringList::Iterator swap_pos = b; + QStringList::Iterator x = e; + QStringList::Iterator y = x; + --y; + QString swap_str; + do { + --x; + --y; + if ( XLessThanY(*x,*y, flat_mode) ) { + swapped = TRUE; + swap_str = (*x); // Swap ------- + (*x) = (*y); + (*y) = swap_str; // ------------ + swap_pos = y; + } + } while( y != b ); + if ( !swapped ) + return; + b = swap_pos; + ++b; + } +} +// ------------------------------------------------------------------ + void VcprojGenerator::initSourceFiles() { + vcProject.SourceFiles.flat_files = project->isActiveConfig("flat"); vcProject.SourceFiles.Name = "Source Files"; vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"; vcProject.SourceFiles.Files += project->variables()["SOURCES"]; - vcProject.SourceFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.SourceFiles.Files, + vcProject.SourceFiles.flat_files ); vcProject.SourceFiles.Project = this; vcProject.SourceFiles.Config = &(vcProject.Configuration); vcProject.SourceFiles.CustomBuild = none; @@ -655,10 +876,16 @@ void VcprojGenerator::initSourceFiles() void VcprojGenerator::initHeaderFiles() { + vcProject.HeaderFiles.flat_files = project->isActiveConfig("flat"); vcProject.HeaderFiles.Name = "Header Files"; vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl"; vcProject.HeaderFiles.Files += project->variables()["HEADERS"]; - vcProject.HeaderFiles.Files.sort(); + if (usePCH) { // Generated PCH cpp file + if (!vcProject.HeaderFiles.Files.contains(precompH)) + vcProject.HeaderFiles.Files += precompH; + } + nonflatDir_BubbleSort( vcProject.HeaderFiles.Files, + vcProject.HeaderFiles.flat_files ); vcProject.HeaderFiles.Project = this; vcProject.HeaderFiles.Config = &(vcProject.Configuration); vcProject.HeaderFiles.CustomBuild = moc; @@ -666,10 +893,12 @@ void VcprojGenerator::initHeaderFiles() void VcprojGenerator::initMOCFiles() { + vcProject.MOCFiles.flat_files = project->isActiveConfig("flat"); vcProject.MOCFiles.Name = "Generated MOC Files"; vcProject.MOCFiles.Filter = "cpp;c;cxx;moc"; vcProject.MOCFiles.Files += project->variables()["SRCMOC"]; - vcProject.MOCFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.MOCFiles.Files, + vcProject.MOCFiles.flat_files ); vcProject.MOCFiles.Project = this; vcProject.MOCFiles.Config = &(vcProject.Configuration); vcProject.MOCFiles.CustomBuild = moc; @@ -677,23 +906,27 @@ void VcprojGenerator::initMOCFiles() void VcprojGenerator::initUICFiles() { - vcProject.UICFiles.Name = "Generated UI Files"; + vcProject.UICFiles.flat_files = project->isActiveConfig("flat"); + vcProject.UICFiles.Name = "Generated Form Files"; vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;"; vcProject.UICFiles.Project = this; vcProject.UICFiles.Files += project->variables()["UICDECLS"]; vcProject.UICFiles.Files += project->variables()["UICIMPLS"]; - vcProject.UICFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.UICFiles.Files, + vcProject.UICFiles.flat_files ); vcProject.UICFiles.Config = &(vcProject.Configuration); vcProject.UICFiles.CustomBuild = none; } void VcprojGenerator::initFormsFiles() { + vcProject.FormFiles.flat_files = project->isActiveConfig("flat"); vcProject.FormFiles.Name = "Forms"; vcProject.FormFiles.ParseFiles = _False; vcProject.FormFiles.Filter = "ui"; vcProject.FormFiles.Files += project->variables()["FORMS"]; - vcProject.FormFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.FormFiles.Files, + vcProject.FormFiles.flat_files ); vcProject.FormFiles.Project = this; vcProject.FormFiles.Config = &(vcProject.Configuration); vcProject.FormFiles.CustomBuild = uic; @@ -701,11 +934,13 @@ void VcprojGenerator::initFormsFiles() void VcprojGenerator::initTranslationFiles() { + vcProject.TranslationFiles.flat_files = project->isActiveConfig("flat"); vcProject.TranslationFiles.Name = "Translations Files"; vcProject.TranslationFiles.ParseFiles = _False; vcProject.TranslationFiles.Filter = "ts"; vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"]; - vcProject.TranslationFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.TranslationFiles.Files, + vcProject.TranslationFiles.flat_files ); vcProject.TranslationFiles.Project = this; vcProject.TranslationFiles.Config = &(vcProject.Configuration); vcProject.TranslationFiles.CustomBuild = none; @@ -713,18 +948,22 @@ void VcprojGenerator::initTranslationFiles() void VcprojGenerator::initLexYaccFiles() { + vcProject.LexYaccFiles.flat_files = project->isActiveConfig("flat"); vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; vcProject.LexYaccFiles.ParseFiles = _False; vcProject.LexYaccFiles.Filter = "l;y"; vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"]; vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"]; - vcProject.LexYaccFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.LexYaccFiles.Files, + vcProject.LexYaccFiles.flat_files ); vcProject.LexYaccFiles.Project = this; + vcProject.LexYaccFiles.Config = &(vcProject.Configuration); vcProject.LexYaccFiles.CustomBuild = lexyacc; } void VcprojGenerator::initResourceFiles() { + vcProject.ResourceFiles.flat_files = project->isActiveConfig("flat"); vcProject.ResourceFiles.Name = "Resources"; vcProject.ResourceFiles.ParseFiles = _False; vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; @@ -732,9 +971,11 @@ void VcprojGenerator::initResourceFiles() vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"]; vcProject.ResourceFiles.Files += project->variables()["IMAGES"]; vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"]; - vcProject.ResourceFiles.Files.sort(); + nonflatDir_BubbleSort( vcProject.ResourceFiles.Files, + vcProject.ResourceFiles.flat_files ); vcProject.ResourceFiles.Project = this; - vcProject.ResourceFiles.CustomBuild = none; + vcProject.ResourceFiles.Config = &(vcProject.Configuration); + vcProject.ResourceFiles.CustomBuild = resource; } /* \internal @@ -865,7 +1106,6 @@ void VcprojGenerator::initOld() project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; if ( project->isActiveConfig( "dll" ) ) { project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; - project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE")); } } if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { @@ -939,6 +1179,15 @@ void VcprojGenerator::initOld() if ( project->isActiveConfig("moc") ) setMocAware(TRUE); + // /VERSION:x.yz ------------------------------------------------- + if ( !project->variables()["VERSION"].isEmpty() ) { + QString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + QString major = version.left( firstDot ); + QString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); + } project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; // Update -lname to name.lib, and -Ldir to @@ -949,6 +1198,7 @@ void VcprojGenerator::initOld() it = libList.remove( it ); it = libList.insert( it, s.mid( 2 ) + ".lib" ); } else if( s.startsWith( "-L" ) ) { + project->variables()["QMAKE_LIBDIR"] += (*it).mid(2); it = libList.remove( it ); } else { it++; @@ -1050,31 +1300,28 @@ void VcprojGenerator::initOld() if ( project->first("TARGET").startsWith("$(QTDIR)") ) dest.replace( QRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); project->variables()["MSVCPROJ_TARGET"] = dest; - if ( project->isActiveConfig("dll") ) { - QString imp = project->first( "DESTDIR" ); - if( !imp.isNull() && !imp.endsWith( "\\" ) ) - imp += "\\"; - imp += dest; - imp.replace(QRegExp("\\.dll"), ".lib"); - project->variables()["MSVCPROJ_LIBOPTIONS"] += QString("/IMPLIB:") + imp; - } // DLL COPY ------------------------------------------------------ if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { QStringList dlldirs = project->variables()["DLLDESTDIR"]; - QString copydll = "# Begin Special Build Tool\n" - "TargetPath=" + dest + "\n" - "SOURCE=$(InputPath)\n" - "PostBuild_Desc=Copy DLL to " + project->first("DLLDESTDIR") + "\n" - "PostBuild_Cmds="; - - for ( QStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { - copydll += "copy \"" + dest + "\" \"" + *dlldir + "\"\t"; + QString copydll(""); + QStringList::Iterator dlldir; + for ( dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + if ( !copydll.isEmpty() ) + copydll += " && "; + copydll += "copy "$(TargetPath)" "" + *dlldir + """; } - copydll += "\n# End Special Build Tool"; - project->variables()["MSVCPROJ_COPY_DLL_REL"].append( copydll ); - project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( copydll ); + QString deststr( "Copy " + dest + " to " ); + for ( dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ) { + deststr += *dlldir; + ++dlldir; + if ( dlldir != dlldirs.end() ) + deststr += ", "; + } + + project->variables()["MSVCPROJ_COPY_DLL"].append( copydll ); + project->variables()["MSVCPROJ_COPY_DLL_DESC"].append( deststr ); } // ACTIVEQT ------------------------------------------------------ @@ -1085,18 +1332,17 @@ void VcprojGenerator::initOld() if ( version.isEmpty() ) version = "1.0"; - project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".idl" ); - project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".tlb" ); - project->variables()["MSVCPROJ_IDLSOURCES"].append( "tmp\\" + targetfilename + ".midl" ); + QString objdir = project->first( "OBJECTS_DIR" ); + project->variables()["MSVCPROJ_IDLSOURCES"].append( objdir + targetfilename + ".idl" ); if ( project->isActiveConfig( "dll" ) ) { QString regcmd = "# Begin Special Build Tool\n" "TargetPath=" + targetfilename + "\n" "SOURCE=$(InputPath)\n" "PostBuild_Desc=Finalizing ActiveQt server...\n" "PostBuild_Cmds=" + - idc + " %1 -idl tmp\\" + targetfilename + ".idl -version " + version + - "\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" - "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" + idc + " %1 -idl " + objdir + targetfilename + ".idl -version " + version + + "\t" + idl + " /nologo " + objdir + targetfilename + ".idl /tlb " + objdir + targetfilename + ".tlb" + + "\t" + idc + " %1 /tlb " + objdir + targetfilename + ".tlb" "\tregsvr32 /s %1\n" "# End Special Build Tool"; @@ -1111,9 +1357,9 @@ void VcprojGenerator::initOld() "SOURCE=$(InputPath)\n" "PostBuild_Desc=Finalizing ActiveQt server...\n" "PostBuild_Cmds=" - "%1 -dumpidl tmp\\" + targetfilename + ".idl -version " + version + - "\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" - "\t" + idc + " %1 /tlb tmp\\" + targetfilename + ".tlb" + "%1 -dumpidl " + objdir + targetfilename + ".idl -version " + version + + "\t" + idl + " /nologo " + objdir + targetfilename + ".idl /tlb " + objdir + targetfilename + ".tlb" + "\t" + idc + " %1 /tlb " + objdir + targetfilename + ".tlb" "\t%1 -regserver\n" "# End Special Build Tool"; @@ -1123,9 +1369,11 @@ void VcprojGenerator::initOld() executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); } - } + if ( !project->variables()["DEF_FILE"].isEmpty() ) + project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE")); + // FORMS --------------------------------------------------------- QStringList &list = project->variables()["FORMS"]; for( it = list.begin(); it != list.end(); ++it ) { -- cgit v0.9.0.2