aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/qtprofilesetup/qtprofilesetup.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-06-12 16:57:33 +0200
committerJoerg Bornemann <joerg.bornemann@digia.com>2014-07-02 14:02:48 +0200
commita22cadc6078e8f0c29bd8eb6f249b0bcd9357fc5 (patch)
treec05860bdf48799acfdec67c3243fb24b0ae573a2 /src/lib/qtprofilesetup/qtprofilesetup.cpp
parent8de8e88a17e8b4595f28d6073746d7d69168249f (diff)
revisit how Qt compiler defines are set up
Move the logic from QtModule.qbs to libqtprofilesetup. Change-Id: Ie0a19cb5da996dfbf76c4ae09416fdcc54e52b27 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/qtprofilesetup/qtprofilesetup.cpp')
-rw-r--r--src/lib/qtprofilesetup/qtprofilesetup.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/lib/qtprofilesetup/qtprofilesetup.cpp b/src/lib/qtprofilesetup/qtprofilesetup.cpp
index 2d34f69f5..f9e08bf6f 100644
--- a/src/lib/qtprofilesetup/qtprofilesetup.cpp
+++ b/src/lib/qtprofilesetup/qtprofilesetup.cpp
@@ -76,6 +76,7 @@ struct QtModuleInfo
QString version;
QStringList dependencies; // qbs names.
QStringList includePaths;
+ QStringList compilerDefines;
bool isPrivate;
bool hasLibrary;
bool isStaticLibrary;
@@ -155,6 +156,7 @@ static void replaceSpecialValues(const QString &filePath, const Profile &profile
content.replace("@dependencies@", utf8JSLiteral(module.dependencies));
content.replace("@includes@", utf8JSLiteral(module.includePaths));
QByteArray propertiesString;
+ QByteArray compilerDefines = utf8JSLiteral(module.compilerDefines);
if (module.qbsName == QLatin1String("declarative")
|| module.qbsName == QLatin1String("quick")) {
const QByteArray debugMacro = module.qbsName == QLatin1String("declarative")
@@ -163,10 +165,7 @@ static void replaceSpecialValues(const QString &filePath, const Profile &profile
const QString indent = QLatin1String(" ");
QTextStream s(&propertiesString);
- s << "property bool qmlDebugging: false" << endl
- << indent << "cpp.defines: "
- << "qmlDebugging ? base.concat('" + debugMacro + "') : base" << endl;
-
+ s << "property bool qmlDebugging: false" << endl;
s << indent << "property string qmlPath";
if (qtEnvironment.qmlPath.isEmpty())
s << endl;
@@ -175,7 +174,16 @@ static void replaceSpecialValues(const QString &filePath, const Profile &profile
s << indent << "property string qmlImportsPath: "
<< pathToJSLiteral(qtEnvironment.qmlImportPath);
+
+ const QByteArray baIndent(4, ' ');
+ compilerDefines = "{\n"
+ + baIndent + baIndent + "var result = " + compilerDefines + ";\n"
+ + baIndent + baIndent + "if (qmlDebugging)\n"
+ + baIndent + baIndent + baIndent + "result.push(\"" + debugMacro + "\");\n"
+ + baIndent + baIndent + "return result;\n"
+ + baIndent + "}";
}
+ content.replace("@defines@", compilerDefines);
if (!module.modulePrefix.isEmpty()) {
if (!propertiesString.isEmpty())
propertiesString += "\n ";
@@ -293,6 +301,7 @@ static void createModules(Profile &profile, Settings *settings,
QtModuleInfo axserver = axcontainer;
axserver.name = QLatin1String("QAxServer");
axserver.qbsName = QLatin1String("axserver");
+ axserver.compilerDefines = QStringList() << QLatin1String("QAXSERVER");
modules << axserver;
QtModuleInfo designerComponentsPrivate(QLatin1String("QtDesignerComponents"),
@@ -313,6 +322,15 @@ static void createModules(Profile &profile, Settings *settings,
module.includePaths = qt4ModuleIncludePaths(qtEnvironment, module);
}
+ // Set up compiler defines haven't been set up before this point.
+ for (QList<QtModuleInfo>::iterator it = modules.begin(); it != modules.end(); ++it) {
+ QtModuleInfo &module = *it;
+ if (!module.compilerDefines.isEmpty())
+ continue;
+ module.compilerDefines
+ << QLatin1String("QT_") + module.name.toUpper() + QLatin1String("_LIB");
+ }
+
// These are for the convenience of project file authors. It allows them
// to add a dependency to e.g. "Qt.widgets" without a version check.
QtModuleInfo virtualModule;
@@ -384,6 +402,9 @@ static void createModules(Profile &profile, Settings *settings,
QLatin1String("$$QT_MODULE_INCLUDE_BASE"),
qtEnvironment.includePath);
}
+ } else if (key.endsWith(".DEFINES")) {
+ moduleInfo.compilerDefines = QString::fromLocal8Bit(value)
+ .split(QLatin1Char(' '), QString::SkipEmptyParts);
} else if (key.endsWith(".VERSION")) {
moduleInfo.version = QString::fromLocal8Bit(value);
}