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

📄 msvc_dsp.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    writeSubFileGroup(t, &root);    return true;}void DspMakefileGenerator::writeSubFileGroup(QTextStream &t, FolderGroup *folder){    t << "# Begin Group \"" << folder->name << "\"" << endl;    t << "# PROP Default_Filter \"" << folder->filter << "\"" << endl;    QMap<QString, FolderGroup *>::const_iterator folderIt = folder->subFolders.begin();    while (folderIt != folder->subFolders.end()) {        writeSubFileGroup(t, folderIt.value());        ++folderIt;    }    QMap<QString, QString>::const_iterator it = folder->files.begin();    while (it != folder->files.end()) {        t << "# Begin Source File" << endl;        t << "SOURCE=" << escapeFilePath(it.key()) << endl;        writeBuildstepForFile(t, it.key(), it.value());        t << "# End Source File" << endl;        t << endl;        ++it;    }    t << "# End Group" << endl;    t << endl;}bool DspMakefileGenerator::writeBuildstepForFile(QTextStream &t, const QString &file, const QString &listName){    if (!mergedProjects.count()) {        t << writeBuildstepForFileForConfig(file, listName, this);        return true;    }    //only add special build rules when needed    QStringList specialBuilds;    int i = 0;    for (i = 0; i < mergedProjects.count(); ++i)        specialBuilds += writeBuildstepForFileForConfig(file, listName, mergedProjects.at(i));    // no special build just return    if (specialBuilds.join("").isEmpty())        return true;    for (i = 0; i < mergedProjects.count(); ++i) {        if (i == 0)            t << "!IF";        else            t << "!ELSEIF";        t << " \"$(CFG)\" == \"" << configName(mergedProjects.at(i)) << "\"" << endl;        t << endl;        t << specialBuilds.at(i);        t << endl;    }    t << "!ENDIF" << endl;    return true;}bool DspMakefileGenerator::writeDspConfig(QTextStream &t, DspMakefileGenerator *config){    bool isDebug = config->project->isActiveConfig("debug");    bool staticLibTarget = config->var("MSVCDSP_DSPTYPE") == "0x0104";    QString outDir = Option::fixPathToTargetOS(config->project->first("DESTDIR"));    while (outDir.endsWith(Option::dir_sep))        outDir.chop(1);    outDir = config->escapeFilePath(outDir);    QString intDir = config->project->first("OBJECTS_DIR");    while (intDir.endsWith(Option::dir_sep))        intDir.chop(1);    intDir = config->escapeFilePath(intDir);    t << "# PROP BASE Use_MFC 0" << endl;    t << "# PROP BASE Use_Debug_Libraries " << (isDebug ? "1" : "0") << endl;    t << "# PROP BASE Output_Dir " << outDir << endl;    t << "# PROP BASE Intermediate_Dir " << intDir << endl;    t << "# PROP BASE Target_Dir \"\"" << endl;    t << "# PROP Use_MFC 0" << endl;    t << "# PROP Use_Debug_Libraries " << (isDebug ? "1" : "0") << endl;    t << "# PROP Output_Dir " << outDir << endl;    t << "# PROP Intermediate_Dir " << intDir << endl;    if (config->project->isActiveConfig("dll") || config->project->isActiveConfig("plugin"))        t << "# PROP Ignore_Export_Lib 1" << endl;    t << "# PROP Target_Dir \"\"" << endl;    t << "# ADD CPP " << config->var("MSVCDSP_INCPATH") << " /c /FD " << config->var("QMAKE_CXXFLAGS") << " " << config->var("MSVCDSP_DEFINES") << " " << config->var("PRECOMPILED_FLAGS") << endl;    t << "# ADD MTL /nologo /mktyplib203 /win32 /D " << (isDebug ? "\"_DEBUG\"" : "\"NDEBUG\"") << endl;    t << "# ADD RSC /l 0x409 /d " << (isDebug ? "\"_DEBUG\"" : "\"NDEBUG\"") << endl;    t << "# ADD BSC32 /nologo" << endl;    if (staticLibTarget) {        t << "LIB32=" << config->var("QMAKE_LIB") << endl;        t << "# ADD LIB32 " << config->var("MSVCDSP_TARGET") << " " << config->var("PRECOMPILED_OBJECT") << endl;    } else {        t << "LINK32=" << config->var("QMAKE_LINK") << endl;        t << "# ADD LINK32 " << config->var("MSVCDSP_LFLAGS") << " " << config->var("MSVCDSP_LIBS") << " " << config->var("MSVCDSP_TARGET") << " " << config->var("PRECOMPILED_OBJECT") << endl;    }    if (!config->project->values("MSVCDSP_PRE_LINK").isEmpty())        t << config->project->values("MSVCDSP_PRE_LINK").first();    if (!config->project->values("MSVCDSP_POST_LINK").isEmpty())        t << config->project->values("MSVCDSP_POST_LINK").first();    return true;}QString DspMakefileGenerator::writeBuildstepForFileForConfig(const QString &file, const QString &listName, DspMakefileGenerator *config){    QString ret;    QTextStream t(&ret);    // exclude from build    if (!config->project->values(listName).contains(file)) {        t << "# PROP Exclude_From_Build 1" << endl;        return ret;    }    if (config->usePCH) {        bool c_file = false;        for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) {            if (file.endsWith(*it)) {                c_file = true;                break;            }        }        if(c_file) {            t << "# SUBTRACT CPP /FI" << config->escapeFilePath(config->namePCH) << " /Yu" << config->escapeFilePath(config->namePCH) << " /Fp" << endl;            return ret;        } else if (config->precompH.endsWith(file)) {            // ### dependency list quickly becomes too long for VS to grok...            t << "USERDEP_" << file << "=" << config->valGlue(config->escapeFilePaths(config->findDependencies(config->precompH)), "", "\t", "") << endl;            t << endl;            t << "# Begin Custom Build - Creating precompiled header from " << file << "..." << endl;            t << "InputPath=.\\" << config->escapeFilePath(file) << endl << endl;            t << config->precompPch + ": $(SOURCE) \"$(IntDir)\" \"$(OUTDIR)\"" << endl;            t << "\t" << config->var("QMAKE_CC") << " /TP /W3 /FD /c /Yc /Fp" << config->precompPch << " /Fo" << config->precompObj << " /Fd\"$(IntDir)\\\\\" " << file << " ";            t << config->var("MSVCDSP_INCPATH") << " " << config->var("MSVCDSP_DEFINES") << " " << config->var("QMAKE_CXXFLAGS") << endl;            t << "# End Custom Build" << endl << endl;            return ret;        }    }    QString fileBase = QFileInfo(file).completeBaseName();    bool hasBuiltin = config->hasBuiltinCompiler(file);    BuildStep allSteps;    if (!config->swappedBuildSteps.contains(file)) {        QStringList compilers = config->project->values("QMAKE_EXTRA_COMPILERS");        for (int i = 0; i < compilers.count(); ++i) {            QString compiler = compilers.at(i);            if (config->project->values(compiler + ".input").isEmpty())                continue;            QString input = config->project->values(compiler + ".input").first();            QStringList inputList = config->project->values(input);            if (!inputList.contains(file))                continue;            QStringList compilerCommands = config->project->values(compiler + ".commands");            QStringList compilerOutput = config->project->values(compiler + ".output");            if (compilerCommands.isEmpty() || compilerOutput.isEmpty())                continue;            QStringList compilerName = config->project->values(compiler + ".name");            if (compilerName.isEmpty())                compilerName << compiler;            QStringList compilerDepends = config->project->values(compiler + ".depends");            QString compilerDependsCommand = config->project->values(compiler + ".depend_command").join(" ");            if (!compilerDependsCommand.isEmpty()) {                if(!config->canExecute(compilerDependsCommand))                    compilerDependsCommand = QString();            }            QStringList compilerConfig = config->project->values(compiler + ".CONFIG");            if (!config->verifyExtraCompiler(compiler, file))                continue;            bool combineAll = compilerConfig.contains("combine");            if (combineAll && inputList.first() != file)                continue;            QString fileIn("$(InputPath)");            if (combineAll && !inputList.isEmpty()) {                fileIn = inputList.join(" ");                compilerDepends += inputList;            }            QString fileOut = compilerOutput.first();            QString fileOutBase = QFileInfo(fileOut).completeBaseName();            fileOut.replace("${QMAKE_FILE_IN}", fileIn);            fileOut.replace("${QMAKE_FILE_BASE}", fileBase);            fileOut.replace("${QMAKE_FILE_OUT_BASE}", fileOutBase);            fileOut.replace('/', '\\');            BuildStep step;            for (int i2 = 0; i2 < compilerDepends.count(); ++i2) {                QString dependency = compilerDepends.at(i2);                dependency.replace("${QMAKE_FILE_IN}", fileIn);                dependency.replace("${QMAKE_FILE_BASE}", fileBase);                dependency.replace("${QMAKE_FILE_OUT_BASE}", fileOutBase);                dependency.replace('/', '\\');                if (!step.deps.contains(dependency, Qt::CaseInsensitive))                    step.deps << dependency;            }            // depends command            if (!compilerDependsCommand.isEmpty() && config->doDepends()) {                char buff[256];                QString dep_cmd = config->replaceExtraCompilerVariables(compilerDependsCommand, file,                    fileOut);                dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false);                if(config->canExecute(dep_cmd)) {                    if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {                        QString indeps;                        while(!feof(proc)) {                            int read_in = (int)fread(buff, 1, 255, proc);                            if(!read_in)                                break;                            indeps += QByteArray(buff, read_in);                        }                        fclose(proc);                        if(!indeps.isEmpty())                            step.deps += config->fileFixify(indeps.replace('\n', ' ').simplified().split(' '));                    }                }            }            QString mappedFile;            if (hasBuiltin) {                mappedFile = fileOut;                fileOut = fileIn;                fileIn = file;            }            step.buildStep += " \\\n\t";            QString command(compilerCommands.join(" "));            // Replace any newlines with proper line-continuance            command.replace("\n", " \\\n\t");            // Might be a macro, and not a valid filename, so the replaceExtraCompilerVariables() would eat it            command.replace("${QMAKE_FILE_IN}", config->escapeFilePath(fileIn));            command.replace("${QMAKE_FILE_BASE}", config->escapeFilePath(fileBase));            command.replace("${QMAKE_FILE_OUT_BASE}", config->escapeFilePath(fileOutBase));            command.replace("${QMAKE_FILE_OUT}", config->escapeFilePath(fileOut));            command = config->replaceExtraCompilerVariables(command, fileIn, fileOut);            step.buildName = compilerName.first();            step.buildStep += command;            step.buildOutputs += fileOut;            if (hasBuiltin) {                step.deps << fileIn;                config->swappedBuildSteps[mappedFile] = step;            } else {                allSteps << step;            }        }    } else {        allSteps << config->swappedBuildSteps.value(file);    }    if (allSteps.buildStep.isEmpty())        return ret;    int i;    QStringList dependencyList;    // remove dependencies that are also output    for (i = 0; i < 1; ++i) {        QStringList buildOutput(allSteps.buildOutputs.at(i));        for (int i2 = 0; i2 < allSteps.deps.count(); ++i2) {            QString dependency = allSteps.deps.at(i2);            if (!buildOutput.contains(dependency) && !dependencyList.contains(dependency))                dependencyList << dependency;        }    }    QString allDependencies = config->valGlue(dependencyList, "", "\t", "");    t << "USERDEP_" << file << "=" << allDependencies << endl;    t << "# PROP Ignore_Default_Tool 1" << endl;    t << "# Begin Custom Build - Running " << allSteps.buildName << " on " << file << endl;    t << "InputPath=" << file << endl;    t << "BuildCmds= " << allSteps.buildStep << endl;    for (i = 0; i < allSteps.buildOutputs.count(); ++i) {        t << config->escapeFilePath(allSteps.buildOutputs.at(i))          << " : $(SOURCE) $(INTDIR) $(OUTDIR)\n\t$(BuildCmds)\n";    }    t << endl;    t << "# End Custom Build" << endl;    return ret;}

⌨️ 快捷键说明

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