forked from qt-creator/qt-creator
QbsProjectManager: Do not call qbs config unnecessarily
- We know the name of the profile for a given kit. There is no need to call qbs config to retrieve it. - Do not update a profile upon kit removal. Change-Id: I1a555233091c69d9ea6daa1e4a11737719c37fdf Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -182,7 +182,7 @@ bool QbsBuildConfiguration::fromMap(const QVariantMap &map)
|
||||
return false;
|
||||
|
||||
if (m_configurationName->value().isEmpty()) { // pre-4.4 backwards compatibility
|
||||
const QString profileName = QbsProfileManager::profileForKit(target()->kit());
|
||||
const QString profileName = QbsProfileManager::profileNameForKit(target()->kit());
|
||||
const QString buildVariant = qbsConfiguration()
|
||||
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
|
||||
m_configurationName->setValue(profileName + '-' + buildVariant);
|
||||
@@ -376,7 +376,7 @@ QString QbsBuildConfiguration::equivalentCommandLine(const BuildStep *buildStep)
|
||||
if (jobCount > 0)
|
||||
commandLine.addArgs({"--jobs", QString::number(jobCount)});
|
||||
|
||||
const QString profileName = QbsProfileManager::profileForKit(buildStep->target()->kit());
|
||||
const QString profileName = QbsProfileManager::profileNameForKit(buildStep->target()->kit());
|
||||
const QString buildVariant = qbsConfiguration()
|
||||
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
|
||||
commandLine.addArg("config:" + configurationName());
|
||||
|
||||
@@ -146,17 +146,12 @@ QbsProfileManager *QbsProfileManager::instance()
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
QString QbsProfileManager::profileForKit(const ProjectExplorer::Kit *k)
|
||||
QString QbsProfileManager::ensureProfileForKit(const ProjectExplorer::Kit *k)
|
||||
{
|
||||
if (!k)
|
||||
return QString();
|
||||
m_instance->updateProfileIfNecessary(k);
|
||||
const QString output = runQbsConfig(QbsConfigOp::Get, kitNameKeyInQbsSettings(k));
|
||||
const int endQuoteIdx = output.lastIndexOf('"');
|
||||
QTC_ASSERT(endQuoteIdx != -1, return QString());
|
||||
const int startQuoteIdx = output.lastIndexOf('"', endQuoteIdx - 1);
|
||||
QTC_ASSERT(startQuoteIdx != -1, return QString());
|
||||
return output.mid(startQuoteIdx + 1, endQuoteIdx - startQuoteIdx - 1);
|
||||
return profileNameForKit(k);
|
||||
}
|
||||
|
||||
void QbsProfileManager::setProfileForKit(const QString &name, const ProjectExplorer::Kit *k)
|
||||
@@ -197,9 +192,7 @@ void QbsProfileManager::addQtProfileFromKit(const QString &profileName, const Pr
|
||||
|
||||
void QbsProfileManager::addProfileFromKit(const ProjectExplorer::Kit *k)
|
||||
{
|
||||
const QString name = QString::fromLatin1("qtc_%1_%2").arg(k->fileSystemFriendlyName().left(8),
|
||||
QString::fromLatin1(QCryptographicHash::hash(k->id().name(),
|
||||
QCryptographicHash::Sha1).toHex().left(8)));
|
||||
const QString name = profileNameForKit(k);
|
||||
runQbsConfig(QbsConfigOp::Unset, "profiles." + name);
|
||||
setProfileForKit(name, k);
|
||||
addQtProfileFromKit(name, k);
|
||||
@@ -224,10 +217,19 @@ void QbsProfileManager::handleKitRemoval(ProjectExplorer::Kit *kit)
|
||||
{
|
||||
m_kitsToBeSetupForQbs.removeOne(kit);
|
||||
runQbsConfig(QbsConfigOp::Unset, kitNameKeyInQbsSettings(kit));
|
||||
runQbsConfig(QbsConfigOp::Unset, "profiles." + profileForKit(kit));
|
||||
runQbsConfig(QbsConfigOp::Unset, "profiles." + profileNameForKit(kit));
|
||||
emit qbsProfilesUpdated();
|
||||
}
|
||||
|
||||
QString QbsProfileManager::profileNameForKit(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
if (!kit)
|
||||
return QString();
|
||||
return QString::fromLatin1("qtc_%1_%2").arg(kit->fileSystemFriendlyName().left(8),
|
||||
QString::fromLatin1(QCryptographicHash::hash(
|
||||
kit->id().name(), QCryptographicHash::Sha1).toHex().left(8)));
|
||||
}
|
||||
|
||||
QString QbsProfileManager::runQbsConfig(QbsConfigOp op, const QString &key, const QVariant &value)
|
||||
{
|
||||
QProcess qbsConfig;
|
||||
|
||||
@@ -49,7 +49,8 @@ public:
|
||||
|
||||
static QbsProfileManager *instance();
|
||||
|
||||
static QString profileForKit(const ProjectExplorer::Kit *k);
|
||||
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 = {});
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ void QbsProfilesSettingsWidget::displayCurrentProfile()
|
||||
const Core::Id kitId = Core::Id::fromSetting(m_ui.kitsComboBox->currentData());
|
||||
const Kit * const kit = KitManager::kit(kitId);
|
||||
QTC_ASSERT(kit, return);
|
||||
const QString profileName = QbsProfileManager::profileForKit(kit);
|
||||
const QString profileName = QbsProfileManager::ensureProfileForKit(kit);
|
||||
m_ui.profileValueLabel->setText(profileName);
|
||||
for (int i = 0; i < m_model.rowCount(); ++i) {
|
||||
const QModelIndex currentProfileIndex = m_model.index(i, 0);
|
||||
|
||||
@@ -435,7 +435,7 @@ bool QbsBuildSystem::renameFileInProduct(
|
||||
|
||||
QString QbsBuildSystem::profile() const
|
||||
{
|
||||
return QbsProfileManager::profileForKit(target()->kit());
|
||||
return QbsProfileManager::ensureProfileForKit(target()->kit());
|
||||
}
|
||||
|
||||
bool QbsBuildSystem::checkCancelStatus()
|
||||
|
||||
Reference in New Issue
Block a user