diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-06-12 16:57:33 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2014-07-02 14:02:48 +0200 |
commit | a22cadc6078e8f0c29bd8eb6f249b0bcd9357fc5 (patch) | |
tree | c05860bdf48799acfdec67c3243fb24b0ae573a2 /src | |
parent | 8de8e88a17e8b4595f28d6073746d7d69168249f (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')
-rw-r--r-- | src/lib/qtprofilesetup/qtprofilesetup.cpp | 29 | ||||
-rw-r--r-- | src/lib/qtprofilesetup/templates/QtModule.qbs | 6 | ||||
-rw-r--r-- | src/lib/qtprofilesetup/templates/gui.qbs | 1 | ||||
-rw-r--r-- | src/lib/qtprofilesetup/templates/module.qbs | 1 | ||||
-rw-r--r-- | src/lib/qtprofilesetup/templates/phonon.qbs | 1 |
5 files changed, 28 insertions, 10 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); } diff --git a/src/lib/qtprofilesetup/templates/QtModule.qbs b/src/lib/qtprofilesetup/templates/QtModule.qbs index ea8512b0d..5cc6391fa 100644 --- a/src/lib/qtprofilesetup/templates/QtModule.qbs +++ b/src/lib/qtprofilesetup/templates/QtModule.qbs @@ -21,12 +21,6 @@ Module { property bool isStaticLibrary: false Properties { - condition: qtModuleName != undefined - cpp.defines: qtModuleName.contains("private") - ? [] : [ "QT_" + qtModuleName.toUpperCase() + "_LIB" ] - } - - Properties { condition: qtModuleName != undefined && hasLibrary cpp.staticLibraries: isStaticLibrary ? [internalLibraryName] : undefined diff --git a/src/lib/qtprofilesetup/templates/gui.qbs b/src/lib/qtprofilesetup/templates/gui.qbs index 366b0250c..d97828b52 100644 --- a/src/lib/qtprofilesetup/templates/gui.qbs +++ b/src/lib/qtprofilesetup/templates/gui.qbs @@ -32,6 +32,7 @@ QtModule { } } + cpp.defines: @defines@ cpp.includePaths: @includes@ Properties { diff --git a/src/lib/qtprofilesetup/templates/module.qbs b/src/lib/qtprofilesetup/templates/module.qbs index 24fb359d4..11e6b55d8 100644 --- a/src/lib/qtprofilesetup/templates/module.qbs +++ b/src/lib/qtprofilesetup/templates/module.qbs @@ -5,6 +5,7 @@ QtModule { qtModuleName: @name@ Depends { name: "Qt"; submodules: @dependencies@} hasLibrary: @has_library@ + cpp.defines: @defines@ cpp.includePaths: @includes@ @special_properties@ } diff --git a/src/lib/qtprofilesetup/templates/phonon.qbs b/src/lib/qtprofilesetup/templates/phonon.qbs index 40bb534e8..46a3371db 100644 --- a/src/lib/qtprofilesetup/templates/phonon.qbs +++ b/src/lib/qtprofilesetup/templates/phonon.qbs @@ -5,5 +5,6 @@ QtModule { qtModuleName: "phonon" Depends { name: "Qt"; submodules: ['core'] } qtModulePrefix: '' + cpp.defines: @defines@ cpp.includePaths: @includes@ } |