diff options
| author | Joerg Bornemann <joerg.bornemann@digia.com> | 2012-10-06 11:15:28 +0200 |
|---|---|---|
| committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2012-10-08 11:50:32 +0200 |
| commit | e613c095d1a93b8c4e12fd02852bfba9193301d5 (patch) | |
| tree | 06670f2825d97aa85c9803786960d01a91b4d70d /src/lib/buildgraph/automoc.cpp | |
| parent | cab09d5a31a6b793be13281281c41070bed77ac3 (diff) | |
| download | qbs-e613c095d1a93b8c4e12fd02852bfba9193301d5.tar.gz | |
support Qt5 plugin metadata json files
For the metadata .json files of Qt5 plugins, qbs now supports the
qt_plugin_metadata filetag.
C++ header files are scanned for the Q_PLUGIN_METADATA macro. If it is
found, the qt_plugin_metadata file is added to the dependents of the
resulting moc_XXX.cpp file.
Change-Id: I4b68fd9a99847640f87a40e15819382ead74b0d3
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/buildgraph/automoc.cpp')
| -rw-r--r-- | src/lib/buildgraph/automoc.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/buildgraph/automoc.cpp b/src/lib/buildgraph/automoc.cpp index 22dd84b4c..7b3557825 100644 --- a/src/lib/buildgraph/automoc.cpp +++ b/src/lib/buildgraph/automoc.cpp @@ -38,6 +38,7 @@ #include "automoc.h" #include "scanresultcache.h" #include <buildgraph/artifact.h> +#include <buildgraph/transformer.h> #include <tools/error.h> #include <tools/logger.h> #include <tools/scannerpluginmanager.h> @@ -59,11 +60,17 @@ void AutoMoc::apply(BuildProduct::Ptr product) if (scanners().isEmpty()) throw Error("C++ scanner cannot be loaded."); + Artifact *pluginMetaDataFile = 0; QList<QPair<Artifact *, FileType> > artifactsToMoc; QSet<QString> includedMocCppFiles; ArtifactList::const_iterator it = product->artifacts.begin(); for (; it != product->artifacts.end(); ++it) { Artifact *artifact = *it; + if (!pluginMetaDataFile && artifact->fileTags.contains(QLatin1String("qt_plugin_metadata"))) { + if (qbsLogLevel(LoggerDebug)) + qbsDebug() << "[AUTOMOC] found Qt plugin metadata file " << artifact->filePath(); + pluginMetaDataFile = artifact; + } if (artifact->artifactType != Artifact::SourceFile) continue; const FileType fileType = AutoMoc::fileType(artifact); @@ -80,6 +87,7 @@ void AutoMoc::apply(BuildProduct::Ptr product) } } + Artifact *pluginHeaderFile = 0; QMap<QString, QSet<Artifact *> > artifactsPerFileTag; for (int i = artifactsToMoc.count(); --i >= 0;) { const QPair<Artifact *, FileType> &p = artifactsToMoc.at(i); @@ -95,6 +103,14 @@ void AutoMoc::apply(BuildProduct::Ptr product) artifactsPerFileTag[newFileTag].insert(artifact); continue; } + } else if (fileTag == QLatin1String("moc_plugin_hpp")) { + if (qbsLogLevel(LoggerDebug)) + qbsDebug() << "[AUTOMOC] found Qt plugin header file " << artifact->filePath(); + QString newFileTag = QLatin1String("moc_hpp"); + artifact->fileTags -= fileTag; + artifact->fileTags += newFileTag; + artifactsPerFileTag[newFileTag].insert(artifact); + pluginHeaderFile = artifact; } artifactsPerFileTag[fileTag].insert(artifact); } @@ -105,6 +121,13 @@ void AutoMoc::apply(BuildProduct::Ptr product) qbsInfo() << DontPrintLogLevel << "Applying moc rules for '" << product->rProduct->name << "'."; buildGraph->applyRules(product.data(), artifactsPerFileTag); } + if (pluginHeaderFile && pluginMetaDataFile) { + // Make every artifact that is dependent of the header file also + // dependent of the plugin metadata file. + foreach (Artifact *outputOfHeader, pluginHeaderFile->parents) + buildGraph->loggedConnect(outputOfHeader, pluginMetaDataFile); + } + buildGraph->updateNodesThatMustGetNewTransformer(); } |
