qmake/generators/symbian/symmake.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
child 8 3f74d0d4af4c
--- a/qmake/generators/symbian/symmake.cpp	Fri Feb 19 23:40:16 2010 +0200
+++ b/qmake/generators/symbian/symmake.cpp	Fri Mar 12 15:46:37 2010 +0200
@@ -56,7 +56,6 @@
 #define REGISTRATION_RESOURCE_DIRECTORY_HW "/private/10003a3f/import/apps"
 #define PLUGIN_COMMON_DEF_FILE_FOR_MMP "./plugin_common.def"
 #define PLUGIN_COMMON_DEF_FILE_ACTUAL "plugin_commonU.def"
-#define BLD_INF_FILENAME_LEN (sizeof(BLD_INF_FILENAME) - 1)
 
 #define BLD_INF_RULES_BASE "BLD_INF_RULES."
 #define BLD_INF_TAG_PLATFORMS "prj_platforms"
@@ -96,6 +95,11 @@
 
 #define PRINT_FILE_CREATE_ERROR(filename) fprintf(stderr, "Error: Could not create '%s'\n", qPrintable(filename));
 
+#define MANUFACTURER_NOTE_FILE "manufacturer_note.txt"
+#define DEFAULT_MANUFACTURER_NOTE \
+    "The package is not supported for devices from this manufacturer. Please try the selfsigned " \
+    "version of the package instead."
+
 QString SymbianMakefileGenerator::fixPathForMmp(const QString& origPath, const QDir& parentDir)
 {
     static QString epocRootStr;
@@ -249,7 +253,9 @@
     QString wrapperFileName("Makefile");
     QString outputFileName = fileInfo(Option::output.fileName()).fileName();
     if (outputFileName != BLD_INF_FILENAME) {
-        wrapperFileName.append(".").append((outputFileName.size() > BLD_INF_FILENAME_LEN && outputFileName.left(BLD_INF_FILENAME_LEN) == BLD_INF_FILENAME) ? outputFileName.mid(8) : outputFileName);
+        wrapperFileName.append(".").append(outputFileName.startsWith(BLD_INF_FILENAME)
+                                           ? outputFileName.mid(sizeof(BLD_INF_FILENAME))
+                                           : outputFileName);
         isPrimaryMakefile = false;
     }
 
@@ -287,7 +293,7 @@
     writeMmpFile(mmpFilename, symbianLangCodes);
 
     if (targetType == TypeExe) {
-        if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
+        if (!project->isActiveConfig("no_icon")) {
             writeRegRssFile(userRssRules);
             writeRssFile(numberOfIcons, iconFile);
             writeLocFile(symbianLangCodes);
@@ -384,6 +390,17 @@
         t << endl;
     }
 
+    // Begin Manufacturer block
+    if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
+        QString manufacturerStr("IF ");
+        foreach(QString manufacturer, project->values("DEPLOYMENT.manufacturers")) {
+            manufacturerStr.append(QString("(MANUFACTURER)=(%1) OR \n   ").arg(manufacturer));
+        }
+        // Remove the final OR
+        manufacturerStr.chop(8);
+        t << manufacturerStr << endl;
+    }
+
     // Install paths on the phone *** should be dynamic at some point
     QString installPathBin = "!:\\sys\\bin";
     QString installPathResource = "!:\\resource\\apps";
@@ -405,7 +422,7 @@
              .arg(exeFile) << endl;
 
         // deploy rsc & reg_rsc file
-        if (!project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
+        if (!project->isActiveConfig("no_icon")) {
             t << QString("\"%1epoc32/data/z/resource/apps/%2\"    - \"%3\\%4\"")
                  .arg(epocRoot())
                  .arg(fixedTarget + ".rsc")
@@ -458,6 +475,30 @@
             t << endl;
         }
     }
+
+    // Close Manufacturer block
+    if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
+        QString manufacturerFailNoteFile;
+        if (project->values("DEPLOYMENT.manufacturers.fail_note").isEmpty()) {
+            manufacturerFailNoteFile = QString("%1_" MANUFACTURER_NOTE_FILE).arg(uid3);
+            QFile ft(manufacturerFailNoteFile);
+            if (ft.open(QIODevice::WriteOnly)) {
+                generatedFiles << ft.fileName();
+                QTextStream t2(&ft);
+
+                t2 << QString(DEFAULT_MANUFACTURER_NOTE) << endl;
+            } else {
+                PRINT_FILE_CREATE_ERROR(manufacturerFailNoteFile)
+            }
+        } else {
+            manufacturerFailNoteFile = project->values("DEPLOYMENT.manufacturers.fail_note").join("");
+        }
+
+        t << "ELSEIF NOT(0) ; MANUFACTURER" << endl
+          << "\"" << fileInfo(manufacturerFailNoteFile).absoluteFilePath() << "\""
+          << " - \"\", FILETEXT, TEXTEXIT" << endl
+          << "ENDIF ; MANUFACTURER" << endl;
+    }
 }
 
 bool SymbianMakefileGenerator::containsStartWithItem(const QChar &c, const QStringList& src)
