Changeset 39


Ignore:
Timestamp:
Jun 19, 2009, 11:36:57 PM (11 years ago)
Author:
Dmitry A. Kuminov
Message:

qmake: os2/GNUMAKE: Added recognition of QMAKE_RUN_LINK, QMAKE_RUN_IMPLIB, QMAKE_RUN_LIB, QMAKE_RUN_RC2RES, QMAKE_RUN_RC2EXE; corrected processing of RC_FILE and RES_FILE.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/mkspecs/os2-g++/qmake.conf

    r35 r39  
    7979QMAKE_LFLAGS_LIB        = -l
    8080
     81!isEmpty(QMAKE_SH) {
     82    QMAKE_RUN_LINK      = $(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(DEF_FILE) $(OBJECTS) $(LIBS)
     83} else {
     84    QMAKE_RUN_LINK      = $(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(DEF_FILE) @$(OBJECTS_RSP) $(LIBS)
     85}
     86QMAKE_RUN_IMPLIB        = emximp -p 64 -o $(basename $(DESTDIR_TARGET)).lib $(DEF_FILE)
     87
    8188QMAKE_LIBS              =
    8289QMAKE_LIBS_CORE         = -lregistry.dll -lsocket
     
    8693QMAKE_LIBS_COMPAT       =
    8794QMAKE_LIBS_QT_ENTRY     =
     95
     96QMAKE_LIB               = emxomfar r
     97!isEmpty(QMAKE_SH) {
     98    QMAKE_RUN_LIB       = $(LIB) $(DESTDIR_TARGET) $(OBJECTS)
     99} else {
     100    QMAKE_RUN_LIB       = $(LIB) $(DESTDIR_TARGET) @$(OBJECTS_RSP)
     101}
    88102
    89103!isEmpty(QMAKE_SH) {
     
    112126
    113127QMAKE_IDL       =
    114 QMAKE_LIB       = emxomfar r
     128QMAKE_ZIP       = zip -r -9
     129
    115130QMAKE_RC        = rc
    116 QMAKE_ZIP       = zip -r -9
     131QMAKE_RUN_RC2RES= set INCLUDE=%INCLUDE%;$(INCLUDEPATH) & $(RC) -n -r $(RC_FILE) $(RES_FILE)
     132QMAKE_RUN_RC2EXE= $(RC) -n -x2 $(RES_FILE) $(DESTDIR_TARGET)
    117133
    118134QMAKE_STRIP     = strip
  • trunk/qmake/generators/os2/gnumake.cpp

    r35 r39  
    5454GNUMakefileGenerator::GNUMakefileGenerator() : Win32MakefileGenerator(), init_flag(false)
    5555{
    56     if (Option::shellPath.isEmpty())
     56    if (isDosLikeShell())
    5757        quote = "\"";
    5858    else
     
    6969}
    7070
    71 QString GNUMakefileGenerator::escapeDependencyPath(const QString &path) const
     71QString GNUMakefileGenerator::escapeFilePath(const QString &path) const
    7272{
    7373    QString ret = path;
    74     ret.remove('\"');
    75     ret.replace('\\', "/");
    76     ret.replace(' ', "\\ ");
     74    if (!isDosLikeShell()) {
     75        ret.remove('\"');
     76        ret.replace('\\', "/");
     77        ret.replace(' ', "\\ ");
     78    } else {
     79        ret.replace(QRegExp("\""), "");
     80        if (ret.contains(QRegExp("[ +&;%]")))
     81            ret = quote + ret + quote;
     82        /* @todo exclude $(var) constructs from quoting like this:
     83         *     $(OBJECTS_DIR)\my file.obj = > $(OBJECTS_DIR)\"my file.obj"
     84         */
     85    }
    7786    return ret;
    7887}
     
    191200    init_flag = true;
    192201
    193     /* this should probably not be here, but I'm using it to wrap the .t files */
    194202    if(project->first("TEMPLATE") == "app")
    195203        project->values("QMAKE_APP_FLAG").append("1");
     
    201209            project->values("QMAKE_COPY_FILE").append("$(COPY)");
    202210        if(project->isEmpty("QMAKE_COPY_DIR"))
    203             project->values("QMAKE_COPY_DIR").append("xcopy /s /q /y /i");
     211            project->values("QMAKE_COPY_DIR").append("$(COPY)");
    204212        if(project->isEmpty("QMAKE_INSTALL_FILE"))
    205213            project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)");
     
    219227    processVars();
    220228
    221     if (!project->values("RES_FILE").isEmpty()) {
    222         project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));
    223     }
    224 
    225229    // LIBS defined in Profile comes first for gcc
    226230    project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS"));
     
    238242            destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false);
    239243    }
    240 
    241     if(!project->values("DEF_FILE").isEmpty())
    242         project->values("QMAKE_LFLAGS").append(QString("-Wl,") + project->first("DEF_FILE"));
    243244
    244245    MakefileGenerator::init();
     
    270271void GNUMakefileGenerator::fixTargetExt()
    271272{
    272     if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
    273         project->values("TARGET_EXT").append(".lib");
    274         project->values("QMAKE_LFLAGS").append("-static");
    275         project->values("TARGET").first() =  "lib" + project->first("TARGET");
    276     } else {
    277         Win32MakefileGenerator::fixTargetExt();
    278     }
     273    Win32MakefileGenerator::fixTargetExt();
    279274}
    280275
     
    287282    QString incsSemicolon;
    288283    for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) {
    289         QString inc = maybeQuotePath(*incit);
     284        QString inc = escapeFilePath(*incit);
    290285        t << " " << opt << inc;
    291286        incsSemicolon += inc + Option::dirlist_sep;
     
    309304        QStringList libs = project->values("QMAKE_LIBS");
    310305        for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) {
    311             QString lib = maybeQuotePath(*it);
     306            QString lib = escapeFilePath(*it);
    312307            /* lib may be prefixed with -l which is commonly used in e.g. PRF
    313308             * (feature) files on all platforms; remove it before prepending
     
    326321    QStringList libDirs = project->values("QMAKE_LIBDIR");
    327322    for(QStringList::Iterator it = libDirs.begin(); it != libDirs.end(); ++it) {
    328         QString libDir = maybeQuotePath(*it);
     323        QString libDir = escapeFilePath(*it);
    329324        /* libDir may be prefixed with -L which is commonly used in e.g. PRF
    330325         * (feature) files on all platforms; remove it before prepending
     
    353348    if(!project->isEmpty("QMAKE_PRE_LINK"))
    354349        t << "\n\t" <<var("QMAKE_PRE_LINK");
    355     if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") {
    356         t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) $(OBJECTS)";
     350    if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) {
     351        /* static library */
     352        t << "\n\t" << var("QMAKE_RUN_LIB");
    357353    } else {
    358         t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)";
     354        /* application or DLL */
     355        t << "\n\t" << var("QMAKE_RUN_LINK");
     356        if (!project->isEmpty("RES_FILE") && !project->isEmpty("QMAKE_RUN_RC2EXE")) {
     357            t << "\n\t" << var("QMAKE_RUN_RC2EXE");
     358        }
     359        if (project->first("TEMPLATE") == "lib") {
     360            if (!project->isEmpty("QMAKE_RUN_IMPLIB"))
     361                t << "\n\t" << var("QMAKE_RUN_IMPLIB");
     362        }
    359363    }
    360364    if(!project->isEmpty("QMAKE_POST_LINK"))
     
    363367}
    364368
    365 void GNUMakefileGenerator::writeRcFilePart(QTextStream &t)
    366 {
    367     const QString rc_file = fileFixify(project->first("RC_FILE"));
    368 
    369     QString incPathStr = fileInfo(rc_file).path();
    370     if (incPathStr != "." && QDir::isRelativePath(incPathStr))
    371         incPathStr.prepend("./");
    372 
    373     if (!rc_file.isEmpty()) {
    374         t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t"
    375           << var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE")
    376           << " --include-dir=" << incPathStr << endl << endl;
    377     }
     369void GNUMakefileGenerator::writeRcAndDefVariables(QTextStream &t)
     370{
     371    if (!project->isEmpty("RC_FILE")) {
     372        t << "RC_FILE       = " << escapeFilePath(var("RC_FILE")) << endl;
     373    }
     374    if (!project->isEmpty("RES_FILE")) {
     375        t << "RES_FILE      = " << valList(escapeFilePaths(project->values("RES_FILE"))) << endl;
     376    }
     377    if (project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") &&
     378        !project->isEmpty( "QMAKE_RUN_IMPLIB")) {
     379        t << "TARGET_IMPLIB = $(basename $(DESTDIR_TARGET)).lib" << endl;
     380        project->values("QMAKE_CLEAN").append( "$(TARGET_IMPLIB)" );
     381    }
     382}
     383
     384void GNUMakefileGenerator::writeRcAndDefPart(QTextStream &t)
     385{
     386    if (!project->isEmpty("RC_FILE") && !project->isEmpty("RES_FILE") &&
     387        !project->isEmpty("QMAKE_RUN_RC2RES")) {
     388        t << "$(RES_FILE): $(RC_FILE)\n\t";
     389        t << var("QMAKE_RUN_RC2RES") << endl;
     390    }
     391}
     392
     393void GNUMakefileGenerator::processRcFileVar()
     394{
     395    if (Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING)
     396        return;
     397
     398    if (!project->values("RC_FILE").isEmpty()) {
     399        if (!project->values("RES_FILE").isEmpty()) {
     400            fprintf(stderr, "Both rc and res file specified.\n");
     401            fprintf(stderr, "Please specify one of them, not both.");
     402            exit(1);
     403        }
     404        project->values("RES_FILE").prepend(escapeFilePath(QString("$(OBJECTS_DIR)") +
     405                                                           QDir::separator() +
     406                                                           QFileInfo(var("RC_FILE")).baseName() +
     407                                                           ".res"));
     408        project->values("CLEAN_FILES") += "$(RES_FILE)";
     409    }
     410
     411    if (!project->values("RES_FILE").isEmpty())
     412        project->values("POST_TARGETDEPS") += "$(RES_FILE)";
    378413}
    379414
     
    421456}
    422457
    423 QString GNUMakefileGenerator::maybeQuotePath(const QString &path)
    424 {
    425     QString quoted = path;
    426     quoted.replace(QRegExp("\\\\$"), "");
    427     quoted.replace(QRegExp("\""), "");
    428     if (quoted.contains(QRegExp("[ +&;$%()]")))
    429         quoted = quote + quoted + quote;
    430     return quoted;
    431 }
    432 
    433458void GNUMakefileGenerator::writeProjectVarToStream(QTextStream &t, const QString &var)
    434459{
     
    475500            if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
    476501                QTextStream rt(&file);
    477                 writeProjectVarToStream(rt, vars[i+1]);
     502                if (!qstrcmp(vars[i+1], "INCPATH")) {
     503                    QString opt = var("QMAKE_CFLAGS_INCDIR");
     504                    rt << varGlue(vars[i+1], opt, "\n" + opt, QString::null);
     505                } else
     506                    rt << varGlue(vars[i+1], QString::null, "\n", QString::null);
    478507                rt.flush();
    479508                file.close();
     
    494523        if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
    495524            QTextStream rt(&file);
    496             writeProjectVarToStream(rt, "OBJECTS");
     525            rt << varGlue("OBJECTS", QString::null, "\n", QString::null);
    497526            rt.flush();
    498527            file.close();
  • trunk/qmake/generators/os2/gnumake.h

    r35 r39  
    5555    ~GNUMakefileGenerator();
    5656protected:
    57     QString escapeDependencyPath(const QString &path) const;
     57    QString escapeFilePath(const QString &path) const;
    5858    QString getLibTarget();
    5959private:
     
    6666    void writeObjectsPart(QTextStream &t);
    6767    void writeBuildRulesPart(QTextStream &t);
    68     void writeRcFilePart(QTextStream &t);
     68    void writeRcAndDefVariables(QTextStream &t);
     69    void writeRcAndDefPart(QTextStream &t);
    6970    void init();
     71    void processRcFileVar();
    7072    void processPrlVariable(const QString &var, const QStringList &l);
    7173
     
    7678    virtual bool findLibraries();
    7779    void fixTargetExt();
    78 
    79     QString maybeQuotePath(const QString &path);
    8080
    8181    void writeProjectVarToStream(QTextStream &t, const QString &var);
Note: See TracChangeset for help on using the changeset viewer.