From 08c1c9ef6f30706cd574eded656f4d65a1b18db5 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 28 Jan 2010 14:06:48 +0200 Subject: Added support for ifdeffing for manufacturer in generated pkg files DEPLOYMENT.manufacturers variable can be used to define manufacturer identifiers. DEPLOYMENT.manufacturers.fail_note variable can be used to define a file that contains the text to be shown in case of failed manufacturer check. Task-number: QTBUG-7695 Reviewed-by: Janne Koskinen --- bin/patch_capabilities.pl | 25 +++++++++++++++++++++- qmake/generators/symbian/symmake.cpp | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index 9daa13e..8afe776 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -108,6 +108,8 @@ if (@ARGV) open (NEW_PKG, ">>".$tempPkgFileName); open (PKG, "<".$pkgFileName); + my $manufacturerElseBlock = 0; + # Parse each line. while () { @@ -133,7 +135,28 @@ if (@ARGV) # from depended packages that are also patched and therefore have different UID. if ($line =~ m/^\(0x[0-9|a-f|A-F]*\).*\{.*\}$/) { - $newLine = "" + $newLine = "\n" + } + + # Remove manufacturer ifdef + if ($line =~ m/^.*\(MANUFACTURER\)\=\(.*\).*$/) + { + $newLine = "\n"; + } + + if ($line =~ m/^ELSEIF.*MANUFACTURER$/) + { + $manufacturerElseBlock = 1; + } + + if ($manufacturerElseBlock eq 1) + { + $newLine = "\n"; + } + + if ($line =~ m/^ENDIF.*MANUFACTURER$/) + { + $manufacturerElseBlock = 0; } print NEW_PKG $newLine; diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index 20e2d0e..a23ec60 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -94,6 +94,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; @@ -354,6 +359,17 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, Deployme 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"; @@ -428,6 +444,30 @@ void SymbianMakefileGenerator::generatePkgFile(const QString &iconFile, Deployme 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) -- cgit v0.12