From 472f9c30d34f60cd4bbd318f7e4b978bc20ae404 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 24 Jun 2021 12:49:17 +0200 Subject: [PATCH] QbsProjectManager: Make use of qbs config --add-profile ... if available. Task-number: QTCREATORBUG-25463 Change-Id: I7fc8a06a5c43b35c4b1b571504d31cc03a95b189 Reviewed-by: Christian Stenger --- .../qbsprojectmanager/qbsprofilemanager.cpp | 17 ++++++++++++++--- .../qbsprojectmanager/qbsprofilemanager.h | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp b/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp index ef93c2a4b0b..96527ad3007 100644 --- a/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp +++ b/src/plugins/qbsprojectmanager/qbsprofilemanager.cpp @@ -183,9 +183,13 @@ void QbsProfileManager::addProfileFromKit(const ProjectExplorer::Kit *k) if (const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitAspect::qtVersion(k)) data.insert("moduleProviders.Qt.qmakeFilePaths", qt->qmakeCommand().toString()); - const QString keyPrefix = "profiles." + name + "."; - for (auto it = data.begin(); it != data.end(); ++it) - runQbsConfig(QbsConfigOp::Set, keyPrefix + it.key(), it.value()); + if (QbsSettings::qbsVersion() < QVersionNumber({1, 20})) { + const QString keyPrefix = "profiles." + name + "."; + for (auto it = data.begin(); it != data.end(); ++it) + runQbsConfig(QbsConfigOp::Set, keyPrefix + it.key(), it.value()); + } else { + runQbsConfig(QbsConfigOp::AddProfile, name, data); + } emit qbsProfilesUpdated(); } @@ -228,6 +232,13 @@ QString QbsProfileManager::runQbsConfig(QbsConfigOp op, const QString &key, cons case QbsConfigOp::Unset: args << "--unset" << key; break; + case QbsConfigOp::AddProfile: { + args << "--add-profile" << key; + const QVariantMap props = value.toMap(); + for (auto it = props.begin(); it != props.end(); ++it) + args << it.key() << toJSLiteral(it.value()); + break; + } } const Utils::FilePath qbsExe = QbsSettings::qbsExecutableFilePath(); if (qbsExe.isEmpty() || !qbsExe.exists()) diff --git a/src/plugins/qbsprojectmanager/qbsprofilemanager.h b/src/plugins/qbsprojectmanager/qbsprofilemanager.h index 9e4b9600dcc..745802da8de 100644 --- a/src/plugins/qbsprojectmanager/qbsprofilemanager.h +++ b/src/plugins/qbsprojectmanager/qbsprofilemanager.h @@ -52,7 +52,8 @@ public: static QString ensureProfileForKit(const ProjectExplorer::Kit *k); static QString profileNameForKit(const ProjectExplorer::Kit *kit); static void updateProfileIfNecessary(const ProjectExplorer::Kit *kit); - enum class QbsConfigOp { Get, Set, Unset }; static QString runQbsConfig(QbsConfigOp op, const QString &key, const QVariant &value = {}); + enum class QbsConfigOp { Get, Set, Unset, AddProfile }; + static QString runQbsConfig(QbsConfigOp op, const QString &key, const QVariant &value = {}); signals: void qbsProfilesUpdated();