@@ -474,7 +515,7 @@
 
 void SymbianMakefileGenerator::writeCustomDefFile()
 {
-    if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
+    if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) {
         // Create custom def file for plugin
         QFile ft(QLatin1String(PLUGIN_COMMON_DEF_FILE_ACTUAL));
 
@@ -515,6 +556,15 @@
     fixedTarget = escapeFilePath(fileFixify(project->first("TARGET")));
     fixedTarget = removePathSeparators(fixedTarget);
     removeSpecialCharacters(fixedTarget);
+    
+ 		translationFileName = escapeFilePath(fileFixify(project->first("TRANSLATIONS")));
+ 		if (!translationFileName.isEmpty()){
+ 		 		translationFileName.chop(3);
+ 				translationFileName = removePathSeparators(translationFileName);
+ 				removeSpecialCharacters(translationFileName);
+ 			}
+ 			else
+ 				translationFileName = fixedTarget;
 
     if (0 != project->values("QMAKE_PLATFORM").size())
         platform = varGlue("QMAKE_PLATFORM", "", " ", "");
@@ -542,9 +592,9 @@
         targetType = TypeExe;
     else if ((project->values("TEMPLATE")).contains("lib")) {
         // Check CONFIG to see if we are to build staticlib or dll
-        if (project->values("CONFIG").contains("staticlib") || project->values("CONFIG").contains("static"))
+        if (project->isActiveConfig("staticlib") || project->isActiveConfig("static"))
             targetType = TypeLib;
-        else if (project->values("CONFIG").contains("plugin"))
+        else if (project->isActiveConfig("plugin"))
             targetType = TypePlugin;
         else
             targetType = TypeDll;
@@ -554,7 +604,7 @@
 
     if (0 != project->values("TARGET.UID2").size()) {
         uid2 = project->first("TARGET.UID2");
-    } else if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
+    } else if (project->isActiveConfig("stdbinary")) {
         uid2 = "0x20004C45";
     } else {
         if (targetType == TypeExe) {
@@ -825,7 +875,7 @@
         }
         t << endl;
 
-        if (!project->values("CONFIG").contains("static") && !project->values("CONFIG").contains("staticlib")) {
+        if (!project->isActiveConfig("static") && !project->isActiveConfig("staticlib")) {
             writeMmpFileLibraryPart(t);
         }
 
@@ -878,7 +928,7 @@
     if (targetType == TypeExe) {
         t << MMP_TARGET "\t\t" << fixedTarget << ".exe" << endl;
         if (!skipTargetType) {
-            if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
+            if (project->isActiveConfig("stdbinary"))
                 t << MMP_TARGETTYPE "\t\tSTDEXE" << endl;
             else
                 t << MMP_TARGETTYPE "\t\tEXE" << endl;
@@ -886,7 +936,7 @@
     } else if (targetType == TypeDll || targetType == TypePlugin) {
         t << MMP_TARGET "\t\t" << fixedTarget << ".dll" << endl;
         if (!skipTargetType) {
-            if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
+            if (project->isActiveConfig("stdbinary"))
                 t << MMP_TARGETTYPE "\t\tSTDDLL" << endl;
             else
                 t << MMP_TARGETTYPE "\t\tDLL" << endl;
@@ -894,7 +944,7 @@
     } else if (targetType == TypeLib) {
         t << MMP_TARGET "\t\t" << fixedTarget << ".lib" << endl;
         if (!skipTargetType) {
-            if (project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive))
+            if (project->isActiveConfig("stdbinary"))
                 t << MMP_TARGETTYPE "\t\tSTDLIB" << endl;
             else
                 t << MMP_TARGETTYPE "\t\tLIB" << endl;
@@ -930,7 +980,7 @@
     if (0 != project->values("TARGET.EPOCALLOWDLLDATA").size())
         t << MMP_EPOCALLOWDLLDATA << endl;
 
-    if (targetType == TypePlugin && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) {
+    if (targetType == TypePlugin && !project->isActiveConfig("stdbinary")) {
         // Use custom def file for Qt plugins
         t << "DEFFILE " PLUGIN_COMMON_DEF_FILE_FOR_MMP << endl;
     }
@@ -946,7 +996,7 @@
 void SymbianMakefileGenerator::writeMmpFileResourcePart(QTextStream& t, QStringList &symbianLangCodes)
 {
     if ((targetType == TypeExe) &&
-            !project->values("CONFIG").contains("no_icon", Qt::CaseInsensitive)) {
+            !project->isActiveConfig("no_icon")) {
 
         QString locTarget = fixedTarget;
         locTarget.append(".rss");
@@ -1313,7 +1363,7 @@
     // Add project mmps and old style extension makefiles
 
     QString mmpTag;
-    if (project->values("CONFIG").contains("symbian_test", Qt::CaseInsensitive))
+    if (project->isActiveConfig("symbian_test"))
         mmpTag = QLatin1String(BLD_INF_TAG_TESTMMPFILES);
     else
         mmpTag = QLatin1String(BLD_INF_TAG_MMPFILES);
@@ -1484,10 +1534,7 @@
         t << "// ============================================================================" << endl;
         t << endl;
         t << "#include <appinfo.rh>" << endl;
-        if (!project->values("SYMBIANTRANSLATIONS").isEmpty())
-            t << "#include <" << fixedTarget << ".loc>" << endl;
-        else
-            t << "#include \"" << fixedTarget << ".loc\"" << endl;
+        t << "#include <" << translationFileName << ".loc>" << endl;
         t << endl;
         t << "RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info" << endl;
         t << "\t{" << endl;
@@ -1519,14 +1566,14 @@
 
 void SymbianMakefileGenerator::writeLocFile(QStringList &symbianLangCodes)
 {
-    QString filename(fixedTarget);
+    QString filename(translationFileName);
     if (project->values("SYMBIANTRANSLATIONS").isEmpty()) {
         filename.append(".loc");
     } else { 
         if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) { 
             filename.insert(0,project->first("SYMBIANLOCFILESDIR"));         
         } else {	
-            filename.insert(0,"/epoc32/include/platform/app/loc/");    
+            filename.insert(0,"/epoc32/include/platform/mw/loc/");    
         }
         filename.append(".loc");
     }
@@ -1560,11 +1607,11 @@
         t << "#endif" << endl;
     } else {
             t << "#if LANGUAGE_01" << endl;    
-            t << "#include <" << "01/" << fixedTarget  << "_01.loc>" << endl;
+            t << "#include <" << "01/" << translationFileName  << "_01.loc>" << endl;
             foreach(QString lang, symbianLangCodes) {
                 if (lang.localeAwareCompare("01") != 0) {
                     t << "#elif LANGUAGE_" << lang << endl;
-                    t << "#include <" << lang << "/" << fixedTarget  << "_" << lang << ".loc>" << ">" << endl;
+                    t << "#include <" << lang << "/" << translationFileName  << "_" << lang << ".loc" << ">" << endl;
                 }
             }
             t << "#endif" << endl;
@@ -1576,13 +1623,14 @@
 
 void SymbianMakefileGenerator::writeSymbianLocFile(QStringList &symbianLangCodes)
 {	
-	QString filename(fixedTarget); 
+	QString filename(translationFileName); 
 	foreach(QString lang, symbianLangCodes) {
         
 		QString tsFilename(filename);  
 		QString language = qt2S60LangMapTable.key(lang, QString("en"));
 		tsFilename.append("_"+language+".ts");
-		tsFilename.insert(0,project->first("SYMBIANTRANSLATIONDIR")); 	
+	
+		tsFilename.insert(0,project->first("SYMBIANTRANSLATIONSRCDIR")); 	
 		
         QString locFilename(filename); 
         locFilename.append("_"+lang+".loc");
@@ -1590,7 +1638,7 @@
             locFilename.insert(0,lang+"/");
             locFilename.insert(0,project->first("SYMBIANLOCFILESDIR"));
         } else {	
-            locFilename.insert(0,"/epoc32/include/platform/app/loc/"+lang+"/");
+            locFilename.insert(0,"/epoc32/include/platform/mw/loc/"+lang+"/");
         }
                 
         QString shortCaption;
@@ -1633,17 +1681,22 @@
                         }
                     }         
                 }
-                if (shortCaption.isEmpty())
+                if (shortCaption.isEmpty()){
                     fprintf(stderr, "Warning: STRING_r_short_caption not generated from file '%s'.\n", qPrintable(tsFilename));
-                if (longCaption.isEmpty())
+                    fprintf(stderr, "       : short caption generated from target name '#%s'.\n", qPrintable(fixedTarget));
+                  }
+                if (longCaption.isEmpty()){
                     fprintf(stderr, "Warning: STRING_r_caption not generated from file '%s'.\n", qPrintable(tsFilename));
+                    fprintf(stderr, "       : caption generated from target name '#%s'.\n", qPrintable(fixedTarget));
+                  }
                 if (xml.hasError())
                     fprintf(stderr, "ERROR: \"%s\" when parsing ts file\n", qPrintable(xml.errorString()));
             } else {
                 fprintf(stderr, "Could not open ts file (%s)\n", qPrintable(tsFilename));
             }
         } else {
-            fprintf(stderr, "ts file does not exist: (%s)\n", qPrintable(tsFilename));
+            fprintf(stderr, "Warning: ts file does not exist: (%s)\n", qPrintable(tsFilename));
+            fprintf(stderr, "       : short and long caption generated from target name '#%s'.\n", qPrintable(fixedTarget));
         }
 
         // generate language specific caption loc file
@@ -1661,12 +1714,12 @@
             if (!shortCaption.isEmpty()) {
                 t << "#define STRING_r_short_caption \"" << shortCaption  << "\"" << endl;    
             } else {
-                t << "#define STRING_r_short_caption \"" << fixedTarget  << "\"" << endl;
+                t << "#define STRING_r_short_caption \"" "#"<< fixedTarget  << "\"" << endl;
             }    
             if (!longCaption.isEmpty()) {
                 t << "#define STRING_r_caption \"" << longCaption  << "\"" << endl;  
             } else {    
-                t << "#define STRING_r_caption \"" << fixedTarget  << "\"" << endl;
+                t << "#define STRING_r_caption \"" "#"<< fixedTarget  << "\"" << endl;
             }
             ft.close();
         } else {
@@ -1747,7 +1800,7 @@
     if (!numberOfIcons.isEmpty()) {
         bool ok;
         numberOfIcons = numberOfIcons.simplified();
-        int tmp = numberOfIcons.toInt(&ok);
+        numberOfIcons.toInt(&ok);
         if (!ok) {
             numberOfIcons.clear();
             iconFile.clear();