From 952f0ca3f371b040bd8b8a007cdf87bf0e4843ad Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 18 Nov 2009 14:47:42 +0200 Subject: Changed MIF filename from UID to target name in Symbian. This change makes it possible to define ICON keyword in pro file without UID3. It is safe to use target as an icon name since Symbian devices cannot have two different binaries with the same name as all binaries are located in \sys\bin. This means there cannot be also two mif files with same target name. Also all native S60 apps use target name as an MIF basename. Target name is also much easier to associate with app than UID. Task-number: QTBUG-4677 Reviewed-by: Miikka Heikkinen --- mkspecs/features/symbian/application_icon.prf | 30 ++++++++++++++++++--------- qmake/generators/symbian/symmake.cpp | 21 ++++++++++--------- qmake/generators/symbian/symmake.h | 4 ++-- qmake/generators/symbian/symmake_abld.cpp | 3 ++- qmake/generators/symbian/symmake_abld.h | 2 +- qmake/generators/symbian/symmake_sbsv2.cpp | 7 +++++-- qmake/generators/symbian/symmake_sbsv2.h | 2 +- 7 files changed, 42 insertions(+), 27 deletions(-) diff --git a/mkspecs/features/symbian/application_icon.prf b/mkspecs/features/symbian/application_icon.prf index b0c1bb1..62fd018 100644 --- a/mkspecs/features/symbian/application_icon.prf +++ b/mkspecs/features/symbian/application_icon.prf @@ -3,38 +3,48 @@ load(data_caging_paths) # If no_icon keyword exist, the S60 UI app is just made hidden. This because S60 app FW # requires the registration resource file to exist always contains( CONFIG, no_icon ) { - symbian:RSS_RULES ="hidden = KAppIsHidden;" + symbian:RSS_RULES ="hidden = KAppIsHidden;" CONFIG -= no_icon } else { # There is no point in compiling the MIF icon if no_icon CONFIGS is set !isEmpty(ICON) { - + !count(ICON, $$size(TRANSLATIONS)):!count(ICON, 1) { message("ICON keyword must have one or the same amout of items as in TRANSLATIONS keyword") } - # MIF files will have UID in their names, if TARGET.UID3 is not set, remind the user - isEmpty(TARGET.UID3):error("TARGET.UID3 must be explicitly defined for ICON generation") + # Try to produce indentical string to fixedTarget in SymbianMakefileGenerator, replaced chars taken + # from SymbianMakefileGenerator::removeSpecialCharacters. + # + # Note: it is not a major problem even baseTarget is not 100% identical to fixedTarget since qmake + # only uses filename from RSS_RULES.icon_file when referring to icon file name. + baseTarget = $$basename(TARGET) + baseTarget = $$replace(baseTarget, /,_) + baseTarget = $$replace(baseTarget, \\,_) + baseTarget = $$replace(baseTarget, -,_) + baseTarget = $$replace(baseTarget, :,_) + baseTarget = $$replace(baseTarget, \.,_) + baseTarget = $$replace(baseTarget, " ",_) # Note: symbian-sbsv2 builds can't utilize extra compiler for mifconv, so ICON handling is done in code - symbian-abld { - #Makefile: requires paths with backslash + symbian-abld { + #Makefile: requires paths with backslash ICON = $$replace( ICON, /, \\) # Extra compiler rules for mifconv - mifconv.output = ${ZDIR}$$APP_RESOURCE_DIR/$${TARGET.UID3}.mif + mifconv.output = ${ZDIR}$$APP_RESOURCE_DIR/$${baseTarget}.mif # Based on: http://www.forum.nokia.com/document/Cpp_Developers_Library # svg-t icons should always use /c32 depth - mifconv.commands = mifconv ${QMAKE_FILE_OUT} $$join(ICON, " /c32 ", "/c32 ",) + mifconv.commands = mifconv ${QMAKE_FILE_OUT} $$join(ICON, " /c32 ", "/c32 ",) mifconv.input = ICON mifconv.CONFIG = no_link combine # target_predeps together with combine seems not to work correctly, lets define it by ourselves PRE_TARGETDEPS += $$mifconv.output QMAKE_EXTRA_COMPILERS += mifconv - } + } # Rules to use generated MIF file from symbian resources RSS_RULES.number_of_icons = $$size(ICON) - RSS_RULES.icon_file = $$replace( APP_RESOURCE_DIR, /, \\\\ )\\\\$${TARGET.UID3}.mif + RSS_RULES.icon_file = $$APP_RESOURCE_DIR/$${baseTarget}.mif } } diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 1326a49..afaf338 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -209,7 +209,7 @@ bool SymbianMakefileGenerator::writeMakefile(QTextStream &t) generatePkgFile(iconFile); } - writeBldInfContent(t, generatePkg); + writeBldInfContent(t, generatePkg, iconFile); // Generate empty wrapper makefile here, because wrapper makefile must exist before writeMkFile, // but all required data is not yet available. @@ -378,14 +378,11 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile) .arg(installPathRegResource) .arg(fixedTarget + "_reg.rsc") << endl; - QString myIconFile = iconFile; - myIconFile = myIconFile.replace("\\\\", "\\"); - if (!iconFile.isEmpty()) { t << QString("\"%1epoc32/data/z%2\" - \"!:%3\"") .arg(epocRoot()) - .arg(QString(myIconFile).replace('\\','/')) - .arg(myIconFile) << endl << endl; + .arg(iconFile) + .arg(QDir::toNativeSeparators(iconFile)) << endl << endl; } } } @@ -1120,7 +1117,7 @@ void SymbianMakefileGenerator::writeMmpFileRulesPart(QTextStream& t) } } -void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension) +void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploymentExtension, const QString &iconFile) { // Read user defined bld inf rules @@ -1242,7 +1239,7 @@ void SymbianMakefileGenerator::writeBldInfContent(QTextStream &t, bool addDeploy // Generate extension rules - writeBldInfExtensionRulesPart(t); + writeBldInfExtensionRulesPart(t, iconFile); userItems = userBldInfRules.value(BLD_INF_TAG_EXTENSIONS); foreach(QString item, userItems) @@ -1320,14 +1317,17 @@ void SymbianMakefileGenerator::writeRssFile(QString &numberOfIcons, QString &ico t << "\t\t{" << endl; t << "\t\tcaption = STRING_r_caption;" << endl; - if (numberOfIcons.isEmpty() || iconFile.isEmpty()) { + QString rssIconFile = iconFile; + rssIconFile = rssIconFile.replace("/", "\\\\"); + + if (numberOfIcons.isEmpty() || rssIconFile.isEmpty()) { // There can be maximum one item in this tag, validated when parsed t << "\t\tnumber_of_icons = 0;" << endl; t << "\t\ticon_file = \"\";" << endl; } else { // There can be maximum one item in this tag, validated when parsed t << "\t\tnumber_of_icons = " << numberOfIcons << ";" << endl; - t << "\t\ticon_file = \"" << iconFile << "\";" << endl; + t << "\t\ticon_file = \"" << rssIconFile << "\";" << endl; } t << "\t\t};" << endl; t << "\t}" << endl; @@ -1697,6 +1697,7 @@ void SymbianMakefileGenerator::generateCleanCommands(QTextStream& t, void SymbianMakefileGenerator::removeSpecialCharacters(QString& str) { + // When modifying this method check also application_icon.prf str.replace(QString("/"), QString("_")); str.replace(QString("\\"), QString("_")); str.replace(QString("-"), QString("_")); diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h index a3e2c17..2e78c46 100644 --- a/qmake/generators/symbian/symmake.h +++ b/qmake/generators/symbian/symmake.h @@ -99,7 +99,7 @@ protected: void checkOverridability(QStringList &overridableKeywords, QString &checkString); void writeHeader(QTextStream &t); - void writeBldInfContent(QTextStream& t, bool addDeploymentExtension); + void writeBldInfContent(QTextStream& t, bool addDeploymentExtension, const QString &iconFile); static bool removeDuplicatedStrings(QStringList& stringList); @@ -143,7 +143,7 @@ protected: void generateDistcleanTargets(QTextStream& t); // Subclass implements - virtual void writeBldInfExtensionRulesPart(QTextStream& t) = 0; + virtual void writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile) = 0; virtual void writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension) = 0; virtual void writeMkFile(const QString& wrapperFileName, bool deploymentOnly) = 0; virtual void writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile) = 0; diff --git a/qmake/generators/symbian/symmake_abld.cpp b/qmake/generators/symbian/symmake_abld.cpp index 1b5464f..6225720 100644 --- a/qmake/generators/symbian/symmake_abld.cpp +++ b/qmake/generators/symbian/symmake_abld.cpp @@ -379,10 +379,11 @@ void SymbianAbldMakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, bool } } -void SymbianAbldMakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t) +void SymbianAbldMakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile) { // We don't use extensions for anything in abld Q_UNUSED(t); + Q_UNUSED(iconTargetFile); } bool SymbianAbldMakefileGenerator::writeDeploymentTargets(QTextStream &t) diff --git a/qmake/generators/symbian/symmake_abld.h b/qmake/generators/symbian/symmake_abld.h index 11b9cd1..56d31e1 100644 --- a/qmake/generators/symbian/symmake_abld.h +++ b/qmake/generators/symbian/symmake_abld.h @@ -51,7 +51,7 @@ class SymbianAbldMakefileGenerator : public SymbianMakefileGenerator protected: // Inherited from parent - virtual void writeBldInfExtensionRulesPart(QTextStream& t); + virtual void writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile); virtual void writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension); virtual void writeMkFile(const QString& wrapperFileName, bool deploymentOnly); virtual void writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile); diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp index 5e624de..4fd5833 100644 --- a/qmake/generators/symbian/symmake_sbsv2.cpp +++ b/qmake/generators/symbian/symmake_sbsv2.cpp @@ -238,7 +238,7 @@ void SymbianSbsv2MakefileGenerator::writeWrapperMakefile(QFile& wrapperFile, boo } } -void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t) +void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile) { // Makes sure we have needed FLMs in place. exportFlm(); @@ -379,9 +379,12 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t QString iconPath = iconInfo.path(); QString iconFile = iconInfo.baseName(); + QFileInfo iconTargetInfo = fileInfo(iconTargetFile); + QString iconTarget = iconTargetInfo.fileName(); + t << "OPTION SOURCES -c32 " << iconFile << endl; t << "OPTION SOURCEDIR " << iconPath << endl; - t << "OPTION TARGETFILE " << uid3 << ".mif" << endl; + t << "OPTION TARGETFILE " << iconTarget << endl; t << "OPTION SVGENCODINGVERSION 3" << endl; // Compatibility with S60 3.1 devices and up t << "END" << endl; } diff --git a/qmake/generators/symbian/symmake_sbsv2.h b/qmake/generators/symbian/symmake_sbsv2.h index 9472b68..3394908 100644 --- a/qmake/generators/symbian/symmake_sbsv2.h +++ b/qmake/generators/symbian/symmake_sbsv2.h @@ -51,7 +51,7 @@ class SymbianSbsv2MakefileGenerator : public SymbianMakefileGenerator protected: // Inherited from parent - virtual void writeBldInfExtensionRulesPart(QTextStream& t); + virtual void writeBldInfExtensionRulesPart(QTextStream& t, const QString &iconTargetFile); virtual void writeBldInfMkFilePart(QTextStream& t, bool addDeploymentExtension); virtual void writeMkFile(const QString& wrapperFileName, bool deploymentOnly); virtual void writeWrapperMakefile(QFile& wrapperFile, bool isPrimaryMakefile); -- cgit v0.12