⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msvc_vcproj.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.**** This file is part of the qmake application of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://trolltech.com/products/qt/licenses/licensing/opensource/**** If you are unsure which license is appropriate for your use, please** review the following information:** http://trolltech.com/products/qt/licenses/licensing/licensingoverview** or contact the sales department at sales@trolltech.com.**** In addition, as a special exception, Trolltech gives you certain** additional rights. These rights are described in the Trolltech GPL** Exception version 1.0, which can be found at** http://www.trolltech.com/products/qt/gplexception/ and in the file** GPL_EXCEPTION.txt in this package.**** In addition, as a special exception, Trolltech, as the sole copyright** holder for Qt Designer, grants users of the Qt/Eclipse Integration** plug-in the right for the Qt/Eclipse Integration to link to** functionality provided by Qt Designer and its related libraries.**** Trolltech reserves all rights not expressly granted herein.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "msvc_vcproj.h"#include "option.h"#include "xmloutput.h"#include <qdir.h>#include <qcryptographichash.h>#include <qregexp.h>#include <qhash.h>#include <quuid.h>#include <stdlib.h>//#define DEBUG_SOLUTION_GEN//#define DEBUG_PROJECT_GEN// Filter GUIDs (Do NOT change these!) ------------------------------const char _GUIDSourceFiles[]          = "{4FC737F1-C7A5-4376-A066-2A32D752A2FF}";const char _GUIDHeaderFiles[]          = "{93995380-89BD-4b04-88EB-625FBE52EBFB}";const char _GUIDGeneratedFiles[]       = "{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}";const char _GUIDResourceFiles[]        = "{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}";const char _GUIDLexYaccFiles[]         = "{E12AE0D2-192F-4d59-BD23-7D3FA58D3183}";const char _GUIDTranslationFiles[]     = "{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}";const char _GUIDFormFiles[]            = "{99349809-55BA-4b9d-BF79-8FDBB0286EB3}";const char _GUIDExtraCompilerFiles[]   = "{E0D8C965-CC5F-43d7-AD63-FAEF0BBC0F85}";#ifdef Q_OS_WIN32#include <qt_windows.h>struct {    DotNET version;    const char *versionStr;    const char *regKey;} dotNetCombo[] = {#ifdef Q_OS_WIN64    {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"},    {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"},    {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Wow6432Node\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"},#else    {NET2005, "MSVC.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"},    {NET2005, "MSVC 2005 Express Edition(8.0)", "Software\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"},    {NET2003, "MSVC.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"},    {NET2002, "MSVC.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"},#endif    {NETUnknown, "", ""},};static QString keyPath(const QString &rKey){    int idx = rKey.lastIndexOf(QLatin1Char('\\'));    if (idx == -1)        return QString();    return rKey.left(idx + 1);}static QString keyName(const QString &rKey){    int idx = rKey.lastIndexOf(QLatin1Char('\\'));    if (idx == -1)        return rKey;    QString res(rKey.mid(idx + 1));    if (res == "Default" || res == ".")        res = "";    return res;}static QString readRegistryKey(HKEY parentHandle, const QString &rSubkey){    QString rSubkeyName = keyName(rSubkey);    QString rSubkeyPath = keyPath(rSubkey);    HKEY handle = 0;    LONG res;    QT_WA( {        res = RegOpenKeyExW(parentHandle, (WCHAR*)rSubkeyPath.utf16(),                            0, KEY_READ, &handle);    } , {        res = RegOpenKeyExA(parentHandle, rSubkeyPath.toLocal8Bit(),                            0, KEY_READ, &handle);    } );    if (res != ERROR_SUCCESS)        return QString();    // get the size and type of the value    DWORD dataType;    DWORD dataSize;    QT_WA( {        res = RegQueryValueExW(handle, (WCHAR*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize);    }, {        res = RegQueryValueExA(handle, rSubkeyName.toLocal8Bit(), 0, &dataType, 0, &dataSize);    } );    if (res != ERROR_SUCCESS) {        RegCloseKey(handle);        return QString();    }    // get the value    QByteArray data(dataSize, 0);    QT_WA( {        res = RegQueryValueExW(handle, (WCHAR*)rSubkeyName.utf16(), 0, 0,                               reinterpret_cast<unsigned char*>(data.data()), &dataSize);    }, {        res = RegQueryValueExA(handle, rSubkeyName.toLocal8Bit(), 0, 0,                               reinterpret_cast<unsigned char*>(data.data()), &dataSize);    } );    if (res != ERROR_SUCCESS) {        RegCloseKey(handle);        return QString();    }    QString result;    switch (dataType) {        case REG_EXPAND_SZ:        case REG_SZ: {            QT_WA( {                result = QString::fromUtf16(((const ushort*)data.constData()));            }, {                result = QString::fromLatin1(data.constData());            } );            break;        }        case REG_MULTI_SZ: {            QStringList l;            int i = 0;            for (;;) {                QString s;                QT_WA( {                    s = QString::fromUtf16((const ushort*)data.constData() + i);                }, {                    s = QString::fromLatin1(data.constData() + i);                } );                i += s.length() + 1;                if (s.isEmpty())                    break;                l.append(s);            }	    result = l.join(", ");            break;        }        case REG_NONE:        case REG_BINARY: {            QT_WA( {                result = QString::fromUtf16((const ushort*)data.constData(), data.size()/2);            }, {                result = QString::fromLatin1(data.constData(), data.size());            } );            break;        }        case REG_DWORD_BIG_ENDIAN:        case REG_DWORD: {            Q_ASSERT(data.size() == sizeof(int));            int i;            memcpy((char*)&i, data.constData(), sizeof(int));	    result = QString::number(i);            break;        }        default:            qWarning("QSettings: unknown data %d type in windows registry", dataType);            break;    }    RegCloseKey(handle);    return result;}#endifDotNET which_dotnet_version(){#ifndef Q_OS_WIN32    return NET2002; // Always generate 7.0 versions on other platforms#else    // Only search for the version once    static DotNET current_version = NETUnknown;    if(current_version != NETUnknown)        return current_version;    // Fallback to .NET 2002    current_version = NET2002;    QStringList warnPath;    int installed = 0;    int i = 0;    for(; dotNetCombo[i].version; ++i) {        QString path = readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey);        if(!path.isEmpty()) {            ++installed;            current_version = dotNetCombo[i].version;			warnPath += QString("%1").arg(dotNetCombo[i].versionStr);        }    }    if (installed < 2)        return current_version;    // More than one version installed, search directory path    QString paths = qgetenv("PATH");    QStringList pathlist = paths.toLower().split(";");    i = installed = 0;    for(; dotNetCombo[i].version; ++i) {        QString productPath = readRegistryKey(HKEY_LOCAL_MACHINE, dotNetCombo[i].regKey).toLower();		if (productPath.isEmpty())			continue;        QStringList::iterator it;        for(it = pathlist.begin(); it != pathlist.end(); ++it) {            if((*it).contains(productPath)) {                ++installed;                current_version = dotNetCombo[i].version;                warnPath += QString("%1 in path").arg(dotNetCombo[i].versionStr);				break;            }        }    }	switch(installed) {	case 1:		break;	case 0:		warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but"				 " none in your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data());		break;	default:		warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio in"				 " your path! Fallback to lowest version (%s)", warnPath.join(", ").toLatin1().data());		break;	}    return current_version;#endif};// Flatfile Tags ----------------------------------------------------const char _slnHeader70[]       = "Microsoft Visual Studio Solution File, Format Version 7.00";const char _slnHeader71[]       = "Microsoft Visual Studio Solution File, Format Version 8.00";const char _slnHeader80[]       = "Microsoft Visual Studio Solution File, Format Version 9.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                                  // to find the subkey that contains a "PossibleProjectExtension"                                  // containing "vcproj"...                                  // Use the hardcoded value for now so projects generated on other                                  // platforms are actually usable.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|Win32"                                  "\n\t\tConfigName.1 = Release|Win32"                                  "\n\tEndGlobalSection";const char _slnProjDepBeg[]     = "\n\tGlobalSection(ProjectDependencies) = postSolution";const char _slnProjDepEnd[]     = "\n\tEndGlobalSection";const char _slnProjConfBeg[]    = "\n\tGlobalSection(ProjectConfiguration) = postSolution";const char _slnProjRelConfTag1[]= ".Release|Win32.ActiveCfg = Release|Win32";const char _slnProjRelConfTag2[]= ".Release|Win32.Build.0 = Release|Win32";const char _slnProjDbgConfTag1[]= ".Debug|Win32.ActiveCfg = Debug|Win32";const char _slnProjDbgConfTag2[]= ".Debug|Win32.Build.0 = Debug|Win32";const char _slnProjConfEnd[]    = "\n\tEndGlobalSection";const char _slnExtSections[]    = "\n\tGlobalSection(ExtensibilityGlobals) = postSolution"                                  "\n\tEndGlobalSection"                                  "\n\tGlobalSection(ExtensibilityAddIns) = postSolution"                                  "\n\tEndGlobalSection";// ------------------------------------------------------------------VcprojGenerator::VcprojGenerator() : Win32MakefileGenerator(), init_flag(false){}bool VcprojGenerator::writeMakefile(QTextStream &t){    initProject(); // Fills the whole project with proper data    // Generate solution file

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -