Commit 7ffdcd10 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QbsProjectManager: Make the configuration name explicit



This is a prerequisite for being able to import builds.

Change-Id: I22bd8f201db943335edadc899bfe9fa64d39e845
Reviewed-by: Joerg Bornemann's avatarJoerg Bornemann <joerg.bornemann@qt.io>
parent 3fb25b28
......@@ -56,6 +56,8 @@ using namespace ProjectExplorer;
namespace QbsProjectManager {
namespace Internal {
static QString configNameKey() { return "Qbs.configName"; }
const char QBS_BC_ID[] = "Qbs.QbsBuildConfiguration";
// ---------------------------------------------------------------------------
......@@ -81,6 +83,7 @@ QbsBuildConfiguration::QbsBuildConfiguration(Target *target, Core::Id id) :
QbsBuildConfiguration::QbsBuildConfiguration(Target *target, QbsBuildConfiguration *source) :
BuildConfiguration(target, source)
{
m_configurationName = source->configurationName();
cloneSteps(source);
}
......@@ -89,6 +92,13 @@ bool QbsBuildConfiguration::fromMap(const QVariantMap &map)
if (!BuildConfiguration::fromMap(map))
return false;
m_configurationName = map.value(configNameKey()).toString();
if (m_configurationName.isEmpty()) { // pre-4.4 backwards compatibility
const QString profileName = QbsManager::instance()->profileForKit(target()->kit());
const QString buildVariant = qbsConfiguration()
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
m_configurationName = profileName + QLatin1Char('-') + buildVariant;
}
BuildStepList *bsl = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
// Fix up the existing build steps:
for (int i = 0; i < bsl->count(); ++i) {
......@@ -100,6 +110,13 @@ bool QbsBuildConfiguration::fromMap(const QVariantMap &map)
return true;
}
QVariantMap QbsBuildConfiguration::toMap() const
{
QVariantMap map = BuildConfiguration::toMap();
map.insert(configNameKey(), m_configurationName);
return map;
}
void QbsBuildConfiguration::buildStepInserted(int pos)
{
QbsBuildStep *step = qobject_cast<QbsBuildStep *>(stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD)->at(pos));
......@@ -201,12 +218,17 @@ void QbsBuildConfiguration::emitBuildTypeChanged()
emit buildTypeChanged();
}
void QbsBuildConfiguration::setConfigurationName(const QString &configName)
{
if (m_configurationName == configName)
return;
m_configurationName = configName;
emit buildDirectoryChanged();
}
QString QbsBuildConfiguration::configurationName() const
{
const QString profileName = QbsManager::instance()->profileForKit(target()->kit());
const QString buildVariant = qbsConfiguration()
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
return profileName + QLatin1Char('-') + buildVariant;
return m_configurationName;
}
class StepProxy
......@@ -351,10 +373,17 @@ QbsBuildConfiguration *QbsBuildConfiguration::setup(Target *t,
bc->setDefaultDisplayName(defaultDisplayName);
bc->setDisplayName(displayName);
bc->setBuildDirectory(directory);
QVariantMap bd = buildData;
QString configName = bd.take("configName").toString();
if (configName.isEmpty()) {
configName = "qtc_" + t->kit()->fileSystemFriendlyName() + QLatin1Char('_')
+ Utils::FileUtils::fileSystemFriendlyName(displayName);
}
bc->setConfigurationName(configName);
BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
QbsBuildStep *bs = new QbsBuildStep(buildSteps);
bs->setQbsConfiguration(buildData);
bs->setQbsConfiguration(bd);
buildSteps->insertStep(0, bs);
BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN);
......
......@@ -76,6 +76,7 @@ public:
void emitBuildTypeChanged();
void setConfigurationName(const QString &configName);
QString configurationName() const;
QString equivalentCommandLine(const ProjectExplorer::BuildStep *buildStep) const;
......@@ -87,6 +88,7 @@ protected:
QbsBuildConfiguration(ProjectExplorer::Target *target, QbsBuildConfiguration *source);
QbsBuildConfiguration(ProjectExplorer::Target *target, Core::Id id);
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
private:
void buildStepInserted(int pos);
......@@ -102,6 +104,7 @@ private:
QStringList m_changedFiles;
QStringList m_activeFileTags;
QStringList m_products;
QString m_configurationName;
friend class QbsBuildConfigurationFactory;
friend class QbsBuildConfigurationWidget;
......
......@@ -34,6 +34,7 @@
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QWidget>
namespace QbsProjectManager {
......@@ -59,16 +60,22 @@ QbsBuildConfigurationWidget::QbsBuildConfigurationWidget(QbsProjectManager::Inte
QGridLayout *layout = new QGridLayout(details);
layout->setMargin(0);
layout->addWidget(new QLabel(tr("Build directory:"), 0, 0));
layout->addWidget(new QLabel(tr("Build directory:")), 0, 0);
m_buildDirChooser = new Utils::PathChooser;
m_buildDirChooser->setExpectedKind(Utils::PathChooser::Directory);
m_buildDirChooser->setBaseFileName(bc->target()->project()->projectDirectory());
m_buildDirChooser->setEnvironment(bc->environment());
layout->addWidget(m_buildDirChooser, 0, 1);
layout->addWidget(new QLabel(tr("Configuration name:")), 1, 0);
m_configNameEdit = new QLineEdit;
m_configNameEdit->setText(m_buildConfiguration->configurationName());
layout->addWidget(m_configNameEdit, 1, 1);
connect(m_buildDirChooser, &Utils::PathChooser::rawPathChanged,
this, &QbsBuildConfigurationWidget::buildDirEdited);
connect(m_configNameEdit, &QLineEdit::textEdited,
this, &QbsBuildConfigurationWidget::configNameEdited);
buildDirectoryChanged();
}
......@@ -79,6 +86,12 @@ void QbsBuildConfigurationWidget::buildDirEdited()
m_buildConfiguration->setBuildDirectory(m_buildDirChooser->fileName());
}
void QbsBuildConfigurationWidget::configNameEdited()
{
m_ignoreChange = true;
m_buildConfiguration->setConfigurationName(m_configNameEdit->text());
}
void QbsBuildConfigurationWidget::buildDirectoryChanged()
{
if (m_ignoreChange)
......
......@@ -32,6 +32,10 @@ class DetailsWidget;
class PathChooser;
} // namespace Utils
QT_BEGIN_NAMESPACE
class QLineEdit;
QT_END_NAMESPACE
namespace QbsProjectManager {
namespace Internal {
class QbsBuildConfiguration;
......@@ -45,6 +49,7 @@ public:
private:
void buildDirEdited();
void configNameEdited();
// Changes triggered from creator
void buildDirectoryChanged();
......@@ -53,6 +58,7 @@ private:
private:
Internal::QbsBuildConfiguration *m_buildConfiguration;
Utils::PathChooser *m_buildDirChooser;
QLineEdit *m_configNameEdit;
bool m_ignoreChange;
};
......
......@@ -606,7 +606,8 @@ void QbsProject::parseCurrentBuildConfiguration()
return;
}
parse(bc->qbsConfiguration(), bc->environment(), bc->buildDirectory().toString());
parse(bc->qbsConfiguration(), bc->environment(), bc->buildDirectory().toString(),
bc->configurationName());
}
void QbsProject::cancelParsing()
......@@ -690,7 +691,8 @@ QString QbsProject::uniqueProductName(const qbs::ProductData &product)
return product.name() + QLatin1Char('.') + product.profile();
}
void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir)
void QbsProject::parse(const QVariantMap &config, const Environment &env, const QString &dir,
const QString &configName)
{
prepareForParsing();
QTC_ASSERT(!m_qbsProjectParser, return);
......@@ -698,7 +700,7 @@ void QbsProject::parse(const QVariantMap &config, const Environment &env, const
registerQbsProjectParser(new QbsProjectParser(this, m_qbsUpdateFutureInterface));
QbsManager::instance()->updateProfileIfNecessary(activeTarget()->kit());
m_qbsProjectParser->parse(config, env, dir);
m_qbsProjectParser->parse(config, env, dir, configName);
emit projectParsingStarted();
}
......
......@@ -124,7 +124,8 @@ private:
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
void parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir);
void parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir,
const QString &configName);
void prepareForParsing();
void updateDocuments(const QSet<QString> &files);
......
......@@ -74,7 +74,8 @@ QbsProjectParser::~QbsProjectParser()
m_fi = 0; // we do not own m_fi, do not delete
}
void QbsProjectParser::parse(const QVariantMap &config, const Environment &env, const QString &dir)
void QbsProjectParser::parse(const QVariantMap &config, const Environment &env, const QString &dir,
const QString &configName)
{
QTC_ASSERT(!m_qbsSetupProjectJob, return);
QTC_ASSERT(!dir.isEmpty(), return);
......@@ -86,9 +87,7 @@ void QbsProjectParser::parse(const QVariantMap &config, const Environment &env,
QString specialKey = QLatin1String(Constants::QBS_CONFIG_PROFILE_KEY);
const QString profileName = userConfig.take(specialKey).toString();
params.setTopLevelProfile(profileName);
const QString buildVariantKey = QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY);
const QString buildVariant = userConfig.value(buildVariantKey).toString();
params.setConfigurationName(profileName + QLatin1Char('-') + buildVariant);
params.setConfigurationName(configName);
specialKey = QLatin1String(Constants::QBS_FORCE_PROBES_KEY);
params.setForceProbeExecution(userConfig.take(specialKey).toBool());
params.setSettingsDirectory(QbsManager::settings()->baseDirectory());
......
......@@ -46,7 +46,8 @@ public:
QFutureInterface<bool> *fi);
~QbsProjectParser();
void parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir);
void parse(const QVariantMap &config, const Utils::Environment &env, const QString &dir,
const QString &configName);
void startRuleExecution();
void cancel();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment