QbsProjectManager: Make use of qbs config --add-profile

... if available.

Task-number: QTCREATORBUG-25463
Change-Id: I7fc8a06a5c43b35c4b1b571504d31cc03a95b189
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-06-24 12:49:17 +02:00
parent bd9bcdb925
commit 472f9c30d3
2 changed files with 16 additions and 4 deletions

View File

@@ -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());
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())

View File

@@ -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();