Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/qmake/generators/symbian/symmake.cpp

    r651 r769  
    5050#include <qdebug.h>
    5151
     52// Included from tools/shared
     53#include <symbian/epocroot.h>
     54
    5255#define RESOURCE_DIRECTORY_MMP "/resource/apps"
    5356#define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\"
     
    5558#define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def"
    5659#define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonU.def"
    57 #define BLD_INF_FILENAME_LEN (sizeof(BLD_INF_FILENAME) - 1)
    5860
    5961#define BLD_INF_RULES_BASE "BLD_INF_RULES."
     
    6264#define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
    6365#define BLD_INF_TAG_EXTENSIONS "prj_extensions"
    64 #define BLD_INF_TAG_EXPORTS "prj_exports"
     66#define BLD_INF_TAG_TESTEXTENSIONS "prj_testextensions"
    6567
    6668#define RSS_RULES "RSS_RULES"
     
    6870#define RSS_TAG_NBROFICONS "number_of_icons"
    6971#define RSS_TAG_ICONFILE "icon_file"
     72#define RSS_TAG_HEADER "header"
     73#define RSS_TAG_SERVICE_LIST "service_list"
     74#define RSS_TAG_FILE_OWNERSHIP_LIST "file_ownership_list"
     75#define RSS_TAG_DATATYPE_LIST "datatype_list"
     76#define RSS_TAG_FOOTER "footer"
     77#define RSS_TAG_DEFAULT "default_rules" // Same as just giving rules without tag
    7078
    7179#define MMP_TARGET "TARGET"
    7280#define MMP_TARGETTYPE "TARGETTYPE"
    7381#define MMP_SECUREID "SECUREID"
    74 #define MMP_OPTION_CW "OPTION CW"
    75 #define MMP_OPTION_ARMCC "OPTION ARMCC"
    76 #define MMP_OPTION_GCCE "OPTION GCCE"
    77 #define MMP_LINKEROPTION_CW "LINKEROPTION CW"
    78 #define MMP_LINKEROPTION_ARMCC "LINKEROPTION ARMCC"
    79 #define MMP_LINKEROPTION_GCCE "LINKEROPTION GCCE"
     82#define MMP_OPTION "OPTION"
     83#define MMP_LINKEROPTION "LINKEROPTION"
    8084#define MMP_CAPABILITY "CAPABILITY"
    8185#define MMP_EPOCALLOWDLLDATA "EPOCALLOWDLLDATA"
     
    8892#define MMP_END_RESOURCE "END"
    8993
     94#define VAR_CXXFLAGS "QMAKE_CXXFLAGS"
     95#define VAR_CFLAGS "QMAKE_CFLAGS"
     96#define VAR_LFLAGS "QMAKE_LFLAGS"
     97
    9098#define SIS_TARGET "sis"
    9199#define INSTALLER_SIS_TARGET "installer_sis"
     100#define ROM_STUB_SIS_TARGET "stub_sis"
    92101#define OK_SIS_TARGET "ok_sis"
    93102#define OK_INSTALLER_SIS_TARGET "ok_installer_sis"
     103#define OK_ROM_STUB_SIS_TARGET "ok_stub_sis"
    94104#define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg"
    95105#define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache"
     
    106116    static QString epocRootStr;
    107117    if (epocRootStr.isEmpty()) {
    108         QFileInfo efi(epocRoot());
    109         epocRootStr = efi.canonicalFilePath();
    110         if (epocRootStr.isEmpty()) {
     118        epocRootStr = epocRoot();
     119        QFileInfo efi(epocRootStr);
     120        if (!efi.exists() || epocRootStr.isEmpty()) {
    111121            fprintf(stderr, "Unable to resolve epocRoot '%s' to real dir on current drive, defaulting to '/' for mmp paths\n", qPrintable(epocRoot()));
    112122            epocRootStr = "/";
     123        } else {
     124            epocRootStr = efi.absoluteFilePath();
    113125        }
    114126        if (!epocRootStr.endsWith("/"))
     
    134146}
    135147
    136 QString SymbianMakefileGenerator::canonizePath(const QString& origPath)
    137 {
    138     // Since current path gets appended almost always anyway, use it as default
    139     // for nonexisting paths.
    140     static QString defaultPath;
    141     if (defaultPath.isEmpty()) {
    142         QFileInfo fi(".");
    143         defaultPath = fi.canonicalFilePath();
    144     }
    145 
     148QString SymbianMakefileGenerator::absolutizePath(const QString& origPath)
     149{
    146150    // Prepend epocroot to any paths beginning with "/epoc32/"
    147151    QString resultPath = QDir::fromNativeSeparators(origPath);
     
    150154
    151155    QFileInfo fi(fileInfo(resultPath));
    152     if (fi.isDir()) {
    153         resultPath = fi.canonicalFilePath();
     156
     157    // Since origPath can be something given in HEADERS, we need to check if we are dealing
     158    // with a file or a directory. In case the origPath doesn't yet exist, isFile() returns
     159    // false and we default to assuming it is a dir.
     160    if (fi.isFile()) {
     161        resultPath = fi.absolutePath();
    154162    } else {
    155         resultPath = fi.canonicalPath();
     163        resultPath = fi.absoluteFilePath();
    156164    }
    157165
    158166    resultPath = QDir::cleanPath(resultPath);
    159 
    160     if (resultPath.isEmpty())
    161         resultPath = defaultPath;
    162167
    163168    return resultPath;
     
    202207    QString numberOfIcons;
    203208    QString iconFile;
    204     QStringList userRssRules;
     209    QMap<QString, QStringList> userRssRules;
    205210    readRssRules(numberOfIcons, iconFile, userRssRules);
    206211
     
    235240    QString outputFileName = fileInfo(Option::output.fileName()).fileName();
    236241    if (outputFileName != BLD_INF_FILENAME) {
    237         wrapperFileName.append(".").append((outputFileName.size() > BLD_INF_FILENAME_LEN && outputFileName.left(BLD_INF_FILENAME_LEN) == BLD_INF_FILENAME) ? outputFileName.mid(8) : outputFileName);
     242        wrapperFileName.append(".").append(outputFileName.startsWith(BLD_INF_FILENAME)
     243                                           ? outputFileName.mid(sizeof(BLD_INF_FILENAME))
     244                                           : outputFileName);
    238245        isPrimaryMakefile = false;
    239246    }
     
    269276
    270277    if (targetType == TypeExe) {
    271         if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
     278        if (!project->isActiveConfig("no_icon")) {
    272279            writeRegRssFile(userRssRules);
    273280            writeRssFile(numberOfIcons, iconFile);
     
    316323
    317324    // Construct QStringList from pkg_prerules since we need search it before printed to file
     325    // Note: Though there can't be more than one language or header line, use stringlists
     326    // in case user wants comments to go with the rules.
    318327    QStringList rawPkgPreRules;
     328    QStringList languageRules;
     329    QStringList headerRules;
    319330    foreach(QString deploymentItem, project->values("DEPLOYMENT")) {
    320331        foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_prerules")) {
     
    323334            // This is convenience for defining single line mmp statements
    324335            if (pkgrulesValue.isEmpty()) {
    325                 rawPkgPreRules << pkgrulesItem;
     336                if (pkgrulesItem.startsWith("&"))
     337                    languageRules << pkgrulesItem;
     338                else if (pkgrulesItem.startsWith("#"))
     339                    headerRules << pkgrulesItem;
     340                else
     341                    rawPkgPreRules << pkgrulesItem;
    326342            } else {
    327                 foreach(QString pkgrule, pkgrulesValue) {
    328                     rawPkgPreRules << pkgrule;
     343                if (containsStartWithItem('&', pkgrulesValue)) {
     344                    foreach(QString pkgrule, pkgrulesValue) {
     345                        languageRules << pkgrule;
     346                    }
     347                } else if (containsStartWithItem('#', pkgrulesValue)) {
     348                    foreach(QString pkgrule, pkgrulesValue) {
     349                        headerRules << pkgrule;
     350                    }
     351                } else {
     352                    foreach(QString pkgrule, pkgrulesValue) {
     353                        rawPkgPreRules << pkgrule;
     354                    }
    329355                }
    330356            }
     
    334360    // Apply some defaults if specific data does not exist in PKG pre-rules
    335361
    336     if (!containsStartWithItem('&', rawPkgPreRules)) {
     362    if (languageRules.isEmpty()) {
    337363        // language, (*** hardcoded to english atm, should be parsed from TRANSLATIONS)
    338         QString languageCode = "; Language\n&EN\n\n";
    339         t << languageCode;
    340         tw << languageCode;
    341     } else {
     364        languageRules << "; Language\n&EN\n\n";
     365    } else if (headerRules.isEmpty()) {
    342366        // In case user defines langs, he must take care also about SIS header
    343         if (!containsStartWithItem('#', rawPkgPreRules))
    344             fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n");
    345     }
     367        fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n");
     368    }
     369
     370    t << languageRules.join("\n") << endl;
     371    tw << languageRules.join("\n") << endl;
    346372
    347373    // name of application, UID and version
     
    358384    }
    359385
    360     if (!containsStartWithItem('#', rawPkgPreRules)) {
     386    if (headerRules.isEmpty())
    361387        t << sisHeader.arg(visualTarget).arg(uid3).arg(applicationVersion);
    362     }
     388    else
     389        t << headerRules.join("\n") << endl;
    363390
    364391    // Localized vendor name
     
    425452
    426453        // deploy rsc & reg_rsc file
    427         if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
     454        if (!project->isActiveConfig("no_icon")) {
    428455            t << QString("\"%1epoc32/data/z/resource/apps/%2\"    - \"%3\\%4\"")
    429456                 .arg(epocRoot())
     
    450477    QString remoteTestPath;
    451478    remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid);
     479    QString zDir = epocRoot() + QLatin1String("epoc32/data/z");
    452480
    453481    initProjectDeploySymbian(project, depList, remoteTestPath, true, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles);
     
    455483        t << "; DEPLOYMENT" << endl;
    456484    for (int i = 0; i < depList.size(); ++i)  {
    457         t << QString("\"%1\"    - \"%2\"")
    458              .arg(QString(depList.at(i).from).replace('\\','/'))
    459              .arg(depList.at(i).to) << endl;
     485        QString from = depList.at(i).from;
     486        QString to = depList.at(i).to;
     487
     488        // Deploy anything not already deployed from under epoc32 instead from under
     489        // \epoc32\data\z\ to enable using pkg file without rebuilding
     490        // the project, which can be useful for some binary only distributions.
     491        if (!from.contains(QLatin1String("epoc32"), Qt::CaseInsensitive)) {
     492            from = to;
     493            if (from.size() > 1 && from.at(1) == QLatin1Char(':'))
     494                from = from.mid(2);
     495            from.prepend(zDir);
     496        } else {
     497            if (from.size() > 1 && from.at(1) == QLatin1Char(':'))
     498                from = from.mid(2);
     499        }
     500
     501        t << QString("\"%1\"    - \"%2\"").arg(from.replace('\\','/')).arg(to) << endl;
    460502    }
    461503    t << endl;
     
    542584void SymbianMakefileGenerator::writeCustomDefFile()
    543585{
    544     if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
     586    if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) {
    545587        // Create custom def file for plugin
    546588        QFile ft(QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL));
     
    607649    else if ((project->values("TEMPLATE")).contains("lib")) {
    608650        // Check CONFIG to see if we are to build staticlib or dll
    609         if (project->values("CONFIG").contains("staticlib") || project->values("CONFIG").contains("static"))
     651        if (project->isActiveConfig("staticlib") || project->isActiveConfig("static"))
    610652            targetType = TypeLib;
    611         else if (project->values("CONFIG").contains("plugin"))
     653        else if (project->isActiveConfig("plugin"))
    612654            targetType = TypePlugin;
    613655        else
     
    619661    if (0 != project->values("TARGET.UID2").size()) {
    620662        uid2 = project->first("TARGET.UID2");
    621     } else if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
     663    } else if (project->isActiveConfig("stdbinary")) {
    622664        uid2 = "0x20004C45";
    623665    } else {
     
    690732
    691733    QDir current = QDir::current();
    692     QString canonizedCurrent = canonizePath(".");
     734    QString absolutizedCurrent = absolutizePath(".");
    693735
    694736    for (int j = 0; j < srcpaths.size(); ++j) {
     
    698740            if (fi.filePath().length() > fi.fileName().length()) {
    699741                appendIfnotExist(srcincpaths, fi.path());
    700                 sources[canonizePath(fi.path())] += fi.fileName();
     742                sources[absolutizePath(fi.path())] += fi.fileName();
    701743            } else {
    702                 sources[canonizedCurrent] += fi.fileName();
    703                 appendIfnotExist(srcincpaths, canonizedCurrent);
     744                sources[absolutizedCurrent] += fi.fileName();
     745                appendIfnotExist(srcincpaths, absolutizedCurrent);
    704746            }
    705747        }
     
    715757
    716758    for (int j = 0; j < incpaths.size(); ++j) {
    717         QString includepath = canonizePath(incpaths.at(j));
     759        QString includepath = absolutizePath(incpaths.at(j));
    718760        appendIfnotExist(sysincspaths, includepath);
    719761        appendAbldTempDirs(sysincspaths, includepath);
     
    757799    bool inResourceBlock = false;
    758800
    759     overridableMmpKeywords << QLatin1String(MMP_TARGETTYPE);
     801    overridableMmpKeywords << QLatin1String(MMP_TARGETTYPE) << QLatin1String(MMP_EPOCHEAPSIZE);
    760802    restrictableMmpKeywords << QLatin1String(MMP_TARGET) << QLatin1String(MMP_SECUREID)
    761        << QLatin1String(MMP_OPTION_CW) << QLatin1String(MMP_OPTION_ARMCC)
    762        << QLatin1String(MMP_OPTION_GCCE) << QLatin1String(MMP_LINKEROPTION_CW)
    763        << QLatin1String(MMP_LINKEROPTION_ARMCC) << QLatin1String(MMP_LINKEROPTION_GCCE)
     803       << QLatin1String(MMP_OPTION) << QLatin1String(MMP_LINKEROPTION)
    764804       << QLatin1String(MMP_CAPABILITY) << QLatin1String(MMP_EPOCALLOWDLLDATA)
    765        << QLatin1String(MMP_EPOCHEAPSIZE) << QLatin1String(MMP_EPOCSTACKSIZE)
    766        << QLatin1String(MMP_UID) << QLatin1String(MMP_VENDORID)
    767        << QLatin1String(MMP_VERSION);
     805       << QLatin1String(MMP_EPOCSTACKSIZE) << QLatin1String(MMP_UID)
     806       << QLatin1String(MMP_VENDORID) << QLatin1String(MMP_VERSION);
    768807
    769808    foreach (QString item, project->values("MMP_RULES")) {
     
    886925        t << endl;
    887926
    888         if (!project->values("CONFIG").contains("static") && !project->values("CONFIG").contains("staticlib")) {
     927        if (!project->isActiveConfig("static") && !project->isActiveConfig("staticlib")) {
    889928            writeMmpFileLibraryPart(t);
    890929        }
     
    935974{
    936975    bool skipTargetType = overriddenMmpKeywords.contains(MMP_TARGETTYPE);
     976    bool skipEpocHeapSize = overriddenMmpKeywords.contains(MMP_EPOCHEAPSIZE);
    937977
    938978    if (targetType == TypeExe) {
    939979        t << MMP_TARGET "\t\t" << fixedTarget << ".exe" << endl;
    940980        if (!skipTargetType) {
    941             if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
     981            if (project->isActiveConfig("stdbinary"))
    942982                t << MMP_TARGETTYPE "\t\tSTDEXE" << endl;
    943983            else
     
    947987        t << MMP_TARGET "\t\t" << fixedTarget << ".dll" << endl;
    948988        if (!skipTargetType) {
    949             if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
     989            if (project->isActiveConfig("stdbinary"))
    950990                t << MMP_TARGETTYPE "\t\tSTDDLL" << endl;
    951991            else
     
    955995        t << MMP_TARGET "\t\t" << fixedTarget << ".lib" << endl;
    956996        if (!skipTargetType) {
    957             if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
     997            if (project->isActiveConfig("stdbinary"))
    958998                t << MMP_TARGETTYPE "\t\tSTDLIB" << endl;
    959999            else
     
    9861026    if (0 != project->first("TARGET.EPOCSTACKSIZE").size())
    9871027        t << MMP_EPOCSTACKSIZE "\t\t" << project->first("TARGET.EPOCSTACKSIZE") << endl;
    988     if (0 != project->values("TARGET.EPOCHEAPSIZE").size())
     1028    if (!skipEpocHeapSize && 0 != project->values("TARGET.EPOCHEAPSIZE").size())
    9891029        t << MMP_EPOCHEAPSIZE "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl;
    9901030    if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size())
    9911031        t << MMP_EPOCALLOWDLLDATA << endl;
    9921032
    993     if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
     1033    if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) {
    9941034        // Use custom def file for Qt plugins
    9951035        t << "DEFFILE " PLUGIN_COMMON_DEF_FILE_FOR_MMP << endl;
     
    10071047{
    10081048    if ((targetType == TypeExe) &&
    1009             !project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
     1049            !project->isActiveConfig("no_icon")) {
    10101050
    10111051        QString locTarget = fixedTarget;
     
    11111151}
    11121152
     1153void SymbianMakefileGenerator::writeMmpFileConditionalOptions(QTextStream& t,
     1154                                                              const QString &optionType,
     1155                                                              const QString &optionTag,
     1156                                                              const QString &variableBase)
     1157{
     1158    foreach(QString compilerVersion, project->values("VERSION_FLAGS." + optionTag)) {
     1159        QStringList currentValues = project->values(variableBase + "." + compilerVersion);
     1160        if (currentValues.size()) {
     1161            t << "#if defined(" << compilerVersion << ")" << endl;
     1162            t << optionType << " " << optionTag << " " << currentValues.join(" ") <<  endl;
     1163            t << "#endif" << endl;
     1164        }
     1165    }
     1166}
     1167
     1168void SymbianMakefileGenerator::writeMmpFileSimpleOption(QTextStream& t,
     1169                                                        const QString &optionType,
     1170                                                        const QString &optionTag,
     1171                                                        const QString &options)
     1172{
     1173    QString trimmedOptions = options.trimmed();
     1174    if (!trimmedOptions.isEmpty())
     1175        t << optionType << " " << optionTag << " " << trimmedOptions << endl;
     1176}
     1177
     1178void SymbianMakefileGenerator::appendMmpFileOptions(QString &options, const QStringList &list)
     1179{
     1180    if (list.size()) {
     1181        options.append(list.join(" "));
     1182        options.append(" ");
     1183    }
     1184}
     1185
    11131186void SymbianMakefileGenerator::writeMmpFileCompilerOptionPart(QTextStream& t)
    11141187{
    1115     QString cw, armcc, gcce;
    1116     QString cwlink, armlink, gccelink;
    1117 
    1118     if (0 != project->values("QMAKE_CXXFLAGS.CW").size()) {
    1119         cw.append(project->values("QMAKE_CXXFLAGS.CW").join(" "));
    1120         cw.append(" ");
    1121     }
    1122 
    1123     if (0 != project->values("QMAKE_CXXFLAGS.ARMCC").size()) {
    1124         armcc.append(project->values("QMAKE_CXXFLAGS.ARMCC").join(" "));
    1125         armcc.append(" ");
    1126     }
    1127 
    1128     if (0 != project->values("QMAKE_CXXFLAGS.GCCE").size()) {
    1129         gcce.append(project->values("QMAKE_CXXFLAGS.GCCE").join(" "));
    1130         gcce.append(" ");
    1131     }
    1132 
    1133     if (0 != project->values("QMAKE_CFLAGS.CW").size()) {
    1134         cw.append(project->values("QMAKE_CFLAGS.CW").join(" "));
    1135         cw.append(" ");
    1136     }
    1137 
    1138     if (0 != project->values("QMAKE_CFLAGS.ARMCC").size()) {
    1139         armcc.append(project->values("QMAKE_CFLAGS.ARMCC").join(" "));
    1140         armcc.append(" ");
    1141     }
    1142 
    1143     if (0 != project->values("QMAKE_CFLAGS.GCCE").size()) {
    1144         gcce.append(project->values("QMAKE_CXXFLAGS.GCCE").join(" "));
    1145         gcce.append(" ");
    1146     }
    1147 
    1148     if (0 != project->values("QMAKE_CXXFLAGS").size()) {
    1149         cw.append(project->values("QMAKE_CXXFLAGS").join(" "));
    1150         cw.append(" ");
    1151         armcc.append(project->values("QMAKE_CXXFLAGS").join(" "));
    1152         armcc.append(" ");
    1153         gcce.append(project->values("QMAKE_CXXFLAGS").join(" "));
    1154         gcce.append(" ");
    1155     }
    1156 
    1157     if (0 != project->values("QMAKE_CFLAGS").size()) {
    1158         cw.append(project->values("QMAKE_CFLAGS").join(" "));
    1159         cw.append(" ");
    1160         armcc.append(project->values("QMAKE_CFLAGS").join(" "));
    1161         armcc.append(" ");
    1162         gcce.append(project->values("QMAKE_CFLAGS").join(" "));
    1163         gcce.append(" ");
    1164     }
    1165 
    1166     if (0 != project->values("QMAKE_LFLAGS.CW").size()) {
    1167         cwlink.append(project->values("QMAKE_LFLAGS.CW").join(" "));
    1168         cwlink.append(" ");
    1169     }
    1170 
    1171     if (0 != project->values("QMAKE_LFLAGS.ARMCC").size()) {
    1172         armlink.append(project->values("QMAKE_LFLAGS.ARMCC").join(" "));
    1173         armlink.append(" ");
    1174     }
    1175 
    1176     if (0 != project->values("QMAKE_LFLAGS.GCCE").size()) {
    1177         gccelink.append(project->values("QMAKE_LFLAGS.GCCE").join(" "));
    1178         gccelink.append(" ");
    1179     }
    1180 
    1181     if (0 != project->values("QMAKE_LFLAGS").size()) {
    1182         cwlink.append(project->values("QMAKE_LFLAGS").join(" "));
    1183         cwlink.append(" ");
    1184         armlink.append(project->values("QMAKE_LFLAGS").join(" "));
    1185         armlink.append(" ");
    1186         gccelink.append(project->values("QMAKE_LFLAGS").join(" "));
    1187         gccelink.append(" ");
    1188     }
    1189 
    1190     if (!cw.isEmpty() && cw[cw.size()-1] == ' ')
    1191         cw.chop(1);
    1192     if (!armcc.isEmpty() && armcc[armcc.size()-1] == ' ')
    1193         armcc.chop(1);
    1194     if (!gcce.isEmpty() && gcce[gcce.size()-1] == ' ')
    1195         gcce.chop(1);
    1196     if (!cwlink.isEmpty() && cwlink[cwlink.size()-1] == ' ')
    1197         cwlink.chop(1);
    1198     if (!armlink.isEmpty() && armlink[armlink.size()-1] == ' ')
    1199         armlink.chop(1);
    1200     if (!gccelink.isEmpty() && gccelink[gccelink.size()-1] == ' ')
    1201         gccelink.chop(1);
    1202 
    1203     if (!cw.isEmpty())
    1204         t << MMP_OPTION_CW " " << cw <<  endl;
    1205     if (!armcc.isEmpty())
    1206         t << MMP_OPTION_ARMCC " " << armcc <<  endl;
    1207     if (!gcce.isEmpty())
    1208         t << MMP_OPTION_GCCE " " << gcce <<  endl;
    1209 
    1210     if (!cwlink.isEmpty())
    1211         t << MMP_LINKEROPTION_CW " " << cwlink <<  endl;
    1212     if (!armlink.isEmpty())
    1213         t << MMP_LINKEROPTION_ARMCC " " << armlink <<  endl;
    1214     if (!gccelink.isEmpty())
    1215         t << MMP_LINKEROPTION_GCCE " " << gccelink <<  endl;
     1188    QStringList keywords =  project->values("MMP_OPTION_KEYWORDS");
     1189    QStringList commonCxxFlags = project->values(VAR_CXXFLAGS);
     1190    QStringList commonCFlags = project->values(VAR_CFLAGS);
     1191    QStringList commonLFlags = project->values(VAR_LFLAGS);
     1192
     1193    foreach(QString item, keywords) {
     1194        QString compilerOption;
     1195        QString linkerOption;
     1196
     1197        appendMmpFileOptions(compilerOption, project->values(VAR_CXXFLAGS "." + item));
     1198        appendMmpFileOptions(compilerOption, project->values(VAR_CFLAGS "." + item));
     1199        appendMmpFileOptions(compilerOption, commonCxxFlags);
     1200        appendMmpFileOptions(compilerOption, commonCFlags);
     1201
     1202        appendMmpFileOptions(linkerOption, project->values(VAR_LFLAGS "."  + item));
     1203        appendMmpFileOptions(linkerOption, commonLFlags);
     1204
     1205        writeMmpFileSimpleOption(t, MMP_OPTION, item, compilerOption);
     1206        writeMmpFileSimpleOption(t, MMP_LINKEROPTION, item, linkerOption);
     1207
     1208        writeMmpFileConditionalOptions(t, MMP_OPTION, item, VAR_CXXFLAGS);
     1209        writeMmpFileConditionalOptions(t, MMP_LINKEROPTION, item, VAR_LFLAGS);
     1210    }
    12161211
    12171212    t << endl;
     
    13171312        }
    13181313
     1314        QString condition;
     1315        if (!project->isEmpty(item + ".condition"))
     1316            condition = project->first(item + ".condition");
     1317
    13191318        QFileInfo subdir(fileInfo(fixedItem));
    13201319        QString relativePath = directory.relativeFilePath(fixedItem);
     
    13451344        removeSpecialCharacters(bldinfDefine);
    13461345
     1346        if (!condition.isEmpty())
     1347            t << "#if defined(" << condition << ")" << endl;
     1348
    13471349        t << "#ifndef " << bldinfDefine << endl;
    1348         t << "\t#include \"" << QDir::toNativeSeparators(bldinfFilename) << "\"" << endl;
    1349         t << "#endif // " << bldinfDefine << endl;
     1350        t << "\t#include \"" << bldinfFilename << "\"" << endl;
     1351        t << "#endif" << endl;
     1352
     1353        if (!condition.isEmpty())
     1354            t << "#endif" << endl;
     1355
    13501356    }
    13511357
     
    13651371
    13661372    QString mmpTag;
    1367     if (project->values("CONFIG").contains("symbian_test", Qt::CaseInsensitive))
     1373    if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
    13681374        mmpTag = QLatin1String(BLD_INF_TAG_TESTMMPFILES);
    13691375    else
     
    13881394    userBldInfRules.remove(mmpTag);
    13891395
    1390     t << endl << BLD_INF_TAG_EXTENSIONS << endl << endl;
     1396    QString extensionTag;
     1397    if (project->isActiveConfig(SYMBIAN_TEST_CONFIG))
     1398        extensionTag = QLatin1String(BLD_INF_TAG_TESTEXTENSIONS);
     1399    else
     1400        extensionTag = QLatin1String(BLD_INF_TAG_EXTENSIONS);
     1401
     1402    t << endl << extensionTag << endl << endl;
    13911403
    13921404    // Generate extension rules
     
    13941406    writeBldInfExtensionRulesPart(t, iconFile);
    13951407
    1396     userItems = userBldInfRules.value(BLD_INF_TAG_EXTENSIONS);
     1408    userItems = userBldInfRules.value(extensionTag);
    13971409    foreach(QString item, userItems)
    13981410        t << item << endl;
    1399     userBldInfRules.remove(BLD_INF_TAG_EXTENSIONS);
    1400 
    1401     t << endl << BLD_INF_TAG_EXPORTS << endl << endl;
    1402 
    1403     // Generate export rules
    1404 
    1405     // Export any deployed plugin stubs under /epoc32/data/z to support ROM builds
    1406     for (int i = 0; i < depList.size(); ++i)  {
    1407         int index = depList.at(i).from.indexOf(PLUGIN_STUB_DIR);
    1408         if (index != -1) {
    1409             t << QString("%1 /epoc32/data/z%2")
    1410                 .arg(QString(depList.at(i).from).mid(index).replace('\\','/'))
    1411                 .arg(QString(depList.at(i).to).mid(2).replace('\\','/')) << endl;
    1412         }
    1413     }
    1414 
    1415     userItems = userBldInfRules.value(BLD_INF_TAG_EXPORTS);
    1416     foreach(QString item, userItems)
    1417         t << item << endl;
    1418     userBldInfRules.remove(BLD_INF_TAG_EXPORTS);
     1411    userBldInfRules.remove(extensionTag);
    14191412
    14201413    // Add rest of the user defined content
     
    14281421}
    14291422
    1430 void SymbianMakefileGenerator::writeRegRssFile(QStringList &userItems)
     1423void SymbianMakefileGenerator::writeRegRssFile(QMap<QString, QStringList> &userItems)
    14311424{
    14321425    QString filename(fixedTarget);
     
    14451438        t << "#include <" << fixedTarget << ".rsg>" << endl;
    14461439        t << "#include <appinfo.rh>" << endl;
     1440        foreach(QString item, userItems[RSS_TAG_HEADER])
     1441            t << item << endl;
    14471442        t << endl;
    14481443        t << "UID2 KUidAppRegistrationResourceFile" << endl;
     
    14521447        t << "\tapp_file=\"" << fixedTarget << "\";" << endl;
    14531448        t << "\tlocalisable_resource_file=\"" RESOURCE_DIRECTORY_RESOURCE << fixedTarget << "\";" << endl;
     1449
     1450        writeRegRssList(t, userItems[RSS_TAG_SERVICE_LIST],
     1451                        QLatin1String(RSS_TAG_SERVICE_LIST),
     1452                        QLatin1String("SERVICE_INFO"));
     1453        writeRegRssList(t, userItems[RSS_TAG_FILE_OWNERSHIP_LIST],
     1454                        QLatin1String(RSS_TAG_FILE_OWNERSHIP_LIST),
     1455                        QLatin1String("FILE_OWNERSHIP_INFO"));
     1456        writeRegRssList(t, userItems[RSS_TAG_DATATYPE_LIST],
     1457                        QLatin1String(RSS_TAG_DATATYPE_LIST),
     1458                        QLatin1String("DATATYPE"));
    14541459        t << endl;
    14551460
    1456         foreach(QString item, userItems)
    1457             t << "\t" << item << endl;
     1461        foreach(QString item, userItems[RSS_TAG_DEFAULT])
     1462            t << "\t" << item.replace("\n","\n\t") << endl;
    14581463        t << "\t}" << endl;
     1464
     1465        foreach(QString item, userItems[RSS_TAG_FOOTER])
     1466            t << item << endl;
    14591467    } else {
    14601468        PRINT_FILE_CREATE_ERROR(filename)
     1469    }
     1470}
     1471
     1472void SymbianMakefileGenerator::writeRegRssList(QTextStream &t,
     1473                                               QStringList &userList,
     1474                                               const QString &listTag,
     1475                                               const QString &listItem)
     1476{
     1477    int itemCount = userList.count();
     1478    if (itemCount) {
     1479        t << "\t" << listTag << " ="<< endl;
     1480        t << "\t\t{" << endl;
     1481        foreach(QString item, userList) {
     1482            t << "\t\t" << listItem << endl;
     1483            t << "\t\t\t{" << endl;
     1484            t << "\t\t\t" << item.replace("\n","\n\t\t\t") << endl;
     1485            t << "\t\t\t}";
     1486            if (--itemCount)
     1487                t << ",";
     1488            t << endl;
     1489        }
     1490        t << "\t\t}; "<< endl;
    14611491    }
    14621492}
     
    15401570}
    15411571
    1542 void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons, QString &iconFile, QStringList &userRssRules)
     1572void SymbianMakefileGenerator::readRssRules(QString &numberOfIcons,
     1573                                            QString &iconFile, QMap<QString,
     1574                                            QStringList> &userRssRules)
    15431575{
    15441576    for (QMap<QString, QStringList>::iterator it = project->variables().begin(); it != project->variables().end(); ++it) {
     
    15521584            QStringList values = it.value();
    15531585            foreach(QString item, values) {
    1554                 // If there is no stringlist defined for a rule, use rule name directly
     1586                // If there is no stringlist defined for a rule, use rule value directly
    15551587                // This is convenience for defining single line statements
    15561588                if (project->values(item).isEmpty()) {
    15571589                    newValues << item;
    15581590                } else {
     1591                    QStringList itemList;
    15591592                    foreach(QString itemRow, project->values(item)) {
    1560                         newValues << itemRow;
     1593                        itemList << itemRow;
    15611594                    }
     1595                    newValues << itemList.join("\n");
    15621596                }
    15631597            }
     
    15801614                    continue;
    15811615                }
     1616            } else if (newKey == RSS_TAG_HEADER
     1617                       || newKey == RSS_TAG_SERVICE_LIST
     1618                       || newKey == RSS_TAG_FILE_OWNERSHIP_LIST
     1619                       || newKey == RSS_TAG_DATATYPE_LIST
     1620                       || newKey == RSS_TAG_FOOTER
     1621                       || newKey == RSS_TAG_DEFAULT) {
     1622                userRssRules[newKey] = newValues;
     1623                continue;
    15821624            } else {
    15831625                fprintf(stderr, "Warning: Unsupported key:'%s%s'\n",
     
    15881630    }
    15891631
     1632    QStringList newValues;
    15901633    foreach(QString item, project->values(RSS_RULES)) {
    1591         // If there is no stringlist defined for a rule, use rule name directly
    1592         // This is convenience for defining single line mmp statements
     1634        // If there is no stringlist defined for a rule, use rule value directly
     1635        // This is convenience for defining single line statements
    15931636        if (project->values(item).isEmpty()) {
    1594             userRssRules << item;
     1637            newValues << item;
    15951638        } else {
    1596             userRssRules << project->values(item);
    1597         }
    1598     }
     1639            newValues << project->values(item);
     1640        }
     1641    }
     1642    userRssRules[RSS_TAG_DEFAULT] << newValues;
    15991643
    16001644    // Validate that either both RSS_TAG_NBROFICONS and RSS_TAG_ICONFILE keys exist
     
    16121656        bool ok;
    16131657        numberOfIcons = numberOfIcons.simplified();
    1614         int tmp = numberOfIcons.toInt(&ok);
     1658        numberOfIcons.toInt(&ok);
    16151659        if (!ok) {
    16161660            numberOfIcons.clear();
     
    18831927
    18841928    t << SIS_TARGET ":" << endl;
    1885     QString siscommand = QString("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
     1929    QString siscommand = QString::fromLatin1("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
    18861930                                  "$(MAKE) -s -f $(MAKEFILE) %4," \
    18871931                                  "$(if $(QT_SIS_TARGET),$(MAKE) -s -f $(MAKEFILE) %4," \
     
    18991943    t << OK_SIS_TARGET ":" << endl;
    19001944
    1901     QString pkgcommand = QString("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_template.%2 $(QT_SIS_TARGET) " \
     1945    QString pkgcommand = QString::fromLatin1("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_template.%2 $(QT_SIS_TARGET) " \
    19021946                                 "$(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE)")
    19031947                          .arg(fixedTarget)
     
    19121956    t << "\t$(MAKE) -s -f $(MAKEFILE) " SIS_TARGET << endl << endl;
    19131957
     1958    t << ROM_STUB_SIS_TARGET ":" << endl;
     1959    QString stubsiscommand = QString::fromLatin1("\t$(if $(wildcard %1_template.%2),$(if $(wildcard %3)," \
     1960                                  "$(MAKE) -s -f $(MAKEFILE) %4," \
     1961                                  "$(if $(QT_SIS_TARGET),$(MAKE) -s -f $(MAKEFILE) %4," \
     1962                                  "$(MAKE) -s -f $(MAKEFILE) %5))," \
     1963                                  "$(MAKE) -s -f $(MAKEFILE) %6)")
     1964                          .arg(fixedTarget)
     1965                          .arg("pkg")
     1966                          .arg(MAKE_CACHE_NAME)
     1967                          .arg(OK_ROM_STUB_SIS_TARGET)
     1968                          .arg(FAIL_SIS_NOCACHE_TARGET)
     1969                          .arg(FAIL_SIS_NOPKG_TARGET);
     1970    t << stubsiscommand << endl;
     1971    t << endl;
     1972
     1973    t << OK_ROM_STUB_SIS_TARGET ":" << endl;
     1974
     1975    QString stubpkgcommand = QString::fromLatin1("\tcreatepackage.bat -s $(QT_SIS_OPTIONS) %1_template.%2 $(QT_SIS_TARGET) " \
     1976                                 "$(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE)")
     1977                          .arg(fixedTarget)
     1978                          .arg("pkg");
     1979    t << stubpkgcommand << endl;
     1980    t << endl;
     1981
    19141982    t << INSTALLER_SIS_TARGET ": " << sisName << endl;
    1915     siscommand = QString("\t$(if $(wildcard %1_installer.%2)," \
     1983    siscommand = QString::fromLatin1("\t$(if $(wildcard %1_installer.%2)," \
    19161984                                  "$(MAKE) -s -f $(MAKEFILE) %3," \
    19171985                                  "$(MAKE) -s -f $(MAKEFILE) %4)")
     
    19251993    t << OK_INSTALLER_SIS_TARGET ": " << endl;
    19261994
    1927     pkgcommand = QString("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_installer.%2 - " \
     1995    pkgcommand = QString::fromLatin1("\tcreatepackage.bat $(QT_SIS_OPTIONS) %1_installer.%2 - " \
    19281996                         "$(QT_SIS_CERTIFICATE) $(QT_SIS_KEY) $(QT_SIS_PASSPHRASE)")
    19291997                  .arg(fixedTarget)
     
    20052073        }
    20062074        t << "runonphone: sis" << endl;
    2007         t << "\trunonphone $(QT_RUN_ON_PHONE_OPTIONS) --sis " << fixedTarget << "_$(QT_SIS_TARGET).sis " << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl;
     2075        t << "\trunonphone $(QT_RUN_ON_PHONE_OPTIONS) --sis " << fixedTarget << ".sis " << fixedTarget << ".exe " << "$(QT_RUN_OPTIONS)" << endl;
    20082076        t << endl;
    20092077    }
Note: See TracChangeset for help on using the changeset viewer.