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

📄 msvc_vcproj.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                                break;                            indeps += QByteArray(buff, read_in);                        }                        fclose(proc);                        if(!indeps.isEmpty())                            deps += fileFixify(indeps.replace('\n', ' ').simplified().split(' '));                    }                }            }            vcProject.ResourceFiles.addFiles(deps);        }    }    // You may look again --------------------------------------------    vcProject.ResourceFiles.addFiles(project->values("RESOURCES"));    vcProject.ResourceFiles.addFiles(project->values("IMAGES"));    vcProject.ResourceFiles.Project = this;    vcProject.ResourceFiles.Config = &(vcProject.Configuration);    vcProject.ResourceFiles.CustomBuild = none;}void VcprojGenerator::initExtraCompilerOutputs(){    QStringList otherFilters;    otherFilters << "FORMS"                 << "FORMS3"                 << "GENERATED_FILES"                 << "GENERATED_SOURCES"                 << "HEADERS"                 << "IDLSOURCES"                 << "IMAGES"                 << "LEXSOURCES"                 << "QMAKE_IMAGE_COLLECTION"                 << "RC_FILE"                 << "RESOURCES"                 << "RES_FILE"                 << "SOURCES"                 << "TRANSLATIONS"                 << "YACCSOURCES";    const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");    for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {        QString extracompilerName = project->first((*it) + ".name");        if (extracompilerName.isEmpty())            extracompilerName = (*it);        // Create an extra compiler filter and add the files        VCFilter extraCompile;        extraCompile.Name = extracompilerName;        extraCompile.ParseFiles = _False;        extraCompile.Filter = "";        extraCompile.Guid = QString(_GUIDExtraCompilerFiles) + "-" + (*it);        // If the extra compiler has a variable_out set the output file        // is added to an other file list, and does not need its own..        bool addOnInput = hasBuiltinCompiler(project->first((*it) + ".output"));        QString tmp_other_out = project->first((*it) + ".variable_out");        if (!tmp_other_out.isEmpty() && !addOnInput)            continue;        if (!addOnInput) {            QString tmp_out = project->first((*it) + ".output");            if (project->values((*it) + ".CONFIG").indexOf("combine") != -1) {                // Combined output, only one file result                extraCompile.addFile(                    Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, QString(), QString()), false));            } else {                // One output file per input                QStringList tmp_in = project->values(project->first((*it) + ".input"));                for (int i = 0; i < tmp_in.count(); ++i) {                    const QString &filename = tmp_in.at(i);                    if (extraCompilerSources.contains(filename))                        extraCompile.addFile(                            Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, tmp_out, QString()), false));                }            }        } else {            // In this case we the outputs have a built-in compiler, so we cannot add the custom            // build steps there. So, we turn it around and add it to the input files instead,            // provided that the input file variable is not handled already (those in otherFilters            // are handled, so we avoid them).            QStringList inputVars = project->values((*it) + ".input");            foreach(QString inputVar, inputVars) {                if (!otherFilters.contains(inputVar)) {                    QStringList tmp_in = project->values(inputVar);                    for (int i = 0; i < tmp_in.count(); ++i) {                        const QString &filename = tmp_in.at(i);                        if (extraCompilerSources.contains(filename))                            extraCompile.addFile(                                Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, QString(), QString()), false));                    }                }            }        }        extraCompile.Project = this;        extraCompile.Config = &(vcProject.Configuration);        extraCompile.CustomBuild = none;        vcProject.ExtraCompilersFiles.append(extraCompile);    }}/* \internal    Sets up all needed variables from the environment and all the different caches and .conf files*/void VcprojGenerator::initOld(){    if(init_flag)        return;    init_flag = true;    QStringList::Iterator it;    // Decode version, and add it to $$MSVCPROJ_VERSION --------------    if(!project->values("VERSION").isEmpty()) {        QString version = project->values("VERSION")[0];        int firstDot = version.indexOf(".");        QString major = version.left(firstDot);        QString minor = version.right(version.length() - firstDot - 1);        minor.replace(QRegExp("\\."), "");        project->values("MSVCPROJ_VERSION").append("/VERSION:" + major + "." + minor);        project->values("QMAKE_LFLAGS").append("/VERSION:" + major + "." + minor);    }    project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS"));     // Get filename w/o extension -----------------------------------    QString msvcproj_project = "";    QString targetfilename = "";    if(!project->isEmpty("TARGET")) {        project->values("TARGET") = unescapeFilePaths(project->values("TARGET"));        targetfilename = msvcproj_project = project->first("TARGET");    }    // Init base class too -------------------------------------------    MakefileGenerator::init();    if(msvcproj_project.isEmpty())        msvcproj_project = Option::output.fileName();    msvcproj_project = msvcproj_project.right(msvcproj_project.length() - msvcproj_project.lastIndexOf("\\") - 1);    msvcproj_project = msvcproj_project.left(msvcproj_project.lastIndexOf("."));    msvcproj_project.replace(QRegExp("-"), "");    project->values("MSVCPROJ_PROJECT").append(msvcproj_project);    QStringList &proj = project->values("MSVCPROJ_PROJECT");    for(it = proj.begin(); it != proj.end(); ++it)        (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), "");    // SUBSYSTEM -----------------------------------------------------    if(!project->values("QMAKE_APP_FLAG").isEmpty()) {            project->values("MSVCPROJ_TEMPLATE").append("win32app" + project->first("VCPROJ_EXTENSION"));            if(project->isActiveConfig("console")) {                project->values("MSVCPROJ_CONSOLE").append("CONSOLE");                project->values("MSVCPROJ_WINCONDEF").append("_CONSOLE");                project->values("MSVCPROJ_VCPROJTYPE").append("0x0103");                project->values("MSVCPROJ_SUBSYSTEM").append("CONSOLE");            } else {                project->values("MSVCPROJ_CONSOLE").clear();                project->values("MSVCPROJ_WINCONDEF").append("_WINDOWS");                project->values("MSVCPROJ_VCPROJTYPE").append("0x0101");                project->values("MSVCPROJ_SUBSYSTEM").append("WINDOWS");            }    }    // $$QMAKE.. -> $$MSVCPROJ.. -------------------------------------    project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS");    project->values("MSVCPROJ_LFLAGS") += project->values("QMAKE_LFLAGS");    if(!project->values("QMAKE_LIBDIR").isEmpty()) {        QStringList strl = project->values("QMAKE_LIBDIR");        QStringList::iterator stri;        for(stri = strl.begin(); stri != strl.end(); ++stri) {            if(!(*stri).startsWith("/LIBPATH:"))                (*stri).prepend("/LIBPATH:");        }        project->values("MSVCPROJ_LFLAGS") += strl;    }    project->values("MSVCPROJ_CXXFLAGS") += project->values("QMAKE_CXXFLAGS");    QStringList &incs = project->values("INCLUDEPATH");    for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {        QString inc = (*incit);        if (!inc.startsWith('"') && !inc.endsWith('"'))            inc = QString("\"%1\"").arg(inc); // Quote all paths if not quoted already        project->values("MSVCPROJ_INCPATH").append("-I" + inc);    }    project->values("MSVCPROJ_INCPATH").append("-I" + specdir());    QString dest;    project->values("MSVCPROJ_TARGET") = QStringList(project->first("TARGET"));    Option::fixPathToTargetOS(project->first("TARGET"));    dest = project->first("TARGET") + project->first("TARGET_EXT");    project->values("MSVCPROJ_TARGET") = QStringList(dest);    // DLL COPY ------------------------------------------------------    if(project->isActiveConfig("dll") && !project->values("DLLDESTDIR").isEmpty()) {        QStringList dlldirs = project->values("DLLDESTDIR");        QString copydll("");        QStringList::Iterator dlldir;        for(dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir) {            if(!copydll.isEmpty())                copydll += " && ";            copydll += "copy  \"$(TargetPath)\" \"" + *dlldir + "\"";        }        QString deststr("Copy " + dest + " to ");        for(dlldir = dlldirs.begin(); dlldir != dlldirs.end();) {            deststr += *dlldir;            ++dlldir;            if(dlldir != dlldirs.end())                deststr += ", ";        }        project->values("MSVCPROJ_COPY_DLL").append(copydll);        project->values("MSVCPROJ_COPY_DLL_DESC").append(deststr);    }    if (!project->values("DEF_FILE").isEmpty())        project->values("MSVCPROJ_LFLAGS").append("/DEF:"+project->first("DEF_FILE"));    project->values("QMAKE_INTERNAL_PRL_LIBS") << "MSVCPROJ_LIBS";    // Verbose output if "-d -d"...    outputVariables();}// ------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------QString VcprojGenerator::replaceExtraCompilerVariables(const QString &var, const QStringList &in, const QStringList &out){    QString ret = MakefileGenerator::replaceExtraCompilerVariables(var, in, out);    QStringList &defines = project->values("VCPROJ_MAKEFILE_DEFINES");    if(defines.isEmpty())        defines.append(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") +                       varGlue("DEFINES"," -D"," -D",""));    ret.replace("$(DEFINES)", defines.first());    QStringList &incpath = project->values("VCPROJ_MAKEFILE_INCPATH");    if(incpath.isEmpty() && !this->var("MSVCPROJ_INCPATH").isEmpty())        incpath.append(this->var("MSVCPROJ_INCPATH"));    ret.replace("$(INCPATH)", incpath.join(" "));    return ret;}bool VcprojGenerator::openOutput(QFile &file, const QString &/*build*/) const{    QString outdir;    if(!file.fileName().isEmpty()) {        QFileInfo fi(fileInfo(file.fileName()));        if(fi.isDir())            outdir = file.fileName() + QDir::separator();    }    if(!outdir.isEmpty() || file.fileName().isEmpty()) {        QString ext = project->first("VCPROJ_EXTENSION");        if(project->first("TEMPLATE") == "vcsubdirs")            ext = project->first("VCSOLUTION_EXTENSION");        QString outputName = unescapeFilePath(project->first("TARGET"));        if (!project->first("MAKEFILE").isEmpty())            outputName = project->first("MAKEFILE");        file.setFileName(outdir + outputName + ext);    }    return Win32MakefileGenerator::openOutput(file, QString());}QString VcprojGenerator::fixFilename(QString ofile) const{    ofile = Option::fixPathToLocalOS(ofile);    int slashfind = ofile.lastIndexOf(Option::dir_sep);    if(slashfind == -1) {        ofile = ofile.replace('-', '_');    } else {        int hypenfind = ofile.indexOf('-', slashfind);        while (hypenfind != -1 && slashfind < hypenfind) {            ofile = ofile.replace(hypenfind, 1, '_');            hypenfind = ofile.indexOf('-', hypenfind + 1);        }    }    return ofile;}QString VcprojGenerator::findTemplate(QString file){    QString ret;    if(!exists((ret = file)) &&       !exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) &&       !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc.net/" + file))) &&       !exists((ret = (QString(qgetenv("HOME")) + "/.tmake/" + file))))        return "";    debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.toLatin1().constData());    return ret;}void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l){    if(var == "QMAKE_PRL_DEFINES") {        QStringList &out = project->values("MSVCPROJ_DEFINES");        for(QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {            if(out.indexOf((*it)) == -1)                out.append((" /D " + *it));        }    } else {        MakefileGenerator::processPrlVariable(var, l);    }

⌨️ 快捷键说明

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