From d050cb9c44d3c185a36f2af8be36ab70ce7a794e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 29 Jul 2009 08:37:57 +0300 Subject: Extended PKG customization possibilities via qmake. Task: 242139 This commit replaces Symbian specific 'depends' keyword in qmake DEPLOYMENT variable with two more generic ones. The new keywords are 'pkg_prerules' and 'pkg_postrules', and they allow developer to pass raw data to PKG file. The strings in 'pkg_prerules' are added before PKG file package-body headers and 'pkg_postrules' after them. Correspondingly as old 'depends' keyword, the new keywords are not parsed by qmake, so they must be in a format understood by Symbian package generation tools. Note that 'pkg_prerules' can also replace default language, package-header and vendor statements in pkg file. If you decide to override any of these statements, you need to pay attention that also other statements stay valid. --- demos/demobase.pri | 11 ++- doc/src/qmake-manual.qdoc | 32 +++++-- doc/src/snippets/code/doc_src_qmake-manual.qdoc | 6 +- examples/examplebase.pri | 12 ++- mkspecs/common/symbian/symbian.conf | 3 +- mkspecs/features/symbian/qt.prf | 3 +- qmake/generators/symbian/symmake.cpp | 106 +++++++++++++++++++----- qmake/generators/symbian/symmake.h | 1 + src/s60installs/qt_libs.pro | 15 +++- 9 files changed, 152 insertions(+), 37 deletions(-) diff --git a/demos/demobase.pri b/demos/demobase.pri index c0bba64..f010327 100644 --- a/demos/demobase.pri +++ b/demos/demobase.pri @@ -1 +1,10 @@ -symbian:RSS_RULES = "group_name=\"QtDemos\";" \ No newline at end of file +symbian { + RSS_RULES ="group_name=\"QtDemos\";" + + vendorinfo = \ + "; Localised Vendor name" \ + "%{\"Nokia, Qt Software\"}" \ + "; Unique Vendor name" \ + ":\"Nokia, Qt Software\"" + default_deployment.pkg_prerules += vendorinfo +} \ No newline at end of file diff --git a/doc/src/qmake-manual.qdoc b/doc/src/qmake-manual.qdoc index 68f1976..a167399 100644 --- a/doc/src/qmake-manual.qdoc +++ b/doc/src/qmake-manual.qdoc @@ -1358,14 +1358,36 @@ \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 128 - In Symbian, dependencies to other packages can also be created using - this variable. The strings defined as dependencies are not parsed by - qmake, so they should be in a format understood by Symbian package - generation tools. Please consult Symbian documentation for correct syntax. + In Symbian, generic PKG file content can also be specified with this + variable. You can use either \c pkg_prerules or \c pkg_postrules to + pass raw data to PKG file. The strings in \c pkg_prerules are added before + package-body and \c pkg_postrules after. The strings defined in + \c pkg_postrules or \c pkg_prerules are not parsed by qmake, so they + should be in a format understood by Symbian package generation tools. + Please consult Symbian documentation for correct syntax. - For example: + For example, to deploy DLL and add a new dependency: \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 140 + + Please note that \c pkg_prerules can also replace default statements in + pkg file. If no pkg_prerules is defined, qmake makes sure that PKG file + syntax is correct and it contains all mandatory statements such as: + + \list + \o languages, for example \BR + &EN,FR + \o package-header, for example \BR + #{"MyApp-EN", "MyApp-FR"}, (0x1000001F), 1, 2, 3, TYPE=SA + \o localized and unique vendor, for example \BR + %{"Vendor-EN", ..., "Vendor-FR"} + :"Unique vendor name" + \endlist + + If you decide to override any of these statements, you need to pay + attention that also other statements stay valid. For example if you + override languages statement, you must override also package-header + statement and all other statements which are language specific. In Symbian, the \c default_deployment item specifies default platform dependencies. It can be overwritten if a more diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.qdoc index b93e151..50515b7 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.qdoc @@ -885,14 +885,14 @@ MMP_RULES += myIfdefBlock //! [140] somelib.sources = somelib.dll somelib.path = \sys\bin -somelib.depends = "(0x12345678), 2, 2, 0, {\"Some Package\"}" \ +somelib.pkg_prerules = "(0x12345678), 2, 2, 0, {\"Some Package\"}" \ "(0x87654321), 1, *, * ~ 2, 2, 0, {\"Some Other Package\"}" -justdep.depends = "(0xAAAABBBB), 0, 2, 0, {\"My Framework\"}" +justdep.pkg_prerules = "(0xAAAABBBB), 0, 2, 0, {\"My Framework\"}" DEPLOYMENT += somelib justdep //! [140] //! [141] -default_deployment.depends = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}" +default_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}" //! [141] //! [142] diff --git a/examples/examplebase.pri b/examples/examplebase.pri index eff6588..84dcf92 100644 --- a/examples/examplebase.pri +++ b/examples/examplebase.pri @@ -1 +1,11 @@ -symbian:RSS_RULES ="group_name=\"QtExamples\";" \ No newline at end of file +symbian { + RSS_RULES ="group_name=\"QtExamples\";" + + vendorinfo = \ + "; Localised Vendor name" \ + "%{\"Nokia, Qt Software\"}" \ + "; Unique Vendor name" \ + ":\"Nokia, Qt Software\"" + default_deployment.pkg_prerules += vendorinfo +} + \ No newline at end of file diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 4f3e1d2..fbadadc 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -118,7 +118,8 @@ INCLUDEPATH = \ $$INCLUDEPATH # Supports S60 3.0, 3.1, 3.2 and 5.0 by default -default_deployment.depends = \ +default_deployment.pkg_prerules = \ + "; Default HW/platform dependencies" \ "[0x101F7961],0,0,0,{\"S60ProductID\"}" \ "[0x102032BE],0,0,0,{\"S60ProductID\"}" \ "[0x102752AE],0,0,0,{\"S60ProductID\"}" \ diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf index 29b39a5..db2ea14 100644 --- a/mkspecs/features/symbian/qt.prf +++ b/mkspecs/features/symbian/qt.prf @@ -7,7 +7,8 @@ CONFIG += qtmain load(qt) contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C) { - default_deployment.depends += \ + default_deployment.pkg_prerules += \ + "; Default dependency to Qt libraries" \ "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {\"QtLibs pre-release\"}" } diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp index ec19675..34ab560 100644 --- a/qmake/generators/symbian/symmake.cpp +++ b/qmake/generators/symbian/symmake.cpp @@ -286,36 +286,67 @@ bool SymbianMakefileGenerator::generatePkgFile(const QString &compiler, const QS t << QString("; %1 generated by qmake at %2").arg(pkgFilename).arg(QDateTime::currentDateTime().toString(Qt::ISODate)) << endl; t << "; This file is generated by qmake and should not be modified by the user" << endl; t << ";" << endl << endl; - - // language, (*** hardcoded to english atm) - t << "; Language" << endl; - t << "&EN" << endl << endl; + + // Construct QStringList from pkg_prerules since we need search it before printed to file + QStringList rawPkgPreRules; + foreach(QString deploymentItem, project->values("DEPLOYMENT")) { + foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_prerules")) { + QStringList pkgrulesValue = project->values(pkgrulesItem); + // If there is no stringlist defined for a rule, use rule name directly + // This is convenience for defining single line mmp statements + if (pkgrulesValue.isEmpty()){ + rawPkgPreRules << pkgrulesItem; + } else { + foreach(QString pkgrule, pkgrulesValue) { + rawPkgPreRules << pkgrule; + } + } + } + } + + // Apply some defaults if specific data does not exist in PKG pre-rules + + if(!containsStartWithItem('&', rawPkgPreRules)) { + // language, (*** hardcoded to english atm, should be parsed from TRANSLATIONS) + t << "; Language" << endl; + t << "&EN" << endl << endl; + } else { + // In case user defines langs, he must take care also about SIS header + if(!containsStartWithItem('#', rawPkgPreRules)) + fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n"); + } // name of application, UID and version QString applicationName = project->first("TARGET"); int last = applicationName.lastIndexOf(QLatin1Char('/')); applicationName = applicationName.mid( last == -1 ? 0 : last+1 ); - QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ','); + + if(!containsStartWithItem('#', rawPkgPreRules)) { + t << "; SIS header: name, uid, version" << endl; + t << QString("#{\"%1\"},(%2),%3").arg(applicationName).arg(uid3).arg(applicationVersion) << endl << endl; + } - t << "; SIS header: name, uid, version" << endl; - t << QString("#{\"%1\"},(%2),%3").arg(applicationName).arg(uid3).arg(applicationVersion) << endl << endl; - - // vendor names (*** hardcoded for now) - t << "; Localised Vendor name" << endl; - t << "%{\"Nokia, Qt Software\"}" << endl << endl; - t << "; Unique Vendor name" << endl; - t << ":\"Nokia, Qt Software\"" << endl << endl; - - // Dependencies - t << "; Dependencies" << endl; - foreach(QString item, project->values("DEPLOYMENT")) { - QStringList dependencies = project->values(item + ".depends"); - foreach(QString dependency, dependencies) { - t << dependency << endl; - } + // Localized vendor name + if(!containsStartWithItem('%', rawPkgPreRules)) { + t << "; Localised Vendor name" << endl; + t << "%{\"Vendor\"}" << endl << endl; + } + + // Unique vendor name + if(!containsStartWithItem(':', rawPkgPreRules)) { + t << "; Unique Vendor name" << endl; + t << ":\"Vendor\"" << endl << endl; } - t << endl; + + // PKG pre-rules - these are added before actual file installations i.e. SISX package body + if(rawPkgPreRules.size()) { + t << "; Manual PKG pre-rules from PRO files" << endl; + foreach(QString item, rawPkgPreRules) { + t << item << endl; + } + t << endl; + } // install paths on the phone *** should be dynamic at some point QString installPathBin = "!:\\sys\\bin"; @@ -378,10 +409,41 @@ bool SymbianMakefileGenerator::generatePkgFile(const QString &compiler, const QS .arg(QString(depList.at(i).from).replace('\\','/')) .arg(depList.at(i).to) << endl; } + t << endl; + + // PKG post-rules - these are added after actual file installations i.e. SISX package body + t << "; Manual PKG post-rules from PRO files" << endl; + foreach(QString deploymentItem, project->values("DEPLOYMENT")) { + foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_postrules")) { + QStringList pkgrulesValue = project->values(pkgrulesItem); + // If there is no stringlist defined for a rule, use rule name directly + // This is convenience for defining single line mmp statements + if (pkgrulesValue.isEmpty()){ + t << pkgrulesItem << endl; + } else { + foreach(QString pkgrule, pkgrulesValue) { + t << pkgrule << endl; + } + } + t << endl; + } + } return true; } +bool SymbianMakefileGenerator::containsStartWithItem(const QChar &c, const QStringList& src) +{ + bool result = false; + foreach (QString str, src) { + if (str.startsWith(c)) { + result = true; + break; + } + } + return result; +} + bool SymbianMakefileGenerator::writeCustomDefFile() { if(targetType.compare("plugin", Qt::CaseInsensitive) == 0 && !project->values("CONFIG").contains("stdbinary", Qt::CaseInsensitive)) { // Create custom def file for plugin diff --git a/qmake/generators/symbian/symmake.h b/qmake/generators/symbian/symmake.h index 52c3c4d..aade0a0 100644 --- a/qmake/generators/symbian/symmake.h +++ b/qmake/generators/symbian/symmake.h @@ -86,6 +86,7 @@ protected: virtual bool writeMakefile(QTextStream &t); bool generatePkgFile(const QString &compiler, const QString &config, const QString &iconFile); + bool containsStartWithItem(const QChar &c, const QStringList& src); virtual void init(); diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index bd5c67f..a3be711 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -37,12 +37,21 @@ symbian: { #ENDIF qtlibraries.path = /sys/bin - qtlibraries.depends = "(0x20013851), 1, 5, 1, {\"PIPS Installer\"}" + + vendorinfo = \ + "; Localised Vendor name" \ + "%{\"Nokia, Qt Software\"}" \ + "; Unique Vendor name" \ + ":\"Nokia, Qt Software\"" + + qtlibraries.pkg_prerules = vendorinfo + qtlibraries.pkg_prerules += "; Dependencies of Qt libraries" + qtlibraries.pkg_prerules += "(0x20013851), 1, 5, 1, {\"PIPS Installer\"}" contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { - qtlibraries.depends += "(0x200110CB), 1, 5, 1, {\"Open C LIBSSL Common\"}" + qtlibraries.pkg_prerules += "(0x200110CB), 1, 5, 1, {\"Open C LIBSSL Common\"}" } contains(CONFIG, stl) { - qtlibraries.depends += "(0x2000F866), 1, 0, 0, {\"Standard C++ Library Common\"}" + qtlibraries.pkg_prerules += "(0x2000F866), 1, 0, 0, {\"Standard C++ Library Common\"}" } !contains(QT_CONFIG, no-jpeg): imageformats_plugins.sources += qjpeg.dll -- cgit v0.12