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();
|
||||
}
|
||||
|
||||
class StepProxy
|
||||
{
|
||||
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
|
||||
QString QbsBuildConfiguration::equivalentCommandLine(const QbsBuildStepData &stepData) const
|
||||
{
|
||||
CommandLine commandLine;
|
||||
const QString qbsInstallDir = QString::fromLocal8Bit(qgetenv("QBS_INSTALL_DIR"));
|
||||
@@ -346,42 +269,41 @@ QString QbsBuildConfiguration::equivalentCommandLine(const BuildStep *buildStep)
|
||||
? qbsInstallDir + QLatin1String("/bin/qbs")
|
||||
: QCoreApplication::applicationDirPath() + QLatin1String("/qbs"));
|
||||
commandLine.addArg(QDir::toNativeSeparators(qbsFilePath));
|
||||
const StepProxy stepProxy(buildStep);
|
||||
commandLine.addArg(stepProxy.command());
|
||||
commandLine.addArg(stepData.command);
|
||||
const QString buildDir = buildDirectory().toUserOutput();
|
||||
commandLine.addArgs({"-d", buildDir});
|
||||
commandLine.addArgs({"-f", buildStep->project()->projectFilePath().toUserOutput()});
|
||||
commandLine.addArgs({"-f", project()->projectFilePath().toUserOutput()});
|
||||
if (QbsSettings::useCreatorSettingsDirForQbs()) {
|
||||
commandLine.addArgs({"--settings-dir",
|
||||
QDir::toNativeSeparators(QbsSettings::qbsSettingsBaseDir())});
|
||||
}
|
||||
if (stepProxy.dryRun())
|
||||
if (stepData.dryRun)
|
||||
commandLine.addArg("--dry-run");
|
||||
if (stepProxy.keepGoing())
|
||||
if (stepData.keepGoing)
|
||||
commandLine.addArg("--keep-going");
|
||||
if (stepProxy.forceProbeExecution())
|
||||
if (stepData.forceProbeExecution)
|
||||
commandLine.addArg("--force-probe-execution");
|
||||
if (stepProxy.showCommandLines())
|
||||
if (stepData.showCommandLines)
|
||||
commandLine.addArgs({"--command-echo-mode", "command-line"});
|
||||
if (stepProxy.noInstall())
|
||||
if (stepData.noInstall)
|
||||
commandLine.addArg("--no-install");
|
||||
if (stepProxy.noBuild())
|
||||
if (stepData.noBuild)
|
||||
commandLine.addArg("--no-build");
|
||||
if (stepProxy.cleanInstallRoot())
|
||||
if (stepData.cleanInstallRoot)
|
||||
commandLine.addArg("--clean-install-root");
|
||||
const int jobCount = stepProxy.jobCount();
|
||||
const int jobCount = stepData.jobCount;
|
||||
if (jobCount > 0)
|
||||
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()
|
||||
.value(QLatin1String(Constants::QBS_CONFIG_VARIANT_KEY)).toString();
|
||||
commandLine.addArg("config:" + configurationName());
|
||||
commandLine.addArg(QString(Constants::QBS_CONFIG_VARIANT_KEY) + ':' + buildVariant);
|
||||
const FilePath installRoot = stepProxy.installRoot();
|
||||
const FilePath installRoot = stepData.installRoot;
|
||||
if (!installRoot.isEmpty()) {
|
||||
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.addArg("profile:" + profileName);
|
||||
|
@@ -40,7 +40,22 @@ namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
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
|
||||
{
|
||||
@@ -73,7 +88,7 @@ public:
|
||||
QStringList products() const;
|
||||
|
||||
QString configurationName() const;
|
||||
QString equivalentCommandLine(const ProjectExplorer::BuildStep *buildStep) const;
|
||||
QString equivalentCommandLine(const QbsBuildStepData &stepData) const;
|
||||
|
||||
bool isQmlDebuggingEnabled() const;
|
||||
ProjectExplorer::TriState qmlDebuggingSetting() const;
|
||||
|
@@ -523,6 +523,23 @@ void QbsBuildStep::finish()
|
||||
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:
|
||||
// --------------------------------------------------------------------
|
||||
@@ -674,7 +691,8 @@ void QbsBuildStepConfigWidget::updateState()
|
||||
const int idx = (buildVariant == Constants::QBS_VARIANT_DEBUG) ? 0 : 1;
|
||||
buildVariantComboBox->setCurrentIndex(idx);
|
||||
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) {
|
||||
command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue;
|
||||
|
@@ -70,6 +70,7 @@ public:
|
||||
bool forceProbes() const { return m_forceProbes; }
|
||||
|
||||
QbsBuildSystem *qbsBuildSystem() const;
|
||||
QbsBuildStepData stepData() const;
|
||||
|
||||
signals:
|
||||
void qbsConfigurationChanged();
|
||||
|
@@ -67,8 +67,12 @@ QbsCleanStep::QbsCleanStep(BuildStepList *bsl, Core::Id id)
|
||||
effectiveCommandAspect->setLabelText(tr("Equivalent command line:"));
|
||||
|
||||
setSummaryUpdater([this, effectiveCommandAspect] {
|
||||
QbsBuildStepData data;
|
||||
data.command = "clean";
|
||||
data.dryRun = m_dryRunAspect->value();
|
||||
data.keepGoing = m_keepGoingAspect->value();
|
||||
QString command = static_cast<QbsBuildConfiguration *>(buildConfiguration())
|
||||
->equivalentCommandLine(this);
|
||||
->equivalentCommandLine(data);
|
||||
effectiveCommandAspect->setValue(command);
|
||||
return tr("<b>Qbs:</b> %1").arg(command);
|
||||
});
|
||||
|
@@ -44,8 +44,7 @@ public:
|
||||
QbsCleanStep(ProjectExplorer::BuildStepList *bsl, Core::Id id);
|
||||
~QbsCleanStep() override;
|
||||
|
||||
bool dryRun() const { return m_dryRunAspect->value(); }
|
||||
bool keepGoing() const { return m_keepGoingAspect->value(); }
|
||||
QbsBuildStepData stepData() const;
|
||||
|
||||
private:
|
||||
bool init() override;
|
||||
|
@@ -231,6 +231,21 @@ void QbsInstallStep::setKeepGoing(bool kg)
|
||||
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:
|
||||
// --------------------------------------------------------------------
|
||||
@@ -320,7 +335,7 @@ void QbsInstallStepConfigWidget::updateState()
|
||||
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);
|
||||
|
||||
|
@@ -48,6 +48,7 @@ public:
|
||||
bool removeFirst() const { return m_cleanInstallRoot; }
|
||||
bool dryRun() const { return m_dryRun; }
|
||||
bool keepGoing() const { return m_keepGoing; }
|
||||
QbsBuildStepData stepData() const;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
Reference in New Issue
Block a user