summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2011-05-16 15:30:04 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2011-05-16 16:54:15 +0300
commit5f0de35a576cae9333c41dbdd43c8489b20e878a (patch)
tree374e74f0f97506b81cc6053799c8dd0d498eeb6e /qmake
parent674d85693171c308487080f33a4f1ff87ec9d4c4 (diff)
Improve DEFINES crossplatform compatibility in Symbian builds.
DEFINES statements that define strings needed separate statements for symbian-sbsv2 builds and Makefile based plaforms, as there is one extra layer of escaping needed in Makefile builds. Improved compatibility by making qmake remove one layer of escaping before writing the .mmp MACROs based on DEFINES. Note: Symbian-abld builds still do not support string DEFINES as the toolchain simply can't handle them in .mmp files, no matter how they are escaped. Note2: Symbian-sbsv2 support for escaped DEFINES is not perfect either, as bld.inf files do not like doubly escaped characters in extension rules (e.g. double-quotation mark as part of a string). This makes it impossible to pass such DEFINES to extra compilers. Task-number: QTBUG-19232 Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/symbian/symmake.cpp25
-rw-r--r--qmake/generators/symbian/symmake_sbsv2.cpp21
2 files changed, 42 insertions, 4 deletions
diff --git a/qmake/generators/symbian/symmake.cpp b/qmake/generators/symbian/symmake.cpp
index 08d33700f7..50caaf1596 100644
--- a/qmake/generators/symbian/symmake.cpp
+++ b/qmake/generators/symbian/symmake.cpp
@@ -574,7 +574,30 @@ void SymbianMakefileGenerator::writeMmpFileMacrosPart(QTextStream& t)
void SymbianMakefileGenerator::addMacro(QTextStream& t, const QString& value)
{
- t << "MACRO\t\t" << value << endl;
+ // String macros for Makefile based platforms are defined like this in pro files:
+ //
+ // DEFINES += VERSION_STRING=\\\"1.2.3\\\"
+ //
+ // This will not work in *.mmp files, which don't need double escaping, and
+ // will therefore result in a VERSION_STRING value of \"1.2.3\" instead of "1.2.3".
+ // Improve cross platform support by removing one level of escaping from all
+ // DEFINES values.
+ static QChar backslash = QLatin1Char('\\');
+ QString fixedValue;
+ fixedValue.reserve(value.size());
+ int pos = 0;
+ int prevPos = 0;
+ while (pos < value.size()) {
+ if (value.at(pos) == backslash) {
+ fixedValue += value.mid(prevPos, pos - prevPos);
+ pos++;
+ prevPos = pos;
+ }
+ pos++;
+ }
+ fixedValue += value.mid(prevPos);
+
+ t << "MACRO\t\t" << fixedValue << endl;
}
diff --git a/qmake/generators/symbian/symmake_sbsv2.cpp b/qmake/generators/symbian/symmake_sbsv2.cpp
index 767645ac2d..9614615a79 100644
--- a/qmake/generators/symbian/symmake_sbsv2.cpp
+++ b/qmake/generators/symbian/symmake_sbsv2.cpp
@@ -569,12 +569,27 @@ void SymbianSbsv2MakefileGenerator::writeBldInfExtensionRulesPart(QTextStream& t
exportFlm();
// Parse extra compilers data
+ QStringList rawDefines;
QStringList defines;
QStringList incPath;
- defines << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
- << varGlue("QMAKE_COMPILER_DEFINES", "-D", "-D", " ")
- << varGlue("DEFINES","-D"," -D","");
+ rawDefines << project->values("PRL_EXPORT_DEFINES")
+ << project->values("QMAKE_COMPILER_DEFINES")
+ << project->values("DEFINES");
+
+ // Remove defines containing doubly-escaped characters (e.g. escaped double-quotation mark
+ // inside a string define) as bld.inf parsing done by sbsv2 toolchain breaks if they are
+ // present.
+ static QString backslashes = QLatin1String("\\\\");
+ QMutableStringListIterator i(rawDefines);
+ while (i.hasNext()) {
+ QString val = i.next();
+ if (val.indexOf(backslashes) != -1)
+ i.remove();
+ }
+
+ defines << valGlue(rawDefines,"-D"," -D","");
+
for (QMap<QString, QStringList>::iterator it = systeminclude.begin(); it != systeminclude.end(); ++it) {
QStringList values = it.value();
for (int i = 0; i < values.size(); ++i) {