forked from qt-creator/qt-creator
Qbs: Pass related info directly to command line creation function
Saves a few casts and otherwise unneeded accessors. Change-Id: I7a6ff1e8348a24690f35e69d300463a6c5c18867 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -261,84 +261,7 @@ QString QbsBuildConfiguration::configurationName() const
|
|||||||
return m_configurationName->value();
|
return m_configurationName->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
class StepProxy
|
QString QbsBuildConfiguration::equivalentCommandLine(const QbsBuildStepData &stepData) const
|
||||||
{
|
|
||||||
public:
|
|
||||||
StepProxy(const BuildStep *buildStep)
|
|
||||||
: m_qbsBuildStep(qobject_cast<const QbsBuildStep *>(buildStep))
|
|
||||||
, m_qbsCleanStep(qobject_cast<const QbsCleanStep *>(buildStep))
|
|
||||||
, m_qbsInstallStep(qobject_cast<const QbsInstallStep *>(buildStep))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QString command() const {
|
|
||||||
if (m_qbsBuildStep)
|
|
||||||
return QLatin1String("build");
|
|
||||||
if (m_qbsInstallStep)
|
|
||||||
return QLatin1String("install");
|
|
||||||
return QLatin1String("clean");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dryRun() const {
|
|
||||||
if (m_qbsBuildStep)
|
|
||||||
return false;
|
|
||||||
if (m_qbsInstallStep)
|
|
||||||
return m_qbsInstallStep->dryRun();
|
|
||||||
return m_qbsCleanStep->dryRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool keepGoing() const {
|
|
||||||
if (m_qbsBuildStep)
|
|
||||||
return m_qbsBuildStep->keepGoing();
|
|
||||||
if (m_qbsInstallStep)
|
|
||||||
return m_qbsInstallStep->keepGoing();
|
|
||||||
return m_qbsCleanStep->keepGoing();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool forceProbeExecution() const { return m_qbsBuildStep && m_qbsBuildStep->forceProbes(); }
|
|
||||||
|
|
||||||
bool showCommandLines() const {
|
|
||||||
return m_qbsBuildStep ? m_qbsBuildStep->showCommandLines() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool noInstall() const {
|
|
||||||
return m_qbsBuildStep ? !m_qbsBuildStep->install() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool noBuild() const { return m_qbsInstallStep; }
|
|
||||||
|
|
||||||
bool cleanInstallRoot() const {
|
|
||||||
if (m_qbsBuildStep)
|
|
||||||
return m_qbsBuildStep->cleanInstallRoot();
|
|
||||||
if (m_qbsInstallStep)
|
|
||||||
return m_qbsInstallStep->removeFirst();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int jobCount() const {
|
|
||||||
return m_qbsBuildStep ? m_qbsBuildStep->maxJobs() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils::FilePath installRoot() const {
|
|
||||||
const QbsBuildStep *bs = nullptr;
|
|
||||||
if (m_qbsBuildStep) {
|
|
||||||
bs = m_qbsBuildStep;
|
|
||||||
} else if (m_qbsInstallStep) {
|
|
||||||
bs = static_cast<QbsBuildConfiguration *>(m_qbsInstallStep->deployConfiguration()
|
|
||||||
->target()->activeBuildConfiguration())->qbsStep();
|
|
||||||
}
|
|
||||||
if (bs)
|
|
||||||
return bs->installRoot();
|
|
||||||
return Utils::FilePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QbsBuildStep * const m_qbsBuildStep;
|
|
||||||
const QbsCleanStep * const m_qbsCleanStep;
|
|
||||||
const QbsInstallStep * const m_qbsInstallStep;
|
|
||||||
};
|
|
||||||
|
|
||||||
QString QbsBuildConfiguration::equivalentCommandLine(const BuildStep *buildStep) const
|
|
||||||
{
|
{
|
||||||
CommandLine commandLine;
|
CommandLine commandLine;
|
||||||
const QString qbsInstallDir = QString::fromLocal8Bit(qgetenv("QBS_INSTALL_DIR"));
|
const QString qbsInstallDir = QString::fromLocal8Bit(qgetenv("QBS_INSTALL_DIR"));
|
||||||
@@ -346,42 +269,41 @@ QString QbsBuildConfiguration::equivalentCommandLine(const BuildStep *buildStep)
|
|||||||
? qbsInstallDir + QLatin1String("/bin/qbs")
|
? qbsInstallDir + QLatin1String("/bin/qbs")
|
||||||
: QCoreApplication::applicationDirPath() + QLatin1String("/qbs"));
|
: QCoreApplication::applicationDirPath() + QLatin1String("/qbs"));
|
||||||
commandLine.addArg(QDir::toNativeSeparators(qbsFilePath));
|
commandLine.addArg(QDir::toNativeSeparators(qbsFilePath));
|
||||||
const StepProxy stepProxy(buildStep);
|
commandLine.addArg(stepData.command);
|
||||||
commandLine.addArg(stepProxy.command());
|
|
||||||
const QString buildDir = buildDirectory().toUserOutput();
|
const QString buildDir = buildDirectory().toUserOutput();
|
||||||
commandLine.addArgs({"-d", buildDir});
|
commandLine.addArgs({"-d", buildDir});
|
||||||
commandLine.addArgs({"-f", buildStep->project()->projectFilePath().toUserOutput()});
|
commandLine.addArgs({"-f", project()->projectFilePath().toUserOutput()});
|
||||||
if (QbsSettings::useCreatorSettingsDirForQbs()) {
|
if (QbsSettings::useCreatorSettingsDirForQbs()) {
|
||||||
commandLine.addArgs({"--settings-dir",
|
commandLine.addArgs({"--settings-dir",
|
||||||
QDir::toNativeSeparators(QbsSettings::qbsSettingsBaseDir())});
|
QDir::toNativeSeparators(QbsSettings::qbsSettingsBaseDir())});
|
||||||
}
|
}
|
||||||
if (stepProxy.dryRun())
|
if (stepData.dryRun)
|
||||||
commandLine.addArg("--dry-run");
|
commandLine.addArg("--dry-run");
|
||||||
if (stepProxy.keepGoing())
|
if (stepData.keepGoing)
|
||||||
commandLine.addArg("--keep-going");
|
commandLine.addArg("--keep-going");
|
||||||
if (stepProxy.forceProbeExecution())
|
if (stepData.forceProbeExecution)
|
||||||
commandLine.addArg("--force-probe-execution");
|
commandLine.addArg("--force-probe-execution");
|
||||||
if (stepProxy.showCommandLines())
|
if (stepData.showCommandLines)
|
||||||
commandLine.addArgs({"--command-echo-mode", "command-line"});
|
commandLine.addArgs({"--command-echo-mode", "command-line"});
|
||||||
if (stepProxy.noInstall())
|
if (stepData.noInstall)
|
||||||
commandLine.addArg("--no-install");
|
commandLine.addArg("--no-install");
|
||||||
if (stepProxy.noBuild())
|
if (stepData.noBuild)
|
||||||
commandLine.addArg("--no-build");
|
commandLine.addArg("--no-build");
|
||||||
if (stepProxy.cleanInstallRoot())
|
if (stepData.cleanInstallRoot)
|
||||||
commandLine.addArg("--clean-install-root");
|
commandLine.addArg("--clean-install-root");
|
||||||
const int jobCount = stepProxy.jobCount();
|
const int jobCount = stepData.jobCount;
|
||||||
if (jobCount > 0)
|
if (jobCount > 0)
|
||||||
commandLine.addArgs({"--jobs", QString::number(jobCount)});
|
commandLine.addArgs({"--jobs", QString::number(jobCount)});
|
||||||
|
|
||||||
const QString profileName = QbsProfileManager::profileNameForKit(buildStep->target()->kit());
|
const QString profileName = QbsProfileManager::profileNameForKit(target()->kit());
|
||||||
const QString buildVariant = qbsConfiguration()
|
const QString buildVariant = qbsConfiguration()
|
||||||
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
|
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
|
||||||
commandLine.addArg("config:" + configurationName());
|
commandLine.addArg("config:" + configurationName());
|
||||||
commandLine.addArg(QString(Constants::QBS_CONFIG_VARIANT_KEY) + ':' + buildVariant);
|
commandLine.addArg(QString(Constants::QBS_CONFIG_VARIANT_KEY) + ':' + buildVariant);
|
||||||
const FilePath installRoot = stepProxy.installRoot();
|
const FilePath installRoot = stepData.installRoot;
|
||||||
if (!installRoot.isEmpty()) {
|
if (!installRoot.isEmpty()) {
|
||||||
commandLine.addArg(QString(Constants::QBS_INSTALL_ROOT_KEY) + ':' + installRoot.toUserOutput());
|
commandLine.addArg(QString(Constants::QBS_INSTALL_ROOT_KEY) + ':' + installRoot.toUserOutput());
|
||||||
if (qobject_cast<const QbsInstallStep *>(buildStep))
|
if (stepData.isInstallStep)
|
||||||
commandLine.addArgs({"--installRoot", installRoot.toUserOutput()});
|
commandLine.addArgs({"--installRoot", installRoot.toUserOutput()});
|
||||||
}
|
}
|
||||||
commandLine.addArg("profile:" + profileName);
|
commandLine.addArg("profile:" + profileName);
|
||||||
|
@@ -40,7 +40,22 @@ namespace QbsProjectManager {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class QbsBuildStep;
|
class QbsBuildStep;
|
||||||
class QbsProject;
|
|
||||||
|
class QbsBuildStepData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString command;
|
||||||
|
bool dryRun = false;
|
||||||
|
bool keepGoing = false;
|
||||||
|
bool forceProbeExecution = false;
|
||||||
|
bool showCommandLines = false;
|
||||||
|
bool noInstall = false;
|
||||||
|
bool noBuild = false;
|
||||||
|
bool cleanInstallRoot = false;
|
||||||
|
bool isInstallStep = false;
|
||||||
|
int jobCount = 0;
|
||||||
|
Utils::FilePath installRoot;
|
||||||
|
};
|
||||||
|
|
||||||
class QbsBuildConfiguration final : public ProjectExplorer::BuildConfiguration
|
class QbsBuildConfiguration final : public ProjectExplorer::BuildConfiguration
|
||||||
{
|
{
|
||||||
@@ -73,7 +88,7 @@ public:
|
|||||||
QStringList products() const;
|
QStringList products() const;
|
||||||
|
|
||||||
QString configurationName() const;
|
QString configurationName() const;
|
||||||
QString equivalentCommandLine(const ProjectExplorer::BuildStep *buildStep) const;
|
QString equivalentCommandLine(const QbsBuildStepData &stepData) const;
|
||||||
|
|
||||||
bool isQmlDebuggingEnabled() const;
|
bool isQmlDebuggingEnabled() const;
|
||||||
ProjectExplorer::TriState qmlDebuggingSetting() const;
|
ProjectExplorer::TriState qmlDebuggingSetting() const;
|
||||||
|
@@ -523,6 +523,23 @@ void QbsBuildStep::finish()
|
|||||||
emit finished(m_lastWasSuccess);
|
emit finished(m_lastWasSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QbsBuildStepData QbsBuildStep::stepData() const
|
||||||
|
{
|
||||||
|
QbsBuildStepData data;
|
||||||
|
data.command = "build";
|
||||||
|
data.dryRun = false;
|
||||||
|
data.keepGoing = m_keepGoing;
|
||||||
|
data.forceProbeExecution = m_forceProbes;
|
||||||
|
data.showCommandLines = m_showCommandLines;
|
||||||
|
data.noInstall = !m_install;
|
||||||
|
data.noBuild = false;
|
||||||
|
data.cleanInstallRoot = m_cleanInstallDir;
|
||||||
|
data.jobCount = maxJobs();
|
||||||
|
data.installRoot = installRoot();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsBuildStepConfigWidget:
|
// QbsBuildStepConfigWidget:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -674,7 +691,8 @@ void QbsBuildStepConfigWidget::updateState()
|
|||||||
const int idx = (buildVariant == Constants::QBS_VARIANT_DEBUG) ? 0 : 1;
|
const int idx = (buildVariant == Constants::QBS_VARIANT_DEBUG) ? 0 : 1;
|
||||||
buildVariantComboBox->setCurrentIndex(idx);
|
buildVariantComboBox->setCurrentIndex(idx);
|
||||||
const auto qbsBuildConfig = static_cast<QbsBuildConfiguration *>(step()->buildConfiguration());
|
const auto qbsBuildConfig = static_cast<QbsBuildConfiguration *>(step()->buildConfiguration());
|
||||||
QString command = qbsBuildConfig->equivalentCommandLine(qbsStep());
|
|
||||||
|
QString command = qbsBuildConfig->equivalentCommandLine(qbsStep()->stepData());
|
||||||
|
|
||||||
for (int i = 0; i < m_propertyCache.count(); ++i) {
|
for (int i = 0; i < m_propertyCache.count(); ++i) {
|
||||||
command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue;
|
command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue;
|
||||||
|
@@ -70,6 +70,7 @@ public:
|
|||||||
bool forceProbes() const { return m_forceProbes; }
|
bool forceProbes() const { return m_forceProbes; }
|
||||||
|
|
||||||
QbsBuildSystem *qbsBuildSystem() const;
|
QbsBuildSystem *qbsBuildSystem() const;
|
||||||
|
QbsBuildStepData stepData() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void qbsConfigurationChanged();
|
void qbsConfigurationChanged();
|
||||||
|
@@ -67,8 +67,12 @@ QbsCleanStep::QbsCleanStep(BuildStepList *bsl, Core::Id id)
|
|||||||
effectiveCommandAspect->setLabelText(tr("Equivalent command line:"));
|
effectiveCommandAspect->setLabelText(tr("Equivalent command line:"));
|
||||||
|
|
||||||
setSummaryUpdater([this, effectiveCommandAspect] {
|
setSummaryUpdater([this, effectiveCommandAspect] {
|
||||||
|
QbsBuildStepData data;
|
||||||
|
data.command = "clean";
|
||||||
|
data.dryRun = m_dryRunAspect->value();
|
||||||
|
data.keepGoing = m_keepGoingAspect->value();
|
||||||
QString command = static_cast<QbsBuildConfiguration *>(buildConfiguration())
|
QString command = static_cast<QbsBuildConfiguration *>(buildConfiguration())
|
||||||
->equivalentCommandLine(this);
|
->equivalentCommandLine(data);
|
||||||
effectiveCommandAspect->setValue(command);
|
effectiveCommandAspect->setValue(command);
|
||||||
return tr("<b>Qbs:</b> %1").arg(command);
|
return tr("<b>Qbs:</b> %1").arg(command);
|
||||||
});
|
});
|
||||||
|
@@ -44,8 +44,7 @@ public:
|
|||||||
QbsCleanStep(ProjectExplorer::BuildStepList *bsl, Core::Id id);
|
QbsCleanStep(ProjectExplorer::BuildStepList *bsl, Core::Id id);
|
||||||
~QbsCleanStep() override;
|
~QbsCleanStep() override;
|
||||||
|
|
||||||
bool dryRun() const { return m_dryRunAspect->value(); }
|
QbsBuildStepData stepData() const;
|
||||||
bool keepGoing() const { return m_keepGoingAspect->value(); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init() override;
|
bool init() override;
|
||||||
|
@@ -231,6 +231,21 @@ void QbsInstallStep::setKeepGoing(bool kg)
|
|||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QbsBuildStepData QbsInstallStep::stepData() const
|
||||||
|
{
|
||||||
|
QbsBuildStepData data;
|
||||||
|
data.command = "install";
|
||||||
|
data.dryRun = dryRun();
|
||||||
|
data.keepGoing = keepGoing();
|
||||||
|
data.noBuild = true;
|
||||||
|
data.cleanInstallRoot = removeFirst();
|
||||||
|
data.isInstallStep = true;
|
||||||
|
auto bs = static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration())->qbsStep();
|
||||||
|
if (bs)
|
||||||
|
data.installRoot = bs->installRoot();
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsInstallStepConfigWidget:
|
// QbsInstallStepConfigWidget:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -320,7 +335,7 @@ void QbsInstallStepConfigWidget::updateState()
|
|||||||
m_keepGoingCheckBox->setChecked(m_step->keepGoing());
|
m_keepGoingCheckBox->setChecked(m_step->keepGoing());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString command = m_step->buildConfig()->equivalentCommandLine(m_step);
|
QString command = m_step->buildConfig()->equivalentCommandLine(m_step->stepData());
|
||||||
|
|
||||||
m_commandLineTextEdit->setPlainText(command);
|
m_commandLineTextEdit->setPlainText(command);
|
||||||
|
|
||||||
|
@@ -48,6 +48,7 @@ public:
|
|||||||
bool removeFirst() const { return m_cleanInstallRoot; }
|
bool removeFirst() const { return m_cleanInstallRoot; }
|
||||||
bool dryRun() const { return m_dryRun; }
|
bool dryRun() const { return m_dryRun; }
|
||||||
bool keepGoing() const { return m_keepGoing; }
|
bool keepGoing() const { return m_keepGoing; }
|
||||||
|
QbsBuildStepData stepData() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
Reference in New Issue
Block a user