Ignore:
Timestamp:
Jun 17, 2009, 11:30:01 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

qmake: os2/GNUMAKE: Overcome 1024 char CMD.EXE limitation with response files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qmake/generators/os2/gnumake.cpp

    r34 r35  
    338338void GNUMakefileGenerator::writeObjectsPart(QTextStream &t)
    339339{
    340     /* @todo generate response files for the linker to overcome the 1024 chars
    341      * CMD.EXE limitation */
    342340    Win32MakefileGenerator::writeObjectsPart(t);
     341    createLinkerResponseFiles(t);
     342
     343    /* this function is a nice place to also handle compiler options response
     344     * files */
     345    createCompilerResponseFiles(t);
    343346}
    344347
     
    428431}
    429432
     433void GNUMakefileGenerator::writeProjectVarToStream(QTextStream &t, const QString &var)
     434{
     435    QStringList &list = project->values(var);
     436    for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
     437        t << (*it) << endl;
     438    }
     439}
     440
     441QString GNUMakefileGenerator::makeResponseFileName(const QString &base)
     442{
     443    QString fileName = base + "." + var("TARGET");
     444    if (!var("BUILD_NAME").isEmpty()) {
     445        fileName += "." + var("BUILD_NAME");
     446    }
     447    fileName += ".rsp";
     448    QString filePath = project->first("OBJECTS_DIR");
     449    if (filePath.isEmpty())
     450        filePath = Option::output_dir;
     451    filePath = Option::fixPathToTargetOS(filePath + QDir::separator() + fileName);
     452    return filePath;
     453}
     454
     455void GNUMakefileGenerator::createCompilerResponseFiles(QTextStream &t)
     456{
     457    static const char *vars[] = { "CFLAGS",   /*<=*/ "QMAKE_CFLAGS",
     458                                  "CXXFLAGS", /*<=*/ "QMAKE_CXXFLAGS",
     459                                  "INCPATH",  /*<=*/ "INCPATH" };
     460
     461    /* QMAKE_XXX_RSP_VAR is used as a flag whether it is necessary to
     462     * generate response files to overcome the 1024 chars CMD.EXE limitation.
     463     * When this variable is defined, a response file with the relevant
     464     * information will be generated and its full path will be stored in an
     465     * environment variable with the given name which can then be referred to in
     466     * other places of qmake.conf (e.g. rules) */
     467
     468    for (size_t i = 0; i < sizeof(vars)/sizeof(vars[0]); i+=2) {
     469        QString rspVar =
     470            project->first(QString().sprintf("QMAKE_%s_RSP_VAR", vars[i]));
     471        if (!rspVar.isEmpty()) {
     472            QString fileName = makeResponseFileName(vars[i]);
     473            t << rspVar.leftJustified(14) << "= " << fileName << endl;
     474            QFile file(fileName);
     475            if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
     476                QTextStream rt(&file);
     477                writeProjectVarToStream(rt, vars[i+1]);
     478                rt.flush();
     479                file.close();
     480            }
     481            project->values("QMAKE_DISTCLEAN").append("$(" + rspVar + ")");
     482        }
     483    }
     484}
     485
     486void GNUMakefileGenerator::createLinkerResponseFiles(QTextStream &t)
     487{
     488    /* see createCompilerResponseFiles() */
     489    QString var = project->first("QMAKE_OBJECTS_RSP_VAR");
     490    if (!var.isEmpty()) {
     491        QString fileName = makeResponseFileName("OBJECTS");
     492        t << var.leftJustified(14) << "= " << fileName << endl;
     493        QFile file(fileName);
     494        if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
     495            QTextStream rt(&file);
     496            writeProjectVarToStream(rt, "OBJECTS");
     497            rt.flush();
     498            file.close();
     499        }
     500        project->values("QMAKE_DISTCLEAN").append("$(" + var + ")");
     501    }
     502}
     503
    430504QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.