Changeset 103 for trunk/qmake


Ignore:
Timestamp:
Aug 12, 2009, 3:19:40 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

mkspecs/os2-g++: 1) Generate a separate rule for the import library (for the split DLL function). 2) Make link_prl work (in particular, automatically add the required libraries from the .prl file of the library to the target that uses it).

Location:
trunk/qmake/generators/os2
Files:
2 edited

Legend:

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

    r94 r103  
    9595}
    9696
     97QString
     98GNUMakefileGenerator::findBestVersion(const QString &d, const QString &stem, const QString &ext)
     99{
     100    QString bd = Option::fixPathToLocalOS(d, true);
     101    if(!exists(bd))
     102        return QString();
     103
     104    QString dllStem = stem + QTDLL_POSTFIX;
     105
     106    QString versionOverride;
     107    if(!project->values("QMAKE_" + stem.toUpper() + "_VERSION_OVERRIDE").isEmpty())
     108        versionOverride = project->values("QMAKE_" + stem.toUpper() + "_VERSION_OVERRIDE").first();
     109
     110    if (project->isActiveConfig("link_prl")) {
     111        QMakeMetaInfo libinfo;
     112        if (libinfo.readLib(bd + Option::dir_sep + dllStem)) {
     113            QString target = libinfo.first("QMAKE_PRL_TARGET");
     114            if (target.isEmpty())
     115                target = stem;
     116            if (!versionOverride.isEmpty())
     117                target += versionOverride;
     118            else if (!libinfo.isEmpty("QMAKE_PRL_VERSION"))
     119                target += libinfo.first("QMAKE_PRL_VERSION").replace(".", "");
     120
     121            const QStringList &in = libinfo.values("QMAKE_PRL_LIBS");
     122            QStringList &out = project->values("QMAKE_INTERNAL_PRL_LIBS");
     123            for (QStringList::ConstIterator it = in.begin(); it != in.end(); ++it) {
     124                if (!out.contains(*it))
     125                    out.append((*it));
     126            }
     127            return target;
     128        }
     129    }
     130
     131    if (!versionOverride.isEmpty())
     132        return stem + versionOverride;
     133
     134    int biggest = -1;
     135    if(!project->isActiveConfig("no_versionlink")) {
     136        QDir dir(bd);
     137        QStringList entries = dir.entryList();
     138        QRegExp regx(QString("((lib)?%1([0-9]*))(%2)$").arg(dllStem).arg(ext), Qt::CaseInsensitive);
     139        for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) {
     140            if(regx.exactMatch((*it))) {
     141                                if (!regx.cap(3).isEmpty()) {
     142                                        bool ok = true;
     143                                        int num = regx.cap(3).toInt(&ok);
     144                                        biggest = qMax(biggest, (!ok ? -1 : num));
     145                                }
     146                        }
     147        }
     148    }
     149    if (biggest != -1)
     150        return stem + QString::number(biggest);
     151
     152    return QString();
     153}
     154
    97155bool GNUMakefileGenerator::findLibraries()
    98156{
     
    107165    }
    108166
    109     QStringList::Iterator it = l.begin();
    110     while (it != l.end()) {
    111         if ((*it).startsWith("-l")) {
    112             QString steam = (*it).mid(2), out;
     167    for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
     168        if((*it).startsWith("-L")) {
     169            dirs.append(QMakeLocalFileName((*it).mid(2)));
     170        } else {
     171            QString stem = *it, out;
     172
     173            if (stem.startsWith("-l"))
     174                stem = stem.mid(2);
     175
    113176            QString suffix;
    114             if (!project->isEmpty("QMAKE_" + steam.toUpper() + "_SUFFIX"))
    115                 suffix = project->first("QMAKE_" + steam.toUpper() + "_SUFFIX");
     177            if (!project->isEmpty("QMAKE_" + stem.toUpper() + "_SUFFIX"))
     178                suffix = project->first("QMAKE_" + stem.toUpper() + "_SUFFIX");
    116179            for (QList<QMakeLocalFileName>::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
    117                 QString extension;
    118                 int ver = findHighestVersion((*dir_it).local(), steam, "dll.lib|lib");
    119                 if (ver != -1)
    120                     extension += QString::number(ver);
    121                 extension += suffix;
    122                 if(QMakeMetaInfo::libExists((*dir_it).local() + Option::dir_sep + steam) ||
    123                     exists((*dir_it).local() + Option::dir_sep + steam + extension + ".lib") ||
    124                     exists((*dir_it).local() + Option::dir_sep + steam + extension + ".dll.lib")) {
    125                         out = (*it) + extension;
    126                         break;
     180                QString best = findBestVersion((*dir_it).local(), stem,
     181                                               QString("%1.lib").arg(suffix));
     182                if (!best.isEmpty()) {
     183                    out = best.prepend("-l");
     184                    break;
    127185                }
    128186            }
    129187            if (!out.isEmpty()) // We assume if it never finds it that its correct
    130                 (*it) = out;
    131             } else if((*it).startsWith("-L")) {
    132             dirs.append(QMakeLocalFileName((*it).mid(2)));
    133         }
    134 
    135         ++it;
    136     }
     188                if (!project->values("QMAKE_LIBS").contains(out))
     189                    (*it) = out;
     190        }
     191    }
     192
     193    QStringList l2 = project->values("QMAKE_INTERNAL_PRL_LIBS");
     194    for (QStringList::ConstIterator it = l2.begin(); it != l2.end(); ++it) {
     195        if (!l.contains(*it))
     196            l.append((*it));
     197    }
     198
    137199    return true;
    138200}
     
    383445            t << "\n\t" << var("QMAKE_RUN_RC2EXE");
    384446        }
    385         if (mode == DLL && !project->isEmpty("QMAKE_RUN_IMPLIB")) {
    386             t << "\n\t" << var("QMAKE_RUN_IMPLIB");
    387         }
    388447    }
    389448    if(!project->isEmpty("QMAKE_POST_LINK"))
     
    399458    if (!project->isEmpty("RES_FILE")) {
    400459        t << "RES_FILE      = " << valList(escapeFilePaths(project->values("RES_FILE"))) << endl;
    401     }
    402     if (mode == DLL && !project->isEmpty("QMAKE_RUN_IMPLIB")) {
    403         t << "TARGET_IMPLIB = $(basename $(DESTDIR_TARGET)).lib" << endl;
    404         project->values("QMAKE_CLEAN").append("$(TARGET_IMPLIB)");
    405460    }
    406461
     
    429484        project->values("POST_TARGETDEPS") += escapeFileVars("$(DEF_FILE)");
    430485    }
     486
     487    if (mode == DLL && !project->isEmpty("QMAKE_RUN_IMPLIB")) {
     488        t << "TARGET_IMPLIB = $(basename $(DESTDIR_TARGET)).lib" << endl;
     489        project->values("QMAKE_CLEAN").append("$(TARGET_IMPLIB)");
     490        project->values("POST_TARGETDEPS") += escapeFileVars("$(TARGET_IMPLIB)");
     491    }
    431492}
    432493
     
    439500    }
    440501
    441     if (project->isEmpty("DEF_FILE") && mode == DLL) {
    442         /* generate a DEF file for the DLL when not supplied */
    443         t << escapeFileVars("$(DEF_FILE): ") << var("QMAKE_GENDEF_DEPS");
    444         t << valGlue(var("QMAKE_RUN_GENDEF").split(";;"), "\n\t", "\n\t", "") << endl;
     502    if (mode == DLL) {
     503        if (project->isEmpty("DEF_FILE")) {
     504            /* generate a DEF file for the DLL when not supplied */
     505            t << escapeFileVars("$(DEF_FILE): ") << var("QMAKE_GENDEF_DEPS");
     506            t << valGlue(var("QMAKE_RUN_GENDEF").split(";;"), "\n\t", "\n\t", "") << endl;
     507        }
     508        if (!project->isEmpty("QMAKE_RUN_IMPLIB")) {
     509            /* generate the import library */
     510            t << escapeFileVars("$(TARGET_IMPLIB): ") << escapeFileVars("$(DEF_FILE)");
     511            t << "\n\t" << var("QMAKE_RUN_IMPLIB") << endl;
     512        }
    445513    }
    446514}
     
    470538void GNUMakefileGenerator::processPrlVariable(const QString &var, const QStringList &l)
    471539{
    472     if (var == "QMAKE_PRL_LIBS") {
    473         QString where = "QMAKE_LIBS";
    474         if (!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
    475             where = project->first("QMAKE_INTERNAL_PRL_LIBS");
    476         QStringList &out = project->values(where);
    477         for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
    478             out.removeAll((*it));
    479             out.append((*it));
    480         }
    481     } else {
    482         Win32MakefileGenerator::processPrlVariable(var, l);
    483     }
     540    // we don't do any processing here; everything we need is done in
     541    // GNUMakefileGenerator::findLibraries()
     542    return;
     543}
     544
     545void GNUMakefileGenerator::processPrlFiles()
     546{
     547    // we don't do any processing here; everything we need is done in
     548    // GNUMakefileGenerator::findLibraries()
     549    return;
    484550}
    485551
  • trunk/qmake/generators/os2/gnumake.h

    r44 r103  
    7171    void processRcFileVar();
    7272    void processPrlVariable(const QString &var, const QStringList &l);
     73    void processPrlFiles();
    7374
    7475    QStringList &findDependencies(const QString &file);
     
    7677    QString preCompHeaderOut;
    7778
     79    QString findBestVersion(const QString &d, const QString &stem, const QString &ext);
    7880    virtual bool findLibraries();
    7981    void fixTargetExt();
Note: See TracChangeset for help on using the changeset viewer.