2013-01-30 18:19:31 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-01-30 18:19:31 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildstep.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildconfiguration.h"
|
|
|
|
|
#include "qbsproject.h"
|
|
|
|
|
#include "qbsprojectmanagerconstants.h"
|
2019-06-28 14:30:32 +02:00
|
|
|
#include "qbssession.h"
|
|
|
|
|
#include "qbssettings.h"
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-03-03 17:32:40 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2020-11-06 15:11:12 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/kit.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2020-11-06 15:11:12 +01:00
|
|
|
|
2013-06-13 17:15:44 +02:00
|
|
|
#include <qtsupport/qtversionmanager.h>
|
2020-11-06 15:11:12 +01:00
|
|
|
|
|
|
|
|
#include <utils/aspects.h>
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
2016-09-20 17:11:03 +03:00
|
|
|
#include <utils/macroexpander.h>
|
2020-04-16 13:53:05 +02:00
|
|
|
#include <utils/outputformatter.h>
|
2019-06-27 12:10:04 +02:00
|
|
|
#include <utils/pathchooser.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2013-06-12 14:36:02 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/variablechooser.h>
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
#include <QBoxLayout>
|
|
|
|
|
#include <QCheckBox>
|
2019-06-28 14:30:32 +02:00
|
|
|
#include <QJsonArray>
|
|
|
|
|
#include <QJsonObject>
|
2019-06-27 12:10:04 +02:00
|
|
|
#include <QLabel>
|
2019-06-28 14:30:32 +02:00
|
|
|
#include <QThread>
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Constants:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
const char QBS_CONFIG[] = "Qbs.Configuration";
|
|
|
|
|
const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
|
|
|
|
|
const char QBS_MAXJOBCOUNT[] = "Qbs.MaxJobs";
|
|
|
|
|
const char QBS_SHOWCOMMANDLINES[] = "Qbs.ShowCommandLines";
|
|
|
|
|
const char QBS_INSTALL[] = "Qbs.Install";
|
|
|
|
|
const char QBS_CLEAN_INSTALL_ROOT[] = "Qbs.CleanInstallRoot";
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2020-10-02 17:53:39 +02:00
|
|
|
class QbsBuildStepConfigWidget : public QWidget
|
2016-10-23 05:52:51 +03:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
QbsBuildStepConfigWidget(QbsBuildStep *step);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void updateState();
|
|
|
|
|
void updatePropertyEdit(const QVariantMap &data);
|
|
|
|
|
|
2017-02-13 15:40:59 +01:00
|
|
|
void changeUseDefaultInstallDir(bool useDefault);
|
|
|
|
|
void changeInstallDir(const QString &dir);
|
2016-10-23 05:52:51 +03:00
|
|
|
void applyCachedProperties();
|
|
|
|
|
|
2018-10-12 18:38:22 +02:00
|
|
|
QbsBuildStep *qbsStep() const;
|
|
|
|
|
|
2016-10-23 05:52:51 +03:00
|
|
|
bool validateProperties(Utils::FancyLineEdit *edit, QString *errorMessage);
|
|
|
|
|
|
2016-10-23 06:01:41 +03:00
|
|
|
class Property
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Property() = default;
|
|
|
|
|
Property(const QString &n, const QString &v, const QString &e) :
|
|
|
|
|
name(n), value(v), effectiveValue(e)
|
|
|
|
|
{}
|
|
|
|
|
bool operator==(const Property &other) const
|
|
|
|
|
{
|
|
|
|
|
return name == other.name
|
|
|
|
|
&& value == other.value
|
|
|
|
|
&& effectiveValue == other.effectiveValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString name;
|
|
|
|
|
QString value;
|
|
|
|
|
QString effectiveValue;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-11 13:39:11 +02:00
|
|
|
QbsBuildStep *m_qbsStep;
|
2016-10-23 06:01:41 +03:00
|
|
|
QList<Property> m_propertyCache;
|
2019-06-27 12:10:04 +02:00
|
|
|
bool m_ignoreChange = false;
|
|
|
|
|
|
|
|
|
|
FancyLineEdit *propertyEdit;
|
|
|
|
|
PathChooser *installDirChooser;
|
|
|
|
|
QCheckBox *defaultInstallDirCheckBox;
|
2016-10-23 05:52:51 +03:00
|
|
|
};
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsBuildStep:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2020-08-25 12:07:49 +02:00
|
|
|
QbsBuildStep::QbsBuildStep(BuildStepList *bsl, Utils::Id id) :
|
2019-12-20 17:05:30 +01:00
|
|
|
BuildStep(bsl, id)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2013-04-12 16:19:22 +02:00
|
|
|
setDisplayName(tr("Qbs Build"));
|
2020-09-14 12:37:32 +02:00
|
|
|
setSummaryText(tr("<b>Qbs:</b> %1").arg("build"));
|
|
|
|
|
|
2013-05-27 11:36:44 +02:00
|
|
|
setQbsConfiguration(QVariantMap());
|
2018-10-22 19:11:59 +02:00
|
|
|
|
2019-04-30 11:06:49 +02:00
|
|
|
auto qbsBuildConfig = qobject_cast<QbsBuildConfiguration *>(buildConfiguration());
|
|
|
|
|
QTC_CHECK(qbsBuildConfig);
|
|
|
|
|
connect(this, &QbsBuildStep::qbsConfigurationChanged,
|
|
|
|
|
qbsBuildConfig, &QbsBuildConfiguration::qbsConfigurationChanged);
|
|
|
|
|
|
2020-11-09 16:19:23 +01:00
|
|
|
m_buildVariant = addAspect<SelectionAspect>();
|
|
|
|
|
m_buildVariant->setDisplayName(tr("Build variant:"));
|
|
|
|
|
m_buildVariant->setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
|
|
|
|
m_buildVariant->addOption(tr("Debug"));
|
|
|
|
|
m_buildVariant->addOption(tr("Release"));
|
2020-11-06 15:11:12 +01:00
|
|
|
|
|
|
|
|
m_keepGoing = addAspect<BoolAspect>();
|
|
|
|
|
m_keepGoing->setSettingsKey(QBS_KEEP_GOING);
|
|
|
|
|
m_keepGoing->setToolTip(tr("Keep going when errors occur (if at all possible)."));
|
|
|
|
|
m_keepGoing->setLabel(tr("Keep going"),
|
|
|
|
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
|
|
|
|
|
m_maxJobCount = addAspect<IntegerAspect>();
|
|
|
|
|
m_maxJobCount->setSettingsKey(QBS_MAXJOBCOUNT);
|
|
|
|
|
m_maxJobCount->setLabel(tr("Parallel jobs:"));
|
|
|
|
|
m_maxJobCount->setToolTip(tr("Number of concurrent build jobs."));
|
|
|
|
|
m_maxJobCount->setValue(QThread::idealThreadCount());
|
|
|
|
|
|
|
|
|
|
m_showCommandLines = addAspect<BoolAspect>();
|
|
|
|
|
m_showCommandLines->setSettingsKey(QBS_SHOWCOMMANDLINES);
|
|
|
|
|
m_showCommandLines->setLabel(tr("Show command lines"),
|
|
|
|
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
|
|
|
|
|
m_install = addAspect<BoolAspect>();
|
|
|
|
|
m_install->setSettingsKey(QBS_INSTALL);
|
|
|
|
|
m_install->setValue(true);
|
|
|
|
|
m_install->setLabel(tr("Install"), BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
|
|
|
|
|
m_cleanInstallDir = addAspect<BoolAspect>();
|
|
|
|
|
m_cleanInstallDir->setSettingsKey(QBS_CLEAN_INSTALL_ROOT);
|
|
|
|
|
m_cleanInstallDir->setLabel(tr("Clean install root"),
|
|
|
|
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
|
|
|
|
|
m_forceProbes = addAspect<BoolAspect>();
|
|
|
|
|
m_forceProbes->setSettingsKey("Qbs.forceProbesKey");
|
|
|
|
|
m_forceProbes->setLabel(tr("Force probes"),
|
|
|
|
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
|
2020-11-16 10:00:38 +01:00
|
|
|
m_commandLine = addAspect<StringAspect>();
|
|
|
|
|
m_commandLine->setDisplayStyle(StringAspect::TextEditDisplay);
|
|
|
|
|
m_commandLine->setLabelText(tr("Equivalent command line:"));
|
|
|
|
|
m_commandLine->setUndoRedoEnabled(false);
|
|
|
|
|
m_commandLine->setReadOnly(true);
|
|
|
|
|
|
2020-11-06 15:11:12 +01:00
|
|
|
connect(m_maxJobCount, &BaseAspect::changed, this, &QbsBuildStep::updateState);
|
|
|
|
|
connect(m_keepGoing, &BaseAspect::changed, this, &QbsBuildStep::updateState);
|
|
|
|
|
connect(m_showCommandLines, &BaseAspect::changed, this, &QbsBuildStep::updateState);
|
|
|
|
|
connect(m_install, &BaseAspect::changed, this, &QbsBuildStep::updateState);
|
|
|
|
|
connect(m_cleanInstallDir, &BaseAspect::changed, this, &QbsBuildStep::updateState);
|
|
|
|
|
connect(m_forceProbes, &BaseAspect::changed, this, &QbsBuildStep::updateState);
|
2020-11-09 16:19:23 +01:00
|
|
|
|
|
|
|
|
connect(m_buildVariant, &SelectionAspect::changed, this, &QbsBuildStep::changeBuildVariant);
|
2013-06-13 17:53:02 +02:00
|
|
|
}
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
QbsBuildStep::~QbsBuildStep()
|
|
|
|
|
{
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
doCancel();
|
2019-06-28 14:30:32 +02:00
|
|
|
if (m_session)
|
|
|
|
|
m_session->disconnect(this);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool QbsBuildStep::init()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2020-12-03 15:17:23 +01:00
|
|
|
if (m_session)
|
2013-01-30 18:19:31 +01:00
|
|
|
return false;
|
|
|
|
|
|
2018-07-27 12:10:20 +02:00
|
|
|
auto bc = static_cast<QbsBuildConfiguration *>(buildConfiguration());
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
if (!bc)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
m_changedFiles = bc->changedFiles();
|
2013-07-24 16:47:02 +02:00
|
|
|
m_activeFileTags = bc->activeFileTags();
|
2013-06-10 15:40:18 +02:00
|
|
|
m_products = bc->products();
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
void QbsBuildStep::setupOutputFormatter(OutputFormatter *formatter)
|
|
|
|
|
{
|
|
|
|
|
formatter->addLineParsers(target()->kit()->createOutputParsers());
|
|
|
|
|
BuildStep::setupOutputFormatter(formatter);
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void QbsBuildStep::doRun()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-07-14 14:22:27 +02:00
|
|
|
// We need a pre-build parsing step in order not to lose project file changes done
|
|
|
|
|
// right before building (but before the delay has elapsed).
|
2019-06-28 14:30:32 +02:00
|
|
|
m_parsingAfterBuild = false;
|
2014-07-14 14:22:27 +02:00
|
|
|
parseProject();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2020-10-02 17:53:39 +02:00
|
|
|
QWidget *QbsBuildStep::createConfigWidget()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
|
|
|
|
return new QbsBuildStepConfigWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void QbsBuildStep::doCancel()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2014-07-14 14:22:27 +02:00
|
|
|
if (m_parsingProject)
|
2019-10-25 09:55:32 +02:00
|
|
|
qbsBuildSystem()->cancelParsing();
|
2019-06-28 14:30:32 +02:00
|
|
|
else if (m_session)
|
|
|
|
|
m_session->cancelCurrentJob();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-10-23 06:01:41 +03:00
|
|
|
QVariantMap QbsBuildStep::qbsConfiguration(VariableHandling variableHandling) const
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2016-06-17 17:22:30 +02:00
|
|
|
QVariantMap config = m_qbsConfiguration;
|
2019-11-25 15:07:21 +01:00
|
|
|
const auto qbsBuildConfig = static_cast<QbsBuildConfiguration *>(buildConfiguration());
|
2020-11-06 15:11:12 +01:00
|
|
|
config.insert(Constants::QBS_FORCE_PROBES_KEY, m_forceProbes->value());
|
2019-11-15 16:20:33 +01:00
|
|
|
|
|
|
|
|
const auto store = [&config](TriState ts, const QString &key) {
|
|
|
|
|
if (ts == TriState::Enabled)
|
|
|
|
|
config.insert(key, true);
|
|
|
|
|
else if (ts == TriState::Disabled)
|
|
|
|
|
config.insert(key, false);
|
|
|
|
|
else
|
|
|
|
|
config.remove(key);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
store(qbsBuildConfig->separateDebugInfoSetting(),
|
|
|
|
|
Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY);
|
|
|
|
|
|
|
|
|
|
store(qbsBuildConfig->qmlDebuggingSetting(),
|
|
|
|
|
Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
|
|
|
|
|
|
|
|
|
|
store(qbsBuildConfig->qtQuickCompilerSetting(),
|
|
|
|
|
Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
|
|
|
|
|
|
2016-10-23 06:01:41 +03:00
|
|
|
if (variableHandling == ExpandVariables) {
|
2020-02-19 11:55:48 +01:00
|
|
|
const MacroExpander * const expander = macroExpander();
|
2016-11-08 14:15:24 +01:00
|
|
|
for (auto it = config.begin(), end = config.end(); it != end; ++it) {
|
|
|
|
|
const QString rawString = it.value().toString();
|
|
|
|
|
const QString expandedString = expander->expand(rawString);
|
2019-06-28 14:30:32 +02:00
|
|
|
it.value() = expandedString;
|
2016-11-08 14:15:24 +01:00
|
|
|
}
|
2016-10-23 06:01:41 +03:00
|
|
|
}
|
2016-06-17 17:22:30 +02:00
|
|
|
return config;
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStep::setQbsConfiguration(const QVariantMap &config)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap tmp = config;
|
2019-10-25 09:55:32 +02:00
|
|
|
tmp.insert(Constants::QBS_CONFIG_PROFILE_KEY, qbsBuildSystem()->profile());
|
2017-07-27 23:27:25 +03:00
|
|
|
if (!tmp.contains(Constants::QBS_CONFIG_VARIANT_KEY))
|
|
|
|
|
tmp.insert(Constants::QBS_CONFIG_VARIANT_KEY,
|
2013-01-30 18:19:31 +01:00
|
|
|
QString::fromLatin1(Constants::QBS_VARIANT_DEBUG));
|
|
|
|
|
|
|
|
|
|
if (tmp == m_qbsConfiguration)
|
|
|
|
|
return;
|
|
|
|
|
m_qbsConfiguration = tmp;
|
2019-05-02 12:05:13 +02:00
|
|
|
if (ProjectExplorer::BuildConfiguration *bc = buildConfiguration())
|
|
|
|
|
emit bc->buildTypeChanged();
|
2013-01-30 18:19:31 +01:00
|
|
|
emit qbsConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-13 15:40:59 +01:00
|
|
|
bool QbsBuildStep::hasCustomInstallRoot() const
|
|
|
|
|
{
|
2017-07-27 23:27:25 +03:00
|
|
|
return m_qbsConfiguration.contains(Constants::QBS_INSTALL_ROOT_KEY);
|
2017-02-13 15:40:59 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath QbsBuildStep::installRoot(VariableHandling variableHandling) const
|
2017-02-13 15:40:59 +01:00
|
|
|
{
|
2019-05-10 11:37:22 +02:00
|
|
|
const QString root =
|
|
|
|
|
qbsConfiguration(variableHandling).value(Constants::QBS_INSTALL_ROOT_KEY).toString();
|
|
|
|
|
if (!root.isNull())
|
2019-05-28 13:49:26 +02:00
|
|
|
return Utils::FilePath::fromString(root);
|
2019-11-21 17:07:11 +01:00
|
|
|
QString defaultInstallDir = QbsSettings::defaultInstallDirTemplate();
|
|
|
|
|
if (variableHandling == VariableHandling::ExpandVariables)
|
2020-02-19 11:55:48 +01:00
|
|
|
defaultInstallDir = macroExpander()->expand(defaultInstallDir);
|
2019-11-21 17:07:11 +01:00
|
|
|
return FilePath::fromString(defaultInstallDir);
|
2017-02-13 15:40:59 +01:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
int QbsBuildStep::maxJobs() const
|
|
|
|
|
{
|
2020-11-06 15:11:12 +01:00
|
|
|
if (m_maxJobCount->value() > 0)
|
|
|
|
|
return m_maxJobCount->value();
|
2019-06-28 14:30:32 +02:00
|
|
|
return QThread::idealThreadCount();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsBuildStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!ProjectExplorer::BuildStep::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2017-07-27 23:27:25 +03:00
|
|
|
setQbsConfiguration(map.value(QBS_CONFIG).toMap());
|
2013-01-30 18:19:31 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap QbsBuildStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = ProjectExplorer::BuildStep::toMap();
|
2017-07-27 23:27:25 +03:00
|
|
|
map.insert(QBS_CONFIG, m_qbsConfiguration);
|
2013-01-30 18:19:31 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
void QbsBuildStep::buildingDone(const ErrorInfo &error)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
m_session->disconnect(this);
|
|
|
|
|
m_session = nullptr;
|
|
|
|
|
m_lastWasSuccess = !error.hasError();
|
|
|
|
|
for (const ErrorInfoItem &item : qAsConst(error.items)) {
|
|
|
|
|
createTaskAndOutput(
|
|
|
|
|
ProjectExplorer::Task::Error,
|
|
|
|
|
item.description,
|
|
|
|
|
item.filePath.toString(),
|
|
|
|
|
item.line);
|
|
|
|
|
}
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2014-02-18 15:12:41 +01:00
|
|
|
// Building can uncover additional target artifacts.
|
2019-10-25 09:55:32 +02:00
|
|
|
qbsBuildSystem()->updateAfterBuild();
|
2014-07-11 12:44:12 +02:00
|
|
|
|
|
|
|
|
// The reparsing, if it is necessary, has to be done before finished() is emitted, as
|
|
|
|
|
// otherwise a potential additional build step could conflict with the parsing step.
|
2019-06-28 14:30:32 +02:00
|
|
|
if (qbsBuildSystem()->parsingScheduled()) {
|
|
|
|
|
m_parsingAfterBuild = true;
|
2014-07-14 14:22:27 +02:00
|
|
|
parseProject();
|
2019-06-28 14:30:32 +02:00
|
|
|
} else {
|
2014-07-11 12:44:12 +02:00
|
|
|
finish();
|
2019-06-28 14:30:32 +02:00
|
|
|
}
|
2014-03-03 17:23:41 +01:00
|
|
|
}
|
2014-02-18 15:12:41 +01:00
|
|
|
|
2014-07-14 14:22:27 +02:00
|
|
|
void QbsBuildStep::reparsingDone(bool success)
|
2014-03-03 17:23:41 +01:00
|
|
|
{
|
2019-10-25 09:55:32 +02:00
|
|
|
disconnect(target(), &Target::parsingFinished, this, &QbsBuildStep::reparsingDone);
|
2014-07-14 14:22:27 +02:00
|
|
|
m_parsingProject = false;
|
2019-06-28 14:30:32 +02:00
|
|
|
if (m_parsingAfterBuild) {
|
2014-07-14 14:22:27 +02:00
|
|
|
finish();
|
|
|
|
|
} else if (!success) {
|
|
|
|
|
m_lastWasSuccess = false;
|
|
|
|
|
finish();
|
|
|
|
|
} else {
|
|
|
|
|
build();
|
|
|
|
|
}
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStep::handleTaskStarted(const QString &desciption, int max)
|
|
|
|
|
{
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
m_currentTask = desciption;
|
|
|
|
|
m_maxProgress = max;
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStep::handleProgress(int value)
|
|
|
|
|
{
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
if (m_maxProgress > 0)
|
|
|
|
|
emit progress(value * 100 / m_maxProgress, m_currentTask);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
void QbsBuildStep::handleCommandDescription(const QString &message)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::Stdout);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
void QbsBuildStep::handleProcessResult(
|
|
|
|
|
const FilePath &executable,
|
|
|
|
|
const QStringList &arguments,
|
|
|
|
|
const FilePath &workingDir,
|
|
|
|
|
const QStringList &stdOut,
|
|
|
|
|
const QStringList &stdErr,
|
|
|
|
|
bool success)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2020-04-16 13:53:05 +02:00
|
|
|
Q_UNUSED(workingDir);
|
2019-06-28 14:30:32 +02:00
|
|
|
const bool hasOutput = !stdOut.isEmpty() || !stdErr.isEmpty();
|
|
|
|
|
if (success && !hasOutput)
|
2013-01-30 18:19:31 +01:00
|
|
|
return;
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
emit addOutput(executable.toUserOutput() + ' ' + QtcProcess::joinArgs(arguments),
|
|
|
|
|
OutputFormat::Stdout);
|
2020-04-16 13:53:05 +02:00
|
|
|
for (const QString &line : stdErr)
|
2017-10-19 13:53:57 +02:00
|
|
|
emit addOutput(line, OutputFormat::Stderr);
|
2020-04-16 13:53:05 +02:00
|
|
|
for (const QString &line : stdOut)
|
2017-10-19 13:53:57 +02:00
|
|
|
emit addOutput(line, OutputFormat::Stdout);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message,
|
|
|
|
|
const QString &file, int line)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::Stdout);
|
2020-04-16 13:53:05 +02:00
|
|
|
emit addTask(CompileTask(type, message, FilePath::fromString(file), line), 1);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsBuildStep::buildVariant() const
|
|
|
|
|
{
|
2016-10-23 06:01:41 +03:00
|
|
|
return qbsConfiguration(PreserveVariables).value(Constants::QBS_CONFIG_VARIANT_KEY).toString();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
QbsBuildSystem *QbsBuildStep::qbsBuildSystem() const
|
|
|
|
|
{
|
2020-02-19 11:55:48 +01:00
|
|
|
return static_cast<QbsBuildSystem *>(buildSystem());
|
2019-10-25 09:55:32 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
void QbsBuildStep::setBuildVariant(const QString &variant)
|
|
|
|
|
{
|
2017-07-27 23:27:25 +03:00
|
|
|
if (m_qbsConfiguration.value(Constants::QBS_CONFIG_VARIANT_KEY).toString() == variant)
|
2013-01-30 18:19:31 +01:00
|
|
|
return;
|
2017-07-27 23:27:25 +03:00
|
|
|
m_qbsConfiguration.insert(Constants::QBS_CONFIG_VARIANT_KEY, variant);
|
2013-01-30 18:19:31 +01:00
|
|
|
emit qbsConfigurationChanged();
|
2019-05-02 12:05:13 +02:00
|
|
|
if (ProjectExplorer::BuildConfiguration *bc = buildConfiguration())
|
|
|
|
|
emit bc->buildTypeChanged();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsBuildStep::profile() const
|
|
|
|
|
{
|
2016-10-23 06:01:41 +03:00
|
|
|
return qbsConfiguration(PreserveVariables).value(Constants::QBS_CONFIG_PROFILE_KEY).toString();
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-14 14:22:27 +02:00
|
|
|
void QbsBuildStep::parseProject()
|
|
|
|
|
{
|
|
|
|
|
m_parsingProject = true;
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(target(), &Target::parsingFinished, this, &QbsBuildStep::reparsingDone);
|
|
|
|
|
qbsBuildSystem()->parseCurrentBuildConfiguration();
|
2014-07-14 14:22:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStep::build()
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
m_session = qbsBuildSystem()->session();
|
|
|
|
|
if (!m_session) {
|
|
|
|
|
emit addOutput(tr("No qbs session exists for this target."), OutputFormat::ErrorMessage);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(false);
|
2014-07-14 14:22:27 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
QJsonObject request;
|
|
|
|
|
request.insert("type", "build-project");
|
|
|
|
|
request.insert("max-job-count", maxJobs());
|
|
|
|
|
request.insert("keep-going", keepGoing());
|
|
|
|
|
request.insert("command-echo-mode", showCommandLines() ? "command-line" : "summary");
|
|
|
|
|
request.insert("install", install());
|
|
|
|
|
QbsSession::insertRequestedModuleProperties(request);
|
|
|
|
|
request.insert("clean-install-root", cleanInstallRoot());
|
|
|
|
|
if (!m_products.isEmpty())
|
|
|
|
|
request.insert("products", QJsonArray::fromStringList(m_products));
|
|
|
|
|
if (!m_changedFiles.isEmpty()) {
|
|
|
|
|
const auto changedFilesArray = QJsonArray::fromStringList(m_changedFiles);
|
|
|
|
|
request.insert("changed-files", changedFilesArray);
|
|
|
|
|
request.insert("files-to-consider", changedFilesArray);
|
|
|
|
|
}
|
|
|
|
|
if (!m_activeFileTags.isEmpty())
|
|
|
|
|
request.insert("active-file-tags", QJsonArray::fromStringList(m_activeFileTags));
|
|
|
|
|
request.insert("data-mode", "only-if-changed");
|
2014-07-14 14:22:27 +02:00
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
m_session->sendRequest(request);
|
|
|
|
|
m_maxProgress = 0;
|
|
|
|
|
connect(m_session, &QbsSession::projectBuilt, this, &QbsBuildStep::buildingDone);
|
|
|
|
|
connect(m_session, &QbsSession::taskStarted, this, &QbsBuildStep::handleTaskStarted);
|
|
|
|
|
connect(m_session, &QbsSession::taskProgress, this, &QbsBuildStep::handleProgress);
|
|
|
|
|
connect(m_session, &QbsSession::commandDescription,
|
|
|
|
|
this, &QbsBuildStep::handleCommandDescription);
|
|
|
|
|
connect(m_session, &QbsSession::processResult, this, &QbsBuildStep::handleProcessResult);
|
|
|
|
|
connect(m_session, &QbsSession::errorOccurred, this, [this] {
|
|
|
|
|
buildingDone(ErrorInfo(tr("Build canceled: Qbs session failed.")));
|
|
|
|
|
});
|
2014-07-14 14:22:27 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-11 12:44:12 +02:00
|
|
|
void QbsBuildStep::finish()
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
m_session = nullptr;
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(m_lastWasSuccess);
|
2014-07-11 12:44:12 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-06 15:11:12 +01:00
|
|
|
void QbsBuildStep::updateState()
|
|
|
|
|
{
|
|
|
|
|
emit qbsConfigurationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-13 18:01:27 +01:00
|
|
|
QbsBuildStepData QbsBuildStep::stepData() const
|
|
|
|
|
{
|
|
|
|
|
QbsBuildStepData data;
|
|
|
|
|
data.command = "build";
|
|
|
|
|
data.dryRun = false;
|
2020-11-06 15:11:12 +01:00
|
|
|
data.keepGoing = m_keepGoing->value();
|
|
|
|
|
data.forceProbeExecution = m_forceProbes->value();
|
|
|
|
|
data.showCommandLines = m_showCommandLines->value();
|
|
|
|
|
data.noInstall = !m_install->value();
|
2020-02-13 18:01:27 +01:00
|
|
|
data.noBuild = false;
|
2020-11-06 15:11:12 +01:00
|
|
|
data.cleanInstallRoot = m_cleanInstallDir->value();
|
2020-02-13 18:01:27 +01:00
|
|
|
data.jobCount = maxJobs();
|
|
|
|
|
data.installRoot = installRoot();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-14 13:34:49 +02:00
|
|
|
void QbsBuildStep::dropSession()
|
|
|
|
|
{
|
|
|
|
|
if (m_session) {
|
|
|
|
|
doCancel();
|
|
|
|
|
m_session->disconnect(this);
|
|
|
|
|
m_session = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-13 18:01:27 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsBuildStepConfigWidget:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) :
|
2020-09-11 13:39:11 +02:00
|
|
|
m_qbsStep(step),
|
2013-06-12 14:36:02 +02:00
|
|
|
m_ignoreChange(false)
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
2019-06-27 12:10:04 +02:00
|
|
|
connect(step, &ProjectConfiguration::displayNameChanged,
|
2016-06-28 23:29:21 +03:00
|
|
|
this, &QbsBuildStepConfigWidget::updateState);
|
2019-11-22 14:50:15 +01:00
|
|
|
connect(static_cast<QbsBuildConfiguration *>(step->buildConfiguration()),
|
|
|
|
|
&QbsBuildConfiguration::qbsConfigurationChanged,
|
2016-06-28 23:29:21 +03:00
|
|
|
this, &QbsBuildStepConfigWidget::updateState);
|
2018-10-12 18:38:22 +02:00
|
|
|
connect(step, &QbsBuildStep::qbsBuildOptionsChanged,
|
2016-06-28 23:29:21 +03:00
|
|
|
this, &QbsBuildStepConfigWidget::updateState);
|
2019-06-28 14:30:32 +02:00
|
|
|
connect(&QbsSettings::instance(), &QbsSettings::settingsChanged,
|
2016-02-22 17:49:02 +01:00
|
|
|
this, &QbsBuildStepConfigWidget::updateState);
|
2019-07-25 18:58:07 +02:00
|
|
|
connect(step->buildConfiguration(), &BuildConfiguration::buildDirectoryChanged,
|
|
|
|
|
this, &QbsBuildStepConfigWidget::updateState);
|
2013-01-30 18:19:31 +01:00
|
|
|
|
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
propertyEdit = new FancyLineEdit(this);
|
|
|
|
|
|
|
|
|
|
defaultInstallDirCheckBox = new QCheckBox(this);
|
|
|
|
|
|
|
|
|
|
installDirChooser = new PathChooser(this);
|
|
|
|
|
installDirChooser->setExpectedKind(PathChooser::Directory);
|
|
|
|
|
|
2020-11-06 15:11:12 +01:00
|
|
|
LayoutBuilder builder(this);
|
2020-11-09 16:19:23 +01:00
|
|
|
builder.addRow(m_qbsStep->m_buildVariant);
|
2020-11-06 15:11:12 +01:00
|
|
|
builder.addRow(m_qbsStep->m_maxJobCount);
|
|
|
|
|
builder.addRow({tr("Properties:"), propertyEdit});
|
|
|
|
|
|
|
|
|
|
builder.addRow(tr("Flags:"));
|
|
|
|
|
m_qbsStep->m_keepGoing->addToLayout(builder);
|
|
|
|
|
m_qbsStep->m_showCommandLines->addToLayout(builder);
|
|
|
|
|
m_qbsStep->m_forceProbes->addToLayout(builder);
|
|
|
|
|
|
|
|
|
|
builder.addRow(tr("Installation flags:"));
|
|
|
|
|
m_qbsStep->m_install->addToLayout(builder);
|
|
|
|
|
m_qbsStep->m_cleanInstallDir->addToLayout(builder);
|
|
|
|
|
builder.addItem(defaultInstallDirCheckBox);
|
|
|
|
|
|
|
|
|
|
builder.addRow({tr("Installation directory:"), installDirChooser});
|
2020-11-16 10:00:38 +01:00
|
|
|
builder.addRow(m_qbsStep->m_commandLine);
|
2020-11-06 15:11:12 +01:00
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
propertyEdit->setToolTip(tr("Properties to pass to the project."));
|
|
|
|
|
defaultInstallDirCheckBox->setText(tr("Use default location"));
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
auto chooser = new VariableChooser(this);
|
2019-06-27 12:10:04 +02:00
|
|
|
chooser->addSupportedWidget(propertyEdit);
|
|
|
|
|
chooser->addSupportedWidget(installDirChooser->lineEdit());
|
2020-02-19 11:55:48 +01:00
|
|
|
chooser->addMacroExpanderProvider([step] { return step->macroExpander(); });
|
2019-06-27 12:10:04 +02:00
|
|
|
propertyEdit->setValidationFunction([this](FancyLineEdit *edit, QString *errorMessage) {
|
2015-04-28 14:49:56 +02:00
|
|
|
return validateProperties(edit, errorMessage);
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
connect(defaultInstallDirCheckBox, &QCheckBox::toggled, this,
|
2017-02-13 15:40:59 +01:00
|
|
|
&QbsBuildStepConfigWidget::changeUseDefaultInstallDir);
|
2020-11-06 15:11:12 +01:00
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
connect(installDirChooser, &Utils::PathChooser::rawPathChanged, this,
|
2017-02-13 15:40:59 +01:00
|
|
|
&QbsBuildStepConfigWidget::changeInstallDir);
|
2020-11-06 15:11:12 +01:00
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
updateState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStepConfigWidget::updateState()
|
|
|
|
|
{
|
2013-06-12 14:36:02 +02:00
|
|
|
if (!m_ignoreChange) {
|
2020-11-06 15:11:12 +01:00
|
|
|
updatePropertyEdit(m_qbsStep->qbsConfiguration(QbsBuildStep::PreserveVariables));
|
|
|
|
|
installDirChooser->setFilePath(m_qbsStep->installRoot(QbsBuildStep::PreserveVariables));
|
|
|
|
|
defaultInstallDirCheckBox->setChecked(!m_qbsStep->hasCustomInstallRoot());
|
2013-06-12 14:36:02 +02:00
|
|
|
}
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2020-09-11 13:39:11 +02:00
|
|
|
const auto qbsBuildConfig = static_cast<QbsBuildConfiguration *>(qbsStep()->buildConfiguration());
|
2020-02-13 18:01:27 +01:00
|
|
|
|
|
|
|
|
QString command = qbsBuildConfig->equivalentCommandLine(qbsStep()->stepData());
|
2013-01-30 18:19:31 +01:00
|
|
|
|
2015-04-28 14:49:56 +02:00
|
|
|
for (int i = 0; i < m_propertyCache.count(); ++i) {
|
2017-07-27 23:27:25 +03:00
|
|
|
command += ' ' + m_propertyCache.at(i).name + ':' + m_propertyCache.at(i).effectiveValue;
|
2013-06-12 14:36:02 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 16:20:33 +01:00
|
|
|
const auto addToCommand = [&command](TriState ts, const QString &key) {
|
|
|
|
|
if (ts == TriState::Enabled)
|
|
|
|
|
command.append(' ').append(key).append(":true");
|
|
|
|
|
else if (ts == TriState::Disabled)
|
|
|
|
|
command.append(' ').append(key).append(":false");
|
|
|
|
|
// Do nothing for TriState::Default
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
addToCommand(qbsBuildConfig->separateDebugInfoSetting(),
|
|
|
|
|
Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY);
|
|
|
|
|
|
|
|
|
|
addToCommand(qbsBuildConfig->qmlDebuggingSetting(),
|
|
|
|
|
Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
|
|
|
|
|
|
|
|
|
|
addToCommand(qbsBuildConfig->qtQuickCompilerSetting(),
|
|
|
|
|
Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
|
|
|
|
|
|
2020-11-16 10:00:38 +01:00
|
|
|
m_qbsStep->m_commandLine->setValue(command);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-06-13 17:15:44 +02:00
|
|
|
|
2013-06-12 14:36:02 +02:00
|
|
|
void QbsBuildStepConfigWidget::updatePropertyEdit(const QVariantMap &data)
|
|
|
|
|
{
|
|
|
|
|
QVariantMap editable = data;
|
|
|
|
|
|
|
|
|
|
// remove data that is edited with special UIs:
|
2017-07-27 23:27:25 +03:00
|
|
|
editable.remove(Constants::QBS_CONFIG_PROFILE_KEY);
|
|
|
|
|
editable.remove(Constants::QBS_CONFIG_VARIANT_KEY);
|
2018-02-09 13:33:40 +01:00
|
|
|
editable.remove(Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY); // For existing .user files
|
2019-11-25 15:07:21 +01:00
|
|
|
editable.remove(Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY);
|
2017-07-27 23:27:25 +03:00
|
|
|
editable.remove(Constants::QBS_CONFIG_QUICK_DEBUG_KEY);
|
2019-11-25 16:38:35 +01:00
|
|
|
editable.remove(Constants::QBS_CONFIG_QUICK_COMPILER_KEY);
|
2017-07-27 23:27:25 +03:00
|
|
|
editable.remove(Constants::QBS_FORCE_PROBES_KEY);
|
|
|
|
|
editable.remove(Constants::QBS_INSTALL_ROOT_KEY);
|
2013-06-12 14:36:02 +02:00
|
|
|
|
|
|
|
|
QStringList propertyList;
|
|
|
|
|
for (QVariantMap::const_iterator i = editable.constBegin(); i != editable.constEnd(); ++i)
|
2017-07-27 23:27:25 +03:00
|
|
|
propertyList.append(i.key() + ':' + i.value().toString());
|
2013-06-12 14:36:02 +02:00
|
|
|
|
2019-06-27 12:10:04 +02:00
|
|
|
propertyEdit->setText(QtcProcess::joinArgs(propertyList));
|
2013-06-12 14:36:02 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-09 16:19:23 +01:00
|
|
|
void QbsBuildStep::changeBuildVariant()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
|
|
|
|
QString variant;
|
2020-11-09 16:19:23 +01:00
|
|
|
if (m_buildVariant->value() == 1)
|
2017-07-27 23:27:25 +03:00
|
|
|
variant = Constants::QBS_VARIANT_RELEASE;
|
2013-01-30 18:19:31 +01:00
|
|
|
else
|
2017-07-27 23:27:25 +03:00
|
|
|
variant = Constants::QBS_VARIANT_DEBUG;
|
2020-11-09 16:19:23 +01:00
|
|
|
setBuildVariant(variant);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-13 15:40:59 +01:00
|
|
|
void QbsBuildStepConfigWidget::changeUseDefaultInstallDir(bool useDefault)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2018-10-12 18:38:22 +02:00
|
|
|
QVariantMap config = qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables);
|
2019-06-27 12:10:04 +02:00
|
|
|
installDirChooser->setEnabled(!useDefault);
|
2017-02-13 15:40:59 +01:00
|
|
|
if (useDefault)
|
|
|
|
|
config.remove(Constants::QBS_INSTALL_ROOT_KEY);
|
|
|
|
|
else
|
2019-06-27 12:10:04 +02:00
|
|
|
config.insert(Constants::QBS_INSTALL_ROOT_KEY, installDirChooser->rawPath());
|
2018-10-12 18:38:22 +02:00
|
|
|
qbsStep()->setQbsConfiguration(config);
|
2017-02-13 15:40:59 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsBuildStepConfigWidget::changeInstallDir(const QString &dir)
|
|
|
|
|
{
|
2018-10-12 18:38:22 +02:00
|
|
|
if (!qbsStep()->hasCustomInstallRoot())
|
2017-02-13 15:40:59 +01:00
|
|
|
return;
|
|
|
|
|
m_ignoreChange = true;
|
2018-10-12 18:38:22 +02:00
|
|
|
QVariantMap config = qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables);
|
2017-02-13 15:40:59 +01:00
|
|
|
config.insert(Constants::QBS_INSTALL_ROOT_KEY, dir);
|
2018-10-12 18:38:22 +02:00
|
|
|
qbsStep()->setQbsConfiguration(config);
|
2017-02-13 15:40:59 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 14:49:56 +02:00
|
|
|
void QbsBuildStepConfigWidget::applyCachedProperties()
|
2013-06-12 14:36:02 +02:00
|
|
|
{
|
|
|
|
|
QVariantMap data;
|
2018-10-12 18:38:22 +02:00
|
|
|
const QVariantMap tmp = qbsStep()->qbsConfiguration(QbsBuildStep::PreserveVariables);
|
2013-06-12 14:36:02 +02:00
|
|
|
|
|
|
|
|
// Insert values set up with special UIs:
|
2017-07-27 23:27:25 +03:00
|
|
|
data.insert(Constants::QBS_CONFIG_PROFILE_KEY,
|
|
|
|
|
tmp.value(Constants::QBS_CONFIG_PROFILE_KEY));
|
|
|
|
|
data.insert(Constants::QBS_CONFIG_VARIANT_KEY,
|
|
|
|
|
tmp.value(Constants::QBS_CONFIG_VARIANT_KEY));
|
2017-10-06 17:06:59 +02:00
|
|
|
const QStringList additionalSpecialKeys({Constants::QBS_CONFIG_DECLARATIVE_DEBUG_KEY,
|
|
|
|
|
Constants::QBS_CONFIG_QUICK_DEBUG_KEY,
|
2019-11-25 16:38:35 +01:00
|
|
|
Constants::QBS_CONFIG_QUICK_COMPILER_KEY,
|
2019-11-25 15:07:21 +01:00
|
|
|
Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY,
|
2017-10-06 17:06:59 +02:00
|
|
|
Constants::QBS_INSTALL_ROOT_KEY});
|
|
|
|
|
for (const QString &key : additionalSpecialKeys) {
|
|
|
|
|
const auto it = tmp.constFind(key);
|
|
|
|
|
if (it != tmp.cend())
|
|
|
|
|
data.insert(key, it.value());
|
|
|
|
|
}
|
2013-06-13 17:15:44 +02:00
|
|
|
|
2016-10-23 06:01:41 +03:00
|
|
|
for (int i = 0; i < m_propertyCache.count(); ++i) {
|
|
|
|
|
const Property &property = m_propertyCache.at(i);
|
|
|
|
|
data.insert(property.name, property.value);
|
|
|
|
|
}
|
2013-06-12 14:36:02 +02:00
|
|
|
|
|
|
|
|
m_ignoreChange = true;
|
2018-10-12 18:38:22 +02:00
|
|
|
qbsStep()->setQbsConfiguration(data);
|
2013-06-12 14:36:02 +02:00
|
|
|
m_ignoreChange = false;
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-12 18:38:22 +02:00
|
|
|
QbsBuildStep *QbsBuildStepConfigWidget::qbsStep() const
|
|
|
|
|
{
|
2020-09-11 13:39:11 +02:00
|
|
|
return m_qbsStep;
|
2018-10-12 18:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-28 14:49:56 +02:00
|
|
|
bool QbsBuildStepConfigWidget::validateProperties(Utils::FancyLineEdit *edit, QString *errorMessage)
|
|
|
|
|
{
|
|
|
|
|
Utils::QtcProcess::SplitError err;
|
|
|
|
|
QStringList argList = Utils::QtcProcess::splitArgs(edit->text(), Utils::HostOsInfo::hostOs(),
|
|
|
|
|
false, &err);
|
|
|
|
|
if (err != Utils::QtcProcess::SplitOk) {
|
|
|
|
|
if (errorMessage)
|
|
|
|
|
*errorMessage = tr("Could not split properties.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 06:01:41 +03:00
|
|
|
QList<Property> properties;
|
2020-09-11 13:39:11 +02:00
|
|
|
const MacroExpander * const expander = qbsStep()->macroExpander();
|
2016-09-20 17:11:03 +03:00
|
|
|
foreach (const QString &rawArg, argList) {
|
2017-07-27 23:27:25 +03:00
|
|
|
int pos = rawArg.indexOf(':');
|
2015-04-28 14:49:56 +02:00
|
|
|
if (pos > 0) {
|
2018-10-23 17:13:45 +02:00
|
|
|
const QString propertyName = rawArg.left(pos);
|
|
|
|
|
static const QStringList specialProperties{
|
|
|
|
|
Constants::QBS_CONFIG_PROFILE_KEY, Constants::QBS_CONFIG_VARIANT_KEY,
|
2019-11-25 16:38:35 +01:00
|
|
|
Constants::QBS_CONFIG_QUICK_DEBUG_KEY, Constants::QBS_CONFIG_QUICK_COMPILER_KEY,
|
|
|
|
|
Constants::QBS_INSTALL_ROOT_KEY, Constants::QBS_CONFIG_SEPARATE_DEBUG_INFO_KEY,
|
2019-11-25 15:07:21 +01:00
|
|
|
};
|
2018-10-23 17:13:45 +02:00
|
|
|
if (specialProperties.contains(propertyName)) {
|
|
|
|
|
if (errorMessage) {
|
|
|
|
|
*errorMessage = tr("Property \"%1\" cannot be set here. "
|
|
|
|
|
"Please use the dedicated UI element.").arg(propertyName);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-10-23 06:01:41 +03:00
|
|
|
const QString rawValue = rawArg.mid(pos + 1);
|
2018-10-23 17:13:45 +02:00
|
|
|
Property property(propertyName, rawValue, expander->expand(rawValue));
|
2016-10-23 06:01:41 +03:00
|
|
|
properties.append(property);
|
2015-04-28 14:49:56 +02:00
|
|
|
} else {
|
|
|
|
|
if (errorMessage)
|
2015-06-01 09:51:04 +02:00
|
|
|
*errorMessage = tr("No \":\" found in property definition.");
|
2015-04-28 14:49:56 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_propertyCache != properties) {
|
|
|
|
|
m_propertyCache = properties;
|
|
|
|
|
applyCachedProperties();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-30 18:19:31 +01:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsBuildStepFactory:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
QbsBuildStepFactory::QbsBuildStepFactory()
|
2013-01-30 18:19:31 +01:00
|
|
|
{
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
registerStep<QbsBuildStep>(Constants::QBS_BUILDSTEP_ID);
|
2018-05-14 17:50:56 +02:00
|
|
|
setDisplayName(QbsBuildStep::tr("Qbs Build"));
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
|
|
|
|
setSupportedConfiguration(Constants::QBS_BC_ID);
|
|
|
|
|
setSupportedProjectType(Constants::PROJECT_ID);
|
2013-01-30 18:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|
2016-10-23 05:52:51 +03:00
|
|
|
|
|
|
|
|
#include "qbsbuildstep.moc"
|