qmake/generators/symbian/symmake.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
child 8 3f74d0d4af4c
equal deleted inserted replaced
4:3b1da2848fc7 5:d3bac044e0f0
    54 #define RESOURCE_DIRECTORY_MMP "/resource/apps"
    54 #define RESOURCE_DIRECTORY_MMP "/resource/apps"
    55 #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\"
    55 #define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\"
    56 #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps"
    56 #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps"
    57 #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def"
    57 #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def"
    58 #define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonU.def"
    58 #define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonU.def"
    59 #define BLD_INF_FILENAME_LEN (sizeof(BLD_INF_FILENAME) - 1)
       
    60 
    59 
    61 #define BLD_INF_RULES_BASE "BLD_INF_RULES."
    60 #define BLD_INF_RULES_BASE "BLD_INF_RULES."
    62 #define BLD_INF_TAG_PLATFORMS "prj_platforms"
    61 #define BLD_INF_TAG_PLATFORMS "prj_platforms"
    63 #define BLD_INF_TAG_MMPFILES "prj_mmpfiles"
    62 #define BLD_INF_TAG_MMPFILES "prj_mmpfiles"
    64 #define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
    63 #define BLD_INF_TAG_TESTMMPFILES "prj_testmmpfiles"
    94 #define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg"
    93 #define FAIL_SIS_NOPKG_TARGET "fail_sis_nopkg"
    95 #define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache"
    94 #define FAIL_SIS_NOCACHE_TARGET "fail_sis_nocache"
    96 
    95 
    97 #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename));
    96 #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename));
    98 
    97 
       
    98 #define MANUFACTURER_NOTE_FILE "manufacturer_note.txt"
       
    99 #define DEFAULT_MANUFACTURER_NOTE \
       
   100     "The package is not supported for devices from this manufacturer. Please try the selfsigned " \
       
   101     "version of the package instead."
       
   102 
    99 QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir)
   103 QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir)
   100 {
   104 {
   101     static QString epocRootStr;
   105     static QString epocRootStr;
   102     if (epocRootStr.isEmpty()) {
   106     if (epocRootStr.isEmpty()) {
   103         QFileInfo efi(epocRoot());
   107         QFileInfo efi(epocRoot());
   247     // but all required data is not yet available.
   251     // but all required data is not yet available.
   248     bool isPrimaryMakefile = true;
   252     bool isPrimaryMakefile = true;
   249     QString wrapperFileName("Makefile");
   253     QString wrapperFileName("Makefile");
   250     QString outputFileName = fileInfo(Option::output.fileName()).fileName();
   254     QString outputFileName = fileInfo(Option::output.fileName()).fileName();
   251     if (outputFileName != BLD_INF_FILENAME) {
   255     if (outputFileName != BLD_INF_FILENAME) {
   252         wrapperFileName.append(".").append((outputFileName.size() > BLD_INF_FILENAME_LEN && outputFileName.left(BLD_INF_FILENAME_LEN) == BLD_INF_FILENAME) ? outputFileName.mid(8) : outputFileName);
   256         wrapperFileName.append(".").append(outputFileName.startsWith(BLD_INF_FILENAME)
       
   257                                            ? outputFileName.mid(sizeof(BLD_INF_FILENAME))
       
   258                                            : outputFileName);
   253         isPrimaryMakefile = false;
   259         isPrimaryMakefile = false;
   254     }
   260     }
   255 
   261 
   256     QFile wrapperMakefile(wrapperFileName);
   262     QFile wrapperMakefile(wrapperFileName);
   257     if (wrapperMakefile.open(QIODevice::WriteOnly)) {
   263     if (wrapperMakefile.open(QIODevice::WriteOnly)) {
   285     mmpFilename.append(uid3);
   291     mmpFilename.append(uid3);
   286     mmpFilename.append(Option::mmp_ext);
   292     mmpFilename.append(Option::mmp_ext);
   287     writeMmpFile(mmpFilename, symbianLangCodes);
   293     writeMmpFile(mmpFilename, symbianLangCodes);
   288 
   294 
   289     if (targetType == TypeExe) {
   295     if (targetType == TypeExe) {
   290         if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
   296         if (!project->isActiveConfig("no_icon")) {
   291             writeRegRssFile(userRssRules);
   297             writeRegRssFile(userRssRules);
   292             writeRssFile(numberOfIcons, iconFile);
   298             writeRssFile(numberOfIcons, iconFile);
   293             writeLocFile(symbianLangCodes);
   299             writeLocFile(symbianLangCodes);
   294             if (!project->values("SYMBIANTRANSLATIONS").isEmpty())
   300             if (!project->values("SYMBIANTRANSLATIONS").isEmpty())
   295                 writeSymbianLocFile(symbianLangCodes);        
   301                 writeSymbianLocFile(symbianLangCodes);        
   382             t << item << endl;
   388             t << item << endl;
   383         }
   389         }
   384         t << endl;
   390         t << endl;
   385     }
   391     }
   386 
   392 
       
   393     // Begin Manufacturer block
       
   394     if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
       
   395         QString manufacturerStr("IF ");
       
   396         foreach(QString manufacturer, project->values("DEPLOYMENT.manufacturers")) {
       
   397             manufacturerStr.append(QString("(MANUFACTURER)=(%1) OR \n   ").arg(manufacturer));
       
   398         }
       
   399         // Remove the final OR
       
   400         manufacturerStr.chop(8);
       
   401         t << manufacturerStr << endl;
       
   402     }
       
   403 
   387     // Install paths on the phone *** should be dynamic at some point
   404     // Install paths on the phone *** should be dynamic at some point
   388     QString installPathBin = "!:\\sys\\bin";
   405     QString installPathBin = "!:\\sys\\bin";
   389     QString installPathResource = "!:\\resource\\apps";
   406     QString installPathResource = "!:\\resource\\apps";
   390     QString installPathRegResource = "!:\\private\\10003a3f\\import\\apps";
   407     QString installPathRegResource = "!:\\private\\10003a3f\\import\\apps";
   391 
   408 
   403              .arg(exeFile)
   420              .arg(exeFile)
   404              .arg(installPathBin)
   421              .arg(installPathBin)
   405              .arg(exeFile) << endl;
   422              .arg(exeFile) << endl;
   406 
   423 
   407         // deploy rsc & reg_rsc file
   424         // deploy rsc & reg_rsc file
   408         if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
   425         if (!project->isActiveConfig("no_icon")) {
   409             t << QString("\"%1epoc32/data/z/resource/apps/%2\"    - \"%3\\%4\"")
   426             t << QString("\"%1epoc32/data/z/resource/apps/%2\"    - \"%3\\%4\"")
   410                  .arg(epocRoot())
   427                  .arg(epocRoot())
   411                  .arg(fixedTarget + ".rsc")
   428                  .arg(fixedTarget + ".rsc")
   412                  .arg(installPathResource)
   429                  .arg(installPathResource)
   413                  .arg(fixedTarget + ".rsc") << endl;
   430                  .arg(fixedTarget + ".rsc") << endl;
   456                 }
   473                 }
   457             }
   474             }
   458             t << endl;
   475             t << endl;
   459         }
   476         }
   460     }
   477     }
       
   478 
       
   479     // Close Manufacturer block
       
   480     if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
       
   481         QString manufacturerFailNoteFile;
       
   482         if (project->values("DEPLOYMENT.manufacturers.fail_note").isEmpty()) {
       
   483             manufacturerFailNoteFile = QString("%1_" MANUFACTURER_NOTE_FILE).arg(uid3);
       
   484             QFile ft(manufacturerFailNoteFile);
       
   485             if (ft.open(QIODevice::WriteOnly)) {
       
   486                 generatedFiles << ft.fileName();
       
   487                 QTextStream t2(&ft);
       
   488 
       
   489                 t2 << QString(DEFAULT_MANUFACTURER_NOTE) << endl;
       
   490             } else {
       
   491                 PRINT_FILE_CREATE_ERROR(manufacturerFailNoteFile)
       
   492             }
       
   493         } else {
       
   494             manufacturerFailNoteFile = project->values("DEPLOYMENT.manufacturers.fail_note").join("");
       
   495         }
       
   496 
       
   497         t << "ELSEIF NOT(0) ; MANUFACTURER" << endl
       
   498           << "\"" << fileInfo(manufacturerFailNoteFile).absoluteFilePath() << "\""
       
   499           << " - \"\", FILETEXT, TEXTEXIT" << endl
       
   500           << "ENDIF ; MANUFACTURER" << endl;
       
   501     }
   461 }
   502 }
   462 
   503 
   463 bool SymbianMakefileGenerator::containsStartWithItem(const QChar &c, const QStringList& src)
   504 bool SymbianMakefileGenerator::containsStartWithItem(const QChar &c, const QStringList& src)
   464 {
   505 {
   465     bool result = false;
   506     bool result = false;
   472     return result;
   513     return result;
   473 }
   514 }
   474 
   515 
   475 void SymbianMakefileGenerator::writeCustomDefFile()
   516 void SymbianMakefileGenerator::writeCustomDefFile()
   476 {
   517 {
   477     if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
   518     if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) {
   478         // Create custom def file for plugin
   519         // Create custom def file for plugin
   479         QFile ft(QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL));
   520         QFile ft(QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL));
   480 
   521 
   481         if (ft.open(QIODevice::WriteOnly)) {
   522         if (ft.open(QIODevice::WriteOnly)) {
   482             if (Option::mkfile::listgen) {
   523             if (Option::mkfile::listgen) {
   513 {
   554 {
   514     MakefileGenerator::init();
   555     MakefileGenerator::init();
   515     fixedTarget = escapeFilePath(fileFixify(project->first("TARGET")));
   556     fixedTarget = escapeFilePath(fileFixify(project->first("TARGET")));
   516     fixedTarget = removePathSeparators(fixedTarget);
   557     fixedTarget = removePathSeparators(fixedTarget);
   517     removeSpecialCharacters(fixedTarget);
   558     removeSpecialCharacters(fixedTarget);
       
   559     
       
   560  		translationFileName = escapeFilePath(fileFixify(project->first("TRANSLATIONS")));
       
   561  		if (!translationFileName.isEmpty()){
       
   562  		 		translationFileName.chop(3);
       
   563  				translationFileName = removePathSeparators(translationFileName);
       
   564  				removeSpecialCharacters(translationFileName);
       
   565  			}
       
   566  			else
       
   567  				translationFileName = fixedTarget;
   518 
   568 
   519     if (0 != project->values("QMAKE_PLATFORM").size())
   569     if (0 != project->values("QMAKE_PLATFORM").size())
   520         platform = varGlue("QMAKE_PLATFORM", "", " ", "");
   570         platform = varGlue("QMAKE_PLATFORM", "", " ", "");
   521 
   571 
   522     if (0 == project->values("QMAKESPEC").size())
   572     if (0 == project->values("QMAKESPEC").size())
   540 
   590 
   541     if ((project->values("TEMPLATE")).contains("app"))
   591     if ((project->values("TEMPLATE")).contains("app"))
   542         targetType = TypeExe;
   592         targetType = TypeExe;
   543     else if ((project->values("TEMPLATE")).contains("lib")) {
   593     else if ((project->values("TEMPLATE")).contains("lib")) {
   544         // Check CONFIG to see if we are to build staticlib or dll
   594         // Check CONFIG to see if we are to build staticlib or dll
   545         if (project->values("CONFIG").contains("staticlib") || project->values("CONFIG").contains("static"))
   595         if (project->isActiveConfig("staticlib") || project->isActiveConfig("static"))
   546             targetType = TypeLib;
   596             targetType = TypeLib;
   547         else if (project->values("CONFIG").contains("plugin"))
   597         else if (project->isActiveConfig("plugin"))
   548             targetType = TypePlugin;
   598             targetType = TypePlugin;
   549         else
   599         else
   550             targetType = TypeDll;
   600             targetType = TypeDll;
   551     } else {
   601     } else {
   552         targetType = TypeSubdirs;
   602         targetType = TypeSubdirs;
   553     }
   603     }
   554 
   604 
   555     if (0 != project->values("TARGET.UID2").size()) {
   605     if (0 != project->values("TARGET.UID2").size()) {
   556         uid2 = project->first("TARGET.UID2");
   606         uid2 = project->first("TARGET.UID2");
   557     } else if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
   607     } else if (project->isActiveConfig("stdbinary")) {
   558         uid2 = "0x20004C45";
   608         uid2 = "0x20004C45";
   559     } else {
   609     } else {
   560         if (targetType == TypeExe) {
   610         if (targetType == TypeExe) {
   561             if (project->values("QT").contains("gui", Qt::CaseInsensitive)) {
   611             if (project->values("QT").contains("gui", Qt::CaseInsensitive)) {
   562                 // exe and gui -> uid2 needed
   612                 // exe and gui -> uid2 needed
   823             }
   873             }
   824             t << endl;
   874             t << endl;
   825         }
   875         }
   826         t << endl;
   876         t << endl;
   827 
   877 
   828         if (!project->values("CONFIG").contains("static") && !project->values("CONFIG").contains("staticlib")) {
   878         if (!project->isActiveConfig("static") && !project->isActiveConfig("staticlib")) {
   829             writeMmpFileLibraryPart(t);
   879             writeMmpFileLibraryPart(t);
   830         }
   880         }
   831 
   881 
   832         writeMmpFileCapabilityPart(t);
   882         writeMmpFileCapabilityPart(t);
   833 
   883 
   876     bool skipTargetType = overriddenMmpKeywords.contains(MMP_TARGETTYPE);
   926     bool skipTargetType = overriddenMmpKeywords.contains(MMP_TARGETTYPE);
   877 
   927 
   878     if (targetType == TypeExe) {
   928     if (targetType == TypeExe) {
   879         t << MMP_TARGET "\t\t" << fixedTarget << ".exe" << endl;
   929         t << MMP_TARGET "\t\t" << fixedTarget << ".exe" << endl;
   880         if (!skipTargetType) {
   930         if (!skipTargetType) {
   881             if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
   931             if (project->isActiveConfig("stdbinary"))
   882                 t << MMP_TARGETTYPE "\t\tSTDEXE" << endl;
   932                 t << MMP_TARGETTYPE "\t\tSTDEXE" << endl;
   883             else
   933             else
   884                 t << MMP_TARGETTYPE "\t\tEXE" << endl;
   934                 t << MMP_TARGETTYPE "\t\tEXE" << endl;
   885         }
   935         }
   886     } else if (targetType == TypeDll || targetType == TypePlugin) {
   936     } else if (targetType == TypeDll || targetType == TypePlugin) {
   887         t << MMP_TARGET "\t\t" << fixedTarget << ".dll" << endl;
   937         t << MMP_TARGET "\t\t" << fixedTarget << ".dll" << endl;
   888         if (!skipTargetType) {
   938         if (!skipTargetType) {
   889             if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
   939             if (project->isActiveConfig("stdbinary"))
   890                 t << MMP_TARGETTYPE "\t\tSTDDLL" << endl;
   940                 t << MMP_TARGETTYPE "\t\tSTDDLL" << endl;
   891             else
   941             else
   892                 t << MMP_TARGETTYPE "\t\tDLL" << endl;
   942                 t << MMP_TARGETTYPE "\t\tDLL" << endl;
   893         }
   943         }
   894     } else if (targetType == TypeLib) {
   944     } else if (targetType == TypeLib) {
   895         t << MMP_TARGET "\t\t" << fixedTarget << ".lib" << endl;
   945         t << MMP_TARGET "\t\t" << fixedTarget << ".lib" << endl;
   896         if (!skipTargetType) {
   946         if (!skipTargetType) {
   897             if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
   947             if (project->isActiveConfig("stdbinary"))
   898                 t << MMP_TARGETTYPE "\t\tSTDLIB" << endl;
   948                 t << MMP_TARGETTYPE "\t\tSTDLIB" << endl;
   899             else
   949             else
   900                 t << MMP_TARGETTYPE "\t\tLIB" << endl;
   950                 t << MMP_TARGETTYPE "\t\tLIB" << endl;
   901         }
   951         }
   902     } else {
   952     } else {
   928     if (0 != project->values("TARGET.EPOCHEAPSIZE").size())
   978     if (0 != project->values("TARGET.EPOCHEAPSIZE").size())
   929         t << MMP_EPOCHEAPSIZE "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl;
   979         t << MMP_EPOCHEAPSIZE "\t\t" << project->values("TARGET.EPOCHEAPSIZE").join(" ") << endl;
   930     if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size())
   980     if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size())
   931         t << MMP_EPOCALLOWDLLDATA << endl;
   981         t << MMP_EPOCALLOWDLLDATA << endl;
   932 
   982 
   933     if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
   983     if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) {
   934         // Use custom def file for Qt plugins
   984         // Use custom def file for Qt plugins
   935         t << "DEFFILE " PLUGIN_COMMON_DEF_FILE_FOR_MMP << endl;
   985         t << "DEFFILE " PLUGIN_COMMON_DEF_FILE_FOR_MMP << endl;
   936     }
   986     }
   937 
   987 
   938     t << endl;
   988     t << endl;
   944     \private\10003a3f\import\apps directory.
   994     \private\10003a3f\import\apps directory.
   945 */
   995 */
   946 void SymbianMakefileGenerator::writeMmpFileResourcePart(QTextStream& t, QStringList &symbianLangCodes)
   996 void SymbianMakefileGenerator::writeMmpFileResourcePart(QTextStream& t, QStringList &symbianLangCodes)
   947 {
   997 {
   948     if ((targetType == TypeExe) &&
   998     if ((targetType == TypeExe) &&
   949             !project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
   999             !project->isActiveConfig("no_icon")) {
   950 
  1000 
   951         QString locTarget = fixedTarget;
  1001         QString locTarget = fixedTarget;
   952         locTarget.append(".rss");
  1002         locTarget.append(".rss");
   953 
  1003 
   954         t << "SOURCEPATH\t\t\t. " << endl;
  1004         t << "SOURCEPATH\t\t\t. " << endl;
  1311     t << endl;
  1361     t << endl;
  1312 
  1362 
  1313     // Add project mmps and old style extension makefiles
  1363     // Add project mmps and old style extension makefiles
  1314 
  1364 
  1315     QString mmpTag;
  1365     QString mmpTag;
  1316     if (project->values("CONFIG").contains("symbian_test", Qt::CaseInsensitive))
  1366     if (project->isActiveConfig("symbian_test"))
  1317         mmpTag = QLatin1String(BLD_INF_TAG_TESTMMPFILES);
  1367         mmpTag = QLatin1String(BLD_INF_TAG_TESTMMPFILES);
  1318     else
  1368     else
  1319         mmpTag = QLatin1String(BLD_INF_TAG_MMPFILES);
  1369         mmpTag = QLatin1String(BLD_INF_TAG_MMPFILES);
  1320 
  1370 
  1321     t << endl << mmpTag << endl << endl;
  1371     t << endl << mmpTag << endl << endl;
  1482         t << "// * This file is generated by qmake and should not be modified by the" << endl;
  1532         t << "// * This file is generated by qmake and should not be modified by the" << endl;
  1483         t << "// * user." << endl;
  1533         t << "// * user." << endl;
  1484         t << "// ============================================================================" << endl;
  1534         t << "// ============================================================================" << endl;
  1485         t << endl;
  1535         t << endl;
  1486         t << "#include <appinfo.rh>" << endl;
  1536         t << "#include <appinfo.rh>" << endl;
  1487         if (!project->values("SYMBIANTRANSLATIONS").isEmpty())
  1537         t << "#include <" << translationFileName << ".loc>" << endl;
  1488             t << "#include <" << fixedTarget << ".loc>" << endl;
       
  1489         else
       
  1490             t << "#include \"" << fixedTarget << ".loc\"" << endl;
       
  1491         t << endl;
  1538         t << endl;
  1492         t << "RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info" << endl;
  1539         t << "RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info" << endl;
  1493         t << "\t{" << endl;
  1540         t << "\t{" << endl;
  1494         t << "\tshort_caption = STRING_r_short_caption;" << endl;
  1541         t << "\tshort_caption = STRING_r_short_caption;" << endl;
  1495         t << "\tcaption_and_icon =" << endl;
  1542         t << "\tcaption_and_icon =" << endl;
  1517     }
  1564     }
  1518 }
  1565 }
  1519 
  1566 
  1520 void SymbianMakefileGenerator::writeLocFile(QStringList &symbianLangCodes)
  1567 void SymbianMakefileGenerator::writeLocFile(QStringList &symbianLangCodes)
  1521 {
  1568 {
  1522     QString filename(fixedTarget);
  1569     QString filename(translationFileName);
  1523     if (project->values("SYMBIANTRANSLATIONS").isEmpty()) {
  1570     if (project->values("SYMBIANTRANSLATIONS").isEmpty()) {
  1524         filename.append(".loc");
  1571         filename.append(".loc");
  1525     } else { 
  1572     } else { 
  1526         if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) { 
  1573         if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) { 
  1527             filename.insert(0,project->first("SYMBIANLOCFILESDIR"));         
  1574             filename.insert(0,project->first("SYMBIANLOCFILESDIR"));         
  1528         } else {	
  1575         } else {	
  1529             filename.insert(0,"/epoc32/include/platform/app/loc/");    
  1576             filename.insert(0,"/epoc32/include/platform/mw/loc/");    
  1530         }
  1577         }
  1531         filename.append(".loc");
  1578         filename.append(".loc");
  1532     }
  1579     }
  1533     
  1580     
  1534     QFile ft(filename);
  1581     QFile ft(filename);
  1558         t << "#define STRING_r_short_caption \"" << fixedTarget  << "\"" << endl;
  1605         t << "#define STRING_r_short_caption \"" << fixedTarget  << "\"" << endl;
  1559         t << "#define STRING_r_caption \"" << fixedTarget  << "\"" << endl;
  1606         t << "#define STRING_r_caption \"" << fixedTarget  << "\"" << endl;
  1560         t << "#endif" << endl;
  1607         t << "#endif" << endl;
  1561     } else {
  1608     } else {
  1562             t << "#if LANGUAGE_01" << endl;    
  1609             t << "#if LANGUAGE_01" << endl;    
  1563             t << "#include <" << "01/" << fixedTarget  << "_01.loc>" << endl;
  1610             t << "#include <" << "01/" << translationFileName  << "_01.loc>" << endl;
  1564             foreach(QString lang, symbianLangCodes) {
  1611             foreach(QString lang, symbianLangCodes) {
  1565                 if (lang.localeAwareCompare("01") != 0) {
  1612                 if (lang.localeAwareCompare("01") != 0) {
  1566                     t << "#elif LANGUAGE_" << lang << endl;
  1613                     t << "#elif LANGUAGE_" << lang << endl;
  1567                     t << "#include <" << lang << "/" << fixedTarget  << "_" << lang << ".loc>" << ">" << endl;
  1614                     t << "#include <" << lang << "/" << translationFileName  << "_" << lang << ".loc" << ">" << endl;
  1568                 }
  1615                 }
  1569             }
  1616             }
  1570             t << "#endif" << endl;
  1617             t << "#endif" << endl;
  1571         }
  1618         }
  1572     } else {
  1619     } else {
  1574     }
  1621     }
  1575 }
  1622 }
  1576 
  1623 
  1577 void SymbianMakefileGenerator::writeSymbianLocFile(QStringList &symbianLangCodes)
  1624 void SymbianMakefileGenerator::writeSymbianLocFile(QStringList &symbianLangCodes)
  1578 {	
  1625 {	
  1579 	QString filename(fixedTarget); 
  1626 	QString filename(translationFileName); 
  1580 	foreach(QString lang, symbianLangCodes) {
  1627 	foreach(QString lang, symbianLangCodes) {
  1581         
  1628         
  1582 		QString tsFilename(filename);  
  1629 		QString tsFilename(filename);  
  1583 		QString language = qt2S60LangMapTable.key(lang, QString("en"));
  1630 		QString language = qt2S60LangMapTable.key(lang, QString("en"));
  1584 		tsFilename.append("_"+language+".ts");
  1631 		tsFilename.append("_"+language+".ts");
  1585 		tsFilename.insert(0,project->first("SYMBIANTRANSLATIONDIR")); 	
  1632 	
       
  1633 		tsFilename.insert(0,project->first("SYMBIANTRANSLATIONSRCDIR")); 	
  1586 		
  1634 		
  1587         QString locFilename(filename); 
  1635         QString locFilename(filename); 
  1588         locFilename.append("_"+lang+".loc");
  1636         locFilename.append("_"+lang+".loc");
  1589         if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) {    
  1637         if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) {    
  1590             locFilename.insert(0,lang+"/");
  1638             locFilename.insert(0,lang+"/");
  1591             locFilename.insert(0,project->first("SYMBIANLOCFILESDIR"));
  1639             locFilename.insert(0,project->first("SYMBIANLOCFILESDIR"));
  1592         } else {	
  1640         } else {	
  1593             locFilename.insert(0,"/epoc32/include/platform/app/loc/"+lang+"/");
  1641             locFilename.insert(0,"/epoc32/include/platform/mw/loc/"+lang+"/");
  1594         }
  1642         }
  1595                 
  1643                 
  1596         QString shortCaption;
  1644         QString shortCaption;
  1597         QString longCaption;
  1645         QString longCaption;
  1598         
  1646         
  1631                                 }
  1679                                 }
  1632                             }
  1680                             }
  1633                         }
  1681                         }
  1634                     }         
  1682                     }         
  1635                 }
  1683                 }
  1636                 if (shortCaption.isEmpty())
  1684                 if (shortCaption.isEmpty()){
  1637                     fprintf(stderr, "Warning: STRING_r_short_caption not generated from file '%s'.\n", qPrintable(tsFilename));
  1685                     fprintf(stderr, "Warning: STRING_r_short_caption not generated from file '%s'.\n", qPrintable(tsFilename));
  1638                 if (longCaption.isEmpty())
  1686                     fprintf(stderr, "       : short caption generated from target name '#%s'.\n", qPrintable(fixedTarget));
       
  1687                   }
       
  1688                 if (longCaption.isEmpty()){
  1639                     fprintf(stderr, "Warning: STRING_r_caption not generated from file '%s'.\n", qPrintable(tsFilename));
  1689                     fprintf(stderr, "Warning: STRING_r_caption not generated from file '%s'.\n", qPrintable(tsFilename));
       
  1690                     fprintf(stderr, "       : caption generated from target name '#%s'.\n", qPrintable(fixedTarget));
       
  1691                   }
  1640                 if (xml.hasError())
  1692                 if (xml.hasError())
  1641                     fprintf(stderr, "ERROR: \"%s\" when parsing ts file\n", qPrintable(xml.errorString()));
  1693                     fprintf(stderr, "ERROR: \"%s\" when parsing ts file\n", qPrintable(xml.errorString()));
  1642             } else {
  1694             } else {
  1643                 fprintf(stderr, "Could not open ts file (%s)\n", qPrintable(tsFilename));
  1695                 fprintf(stderr, "Could not open ts file (%s)\n", qPrintable(tsFilename));
  1644             }
  1696             }
  1645         } else {
  1697         } else {
  1646             fprintf(stderr, "ts file does not exist: (%s)\n", qPrintable(tsFilename));
  1698             fprintf(stderr, "Warning: ts file does not exist: (%s)\n", qPrintable(tsFilename));
       
  1699             fprintf(stderr, "       : short and long caption generated from target name '#%s'.\n", qPrintable(fixedTarget));
  1647         }
  1700         }
  1648 
  1701 
  1649         // generate language specific caption loc file
  1702         // generate language specific caption loc file
  1650         QFile ft(locFilename);
  1703         QFile ft(locFilename);
  1651         if (ft.open(QIODevice::WriteOnly)) {
  1704         if (ft.open(QIODevice::WriteOnly)) {
  1659             t << "// ============================================================================" << endl;
  1712             t << "// ============================================================================" << endl;
  1660             t << endl;
  1713             t << endl;
  1661             if (!shortCaption.isEmpty()) {
  1714             if (!shortCaption.isEmpty()) {
  1662                 t << "#define STRING_r_short_caption \"" << shortCaption  << "\"" << endl;    
  1715                 t << "#define STRING_r_short_caption \"" << shortCaption  << "\"" << endl;    
  1663             } else {
  1716             } else {
  1664                 t << "#define STRING_r_short_caption \"" << fixedTarget  << "\"" << endl;
  1717                 t << "#define STRING_r_short_caption \"" "#"<< fixedTarget  << "\"" << endl;
  1665             }    
  1718             }    
  1666             if (!longCaption.isEmpty()) {
  1719             if (!longCaption.isEmpty()) {
  1667                 t << "#define STRING_r_caption \"" << longCaption  << "\"" << endl;  
  1720                 t << "#define STRING_r_caption \"" << longCaption  << "\"" << endl;  
  1668             } else {    
  1721             } else {    
  1669                 t << "#define STRING_r_caption \"" << fixedTarget  << "\"" << endl;
  1722                 t << "#define STRING_r_caption \"" "#"<< fixedTarget  << "\"" << endl;
  1670             }
  1723             }
  1671             ft.close();
  1724             ft.close();
  1672         } else {
  1725         } else {
  1673             PRINT_FILE_CREATE_ERROR(locFilename);	
  1726             PRINT_FILE_CREATE_ERROR(locFilename);	
  1674 	    }
  1727 	    }
  1745 
  1798 
  1746     // Validate that RSS_TAG_NBROFICONS contains only numbers
  1799     // Validate that RSS_TAG_NBROFICONS contains only numbers
  1747     if (!numberOfIcons.isEmpty()) {
  1800     if (!numberOfIcons.isEmpty()) {
  1748         bool ok;
  1801         bool ok;
  1749         numberOfIcons = numberOfIcons.simplified();
  1802         numberOfIcons = numberOfIcons.simplified();
  1750         int tmp = numberOfIcons.toInt(&ok);
  1803         numberOfIcons.toInt(&ok);
  1751         if (!ok) {
  1804         if (!ok) {
  1752             numberOfIcons.clear();
  1805             numberOfIcons.clear();
  1753             iconFile.clear();
  1806             iconFile.clear();
  1754             fprintf(stderr, "Warning: '%s%s' must be integer in decimal format.\n",
  1807             fprintf(stderr, "Warning: '%s%s' must be integer in decimal format.\n",
  1755                     RSS_RULES_BASE, RSS_TAG_NBROFICONS);
  1808                     RSS_RULES_BASE, RSS_TAG_NBROFICONS);