From 9205bc7aeb9ff33565dc0ddec621c2b773da46ab Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 27 Jul 2017 10:10:51 +0200 Subject: [PATCH] QbsPM: Implement configureAsExampleProject function This function is used in some of the plugin unit tests of QC. Change-Id: I8e5f5b734a78a207f139b676aa6616abcc9ce7c0 Reviewed-by: Christian Kandeler --- src/plugins/qbsprojectmanager/qbsproject.cpp | 25 ++++++++++++++++++++ src/plugins/qbsprojectmanager/qbsproject.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index 295a70690f5..166c386570b 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -689,6 +690,30 @@ QString QbsProject::uniqueProductName(const qbs::ProductData &product) return product.name() + QLatin1Char('.') + product.profile(); } +void QbsProject::configureAsExampleProject(const QSet &platforms) +{ + QList infoList; + QList kits = KitManager::kits(); + const auto qtVersionMatchesPlatform = [platforms](const QtSupport::BaseQtVersion *version) { + return platforms.isEmpty() || platforms.intersects(version->targetDeviceTypes()); + }; + foreach (Kit *k, kits) { + const QtSupport::BaseQtVersion * const qtVersion + = QtSupport::QtKitInformation::qtVersion(k); + if (!qtVersion || !qtVersionMatchesPlatform(qtVersion)) + continue; + const IBuildConfigurationFactory * const factory + = IBuildConfigurationFactory::find(k, projectFilePath().toString()); + if (!factory) + continue; + for (BuildInfo * const info : factory->availableSetups(k, projectFilePath().toString())) + infoList << info; + } + setup(infoList); + qDeleteAll(infoList); + prepareForParsing(); +} + void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir, const QString &configName) { diff --git a/src/plugins/qbsprojectmanager/qbsproject.h b/src/plugins/qbsprojectmanager/qbsproject.h index 500761380bd..8d2e0c8cbde 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.h +++ b/src/plugins/qbsprojectmanager/qbsproject.h @@ -108,6 +108,8 @@ public: const qbs::ProductData &product); static QString uniqueProductName(const qbs::ProductData &product); + void configureAsExampleProject(const QSet &platforms) final; + public: void invalidate(); void delayParsing();