diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2018-04-20 17:28:54 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2018-04-27 08:54:09 +0000 |
commit | f66a0df5b91fc38e261c0c857191064f9e02342c (patch) | |
tree | cac749b2260970f751bf5a3c4c634cc94b4f3e6f /src/lib | |
parent | f9df74c5348ab5fab1b49014e43b72fa5407ef42 (diff) |
ModuleLoader: Add convenience function for shadow products
It tells us whether a product is a shadow product and if so,
what the name of the real product is.
We will make more use of it in a follow-up commit.
Change-Id: I2d7f9f08c78f303058d33b7ce004af8751bc1ed4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/corelib/language/moduleloader.cpp | 14 | ||||
-rw-r--r-- | src/lib/corelib/language/moduleloader.h | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 9dceff7a6..1adcdbc50 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -938,8 +938,8 @@ void ModuleLoader::adjustDependenciesForMultiplexing(const ModuleLoader::Product continue; QStringList multiplexIds; - const bool isShadowProduct = product.name.startsWith(shadowProductPrefix()) - && product.name.mid(shadowProductPrefix().size()) == name; + const ShadowProductInfo shadowProductInfo = getShadowProductInfo(product); + const bool isShadowProduct = shadowProductInfo.first && shadowProductInfo.second == name; for (const ProductContext *dependency : dependencies) { const bool depMatchesShadowProduct = isShadowProduct && dependency->item == product.item->parent(); @@ -1030,7 +1030,7 @@ void ModuleLoader::prepareProduct(ProjectContext *projectContext, Item *productI projectContext->products.push_back(productContext); - if (!hasExportItems || productContext.name.startsWith(shadowProductPrefix())) + if (!hasExportItems || getShadowProductInfo(productContext).first) return; // This "shadow product" exists only to pull in a dependency on the actual product @@ -1928,6 +1928,14 @@ void ModuleLoader::checkProductNamesInOverrides() } } +ModuleLoader::ShadowProductInfo ModuleLoader::getShadowProductInfo( + const ModuleLoader::ProductContext &product) const +{ + const bool isShadowProduct = product.name.startsWith(shadowProductPrefix()); + return std::make_pair(isShadowProduct, isShadowProduct + ? product.name.mid(shadowProductPrefix().size()) : QString()); +} + void ModuleLoader::collectProductsByName(const TopLevelProjectContext &topLevelProject) { for (ProjectContext * const project : topLevelProject.projects) { diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h index cf97c16b0..f559105b5 100644 --- a/src/lib/corelib/language/moduleloader.h +++ b/src/lib/corelib/language/moduleloader.h @@ -57,6 +57,7 @@ #include <map> #include <memory> #include <unordered_map> +#include <utility> #include <vector> namespace qbs { @@ -348,6 +349,9 @@ private: void checkProjectNamesInOverrides(const TopLevelProjectContext &tlp); void checkProductNamesInOverrides(); + using ShadowProductInfo = std::pair<bool, QString>; + ShadowProductInfo getShadowProductInfo(const ProductContext &product) const; + ItemPool *m_pool; Logger &m_logger; ProgressObserver *m_progressObserver; |