2017-05-04 12:16:38 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsinstallstep.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsbuildconfiguration.h"
|
|
|
|
|
#include "qbsbuildstep.h"
|
|
|
|
|
#include "qbsproject.h"
|
|
|
|
|
#include "qbsprojectmanagerconstants.h"
|
2019-06-28 14:30:32 +02:00
|
|
|
#include "qbssession.h"
|
2017-05-04 12:16:38 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
|
#include <projectexplorer/kit.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2019-06-25 18:37:49 +02:00
|
|
|
#include <QCheckBox>
|
2017-05-04 12:16:38 +02:00
|
|
|
#include <QFileInfo>
|
2019-06-25 18:37:49 +02:00
|
|
|
#include <QFormLayout>
|
2019-06-28 14:30:32 +02:00
|
|
|
#include <QJsonObject>
|
2019-06-25 18:37:49 +02:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2017-05-04 12:16:38 +02:00
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// Constants:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static const char QBS_REMOVE_FIRST[] = "Qbs.RemoveFirst";
|
|
|
|
|
static const char QBS_DRY_RUN[] = "Qbs.DryRun";
|
|
|
|
|
static const char QBS_KEEP_GOING[] = "Qbs.DryKeepGoing";
|
|
|
|
|
|
|
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-06-25 18:37:49 +02:00
|
|
|
class QbsInstallStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QbsInstallStepConfigWidget(QbsInstallStep *step);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void updateState();
|
|
|
|
|
|
|
|
|
|
void changeRemoveFirst(bool rf) { m_step->setRemoveFirst(rf); }
|
|
|
|
|
void changeDryRun(bool dr) { m_step->setDryRun(dr); }
|
|
|
|
|
void changeKeepGoing(bool kg) { m_step->setKeepGoing(kg); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QbsInstallStep *m_step;
|
|
|
|
|
bool m_ignoreChange;
|
|
|
|
|
|
|
|
|
|
QCheckBox *m_dryRunCheckBox;
|
|
|
|
|
QCheckBox *m_keepGoingCheckBox;
|
|
|
|
|
QCheckBox *m_removeFirstCheckBox;
|
|
|
|
|
QPlainTextEdit *m_commandLineTextEdit;
|
|
|
|
|
QLabel *m_installRootValueLabel;
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-04 12:16:38 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsInstallStep:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2019-12-20 17:05:30 +01:00
|
|
|
QbsInstallStep::QbsInstallStep(BuildStepList *bsl, Core::Id id)
|
|
|
|
|
: BuildStep(bsl, id)
|
2017-05-04 12:16:38 +02:00
|
|
|
{
|
|
|
|
|
setDisplayName(tr("Qbs Install"));
|
|
|
|
|
|
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
|
|
|
const QbsBuildConfiguration * const bc = buildConfig();
|
2019-06-28 14:30:32 +02:00
|
|
|
connect(bc, &QbsBuildConfiguration::qbsConfigurationChanged, this, &QbsInstallStep::changed);
|
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
|
|
|
if (bc->qbsStep()) {
|
|
|
|
|
connect(bc->qbsStep(), &QbsBuildStep::qbsBuildOptionsChanged,
|
2019-06-28 14:30:32 +02:00
|
|
|
this, &QbsInstallStep::changed);
|
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
|
|
|
}
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsInstallStep::~QbsInstallStep()
|
|
|
|
|
{
|
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);
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool QbsInstallStep::init()
|
2017-05-04 12:16:38 +02:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
QTC_ASSERT(!buildConfiguration()->buildSystem()->isParsing() && !m_session, return false);
|
2017-05-04 12:16:38 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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 QbsInstallStep::doRun()
|
2017-05-04 12:16:38 +02:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
m_session = static_cast<QbsBuildSystem *>(buildSystem())->session();
|
2017-05-04 12:16:38 +02:00
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
QJsonObject request;
|
|
|
|
|
request.insert("type", "install");
|
|
|
|
|
request.insert("install-root", installRoot());
|
|
|
|
|
request.insert("clean-install-root", m_cleanInstallRoot);
|
|
|
|
|
request.insert("keep-going", m_keepGoing);
|
|
|
|
|
request.insert("dry-run", m_dryRun);
|
|
|
|
|
m_session->sendRequest(request);
|
2017-05-04 12:16:38 +02:00
|
|
|
|
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_maxProgress = 0;
|
2019-06-28 14:30:32 +02:00
|
|
|
connect(m_session, &QbsSession::projectInstalled, this, &QbsInstallStep::installDone);
|
|
|
|
|
connect(m_session, &QbsSession::taskStarted, this, &QbsInstallStep::handleTaskStarted);
|
|
|
|
|
connect(m_session, &QbsSession::taskProgress, this, &QbsInstallStep::handleProgress);
|
|
|
|
|
connect(m_session, &QbsSession::errorOccurred, this, [this] {
|
|
|
|
|
installDone(ErrorInfo(tr("Installing canceled: Qbs session failed.")));
|
|
|
|
|
});
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::BuildStepConfigWidget *QbsInstallStep::createConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
return new QbsInstallStepConfigWidget(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 QbsInstallStep::doCancel()
|
2017-05-04 12:16:38 +02:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
if (m_session)
|
|
|
|
|
m_session->cancelCurrentJob();
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsInstallStep::installRoot() const
|
|
|
|
|
{
|
|
|
|
|
const QbsBuildStep * const bs = buildConfig()->qbsStep();
|
|
|
|
|
return bs ? bs->installRoot().toString() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QbsBuildConfiguration *QbsInstallStep::buildConfig() const
|
|
|
|
|
{
|
2018-05-17 10:26:10 +02:00
|
|
|
return static_cast<QbsBuildConfiguration *>(buildConfiguration());
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QbsInstallStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!ProjectExplorer::BuildStep::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
m_cleanInstallRoot = map.value(QBS_REMOVE_FIRST, false).toBool();
|
|
|
|
|
m_dryRun = map.value(QBS_DRY_RUN, false).toBool();
|
|
|
|
|
m_keepGoing = map.value(QBS_KEEP_GOING, false).toBool();
|
2017-05-04 12:16:38 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap QbsInstallStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map = ProjectExplorer::BuildStep::toMap();
|
2019-06-28 14:30:32 +02:00
|
|
|
map.insert(QBS_REMOVE_FIRST, m_cleanInstallRoot);
|
|
|
|
|
map.insert(QBS_DRY_RUN, m_dryRun);
|
|
|
|
|
map.insert(QBS_KEEP_GOING, m_keepGoing);
|
2017-05-04 12:16:38 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
void QbsInstallStep::installDone(const ErrorInfo &error)
|
2017-05-04 12:16:38 +02:00
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
m_session->disconnect(this);
|
|
|
|
|
m_session = nullptr;
|
2017-05-04 12:16:38 +02:00
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
for (const ErrorInfoItem &item : error.items)
|
|
|
|
|
createTaskAndOutput(Task::Error, item.description, item.filePath.toString(), item.line);
|
2017-05-04 12:16:38 +02:00
|
|
|
|
2019-06-28 14:30:32 +02:00
|
|
|
emit finished(!error.hasError());
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStep::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_description = desciption;
|
|
|
|
|
m_maxProgress = max;
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStep::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_description);
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type,
|
|
|
|
|
const QString &message, const QString &file, int line)
|
|
|
|
|
{
|
2020-01-15 08:56:11 +01:00
|
|
|
const CompileTask task(type, message, Utils::FilePath::fromString(file), line);
|
2017-05-04 12:16:38 +02:00
|
|
|
emit addTask(task, 1);
|
|
|
|
|
emit addOutput(message, OutputFormat::Stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStep::setRemoveFirst(bool rf)
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
if (m_cleanInstallRoot == rf)
|
2017-05-04 12:16:38 +02:00
|
|
|
return;
|
2019-06-28 14:30:32 +02:00
|
|
|
m_cleanInstallRoot = rf;
|
2017-05-04 12:16:38 +02:00
|
|
|
emit changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStep::setDryRun(bool dr)
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
if (m_dryRun == dr)
|
2017-05-04 12:16:38 +02:00
|
|
|
return;
|
2019-06-28 14:30:32 +02:00
|
|
|
m_dryRun = dr;
|
2017-05-04 12:16:38 +02:00
|
|
|
emit changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStep::setKeepGoing(bool kg)
|
|
|
|
|
{
|
2019-06-28 14:30:32 +02:00
|
|
|
if (m_keepGoing == kg)
|
2017-05-04 12:16:38 +02:00
|
|
|
return;
|
2019-06-28 14:30:32 +02:00
|
|
|
m_keepGoing = kg;
|
2017-05-04 12:16:38 +02:00
|
|
|
emit changed();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-13 18:01:27 +01:00
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-04 12:16:38 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsInstallStepConfigWidget:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsInstallStepConfigWidget::QbsInstallStepConfigWidget(QbsInstallStep *step) :
|
2018-09-20 11:19:41 +02:00
|
|
|
BuildStepConfigWidget(step), m_step(step), m_ignoreChange(false)
|
2017-05-04 12:16:38 +02:00
|
|
|
{
|
|
|
|
|
connect(m_step, &ProjectExplorer::ProjectConfiguration::displayNameChanged,
|
|
|
|
|
this, &QbsInstallStepConfigWidget::updateState);
|
|
|
|
|
connect(m_step, &QbsInstallStep::changed,
|
|
|
|
|
this, &QbsInstallStepConfigWidget::updateState);
|
|
|
|
|
|
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
2019-06-25 18:37:49 +02:00
|
|
|
auto installRootLabel = new QLabel(this);
|
|
|
|
|
|
|
|
|
|
auto flagsLabel = new QLabel(this);
|
|
|
|
|
|
|
|
|
|
m_dryRunCheckBox = new QCheckBox(this);
|
|
|
|
|
m_keepGoingCheckBox = new QCheckBox(this);
|
|
|
|
|
m_removeFirstCheckBox = new QCheckBox(this);
|
|
|
|
|
|
|
|
|
|
auto horizontalLayout = new QHBoxLayout();
|
|
|
|
|
horizontalLayout->addWidget(m_dryRunCheckBox);
|
|
|
|
|
horizontalLayout->addWidget(m_keepGoingCheckBox);
|
|
|
|
|
horizontalLayout->addWidget(m_removeFirstCheckBox);
|
|
|
|
|
horizontalLayout->addStretch(1);
|
|
|
|
|
|
|
|
|
|
auto commandLineKeyLabel = new QLabel(this);
|
|
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
|
|
|
|
sizePolicy.setHorizontalStretch(0);
|
|
|
|
|
sizePolicy.setVerticalStretch(0);
|
|
|
|
|
sizePolicy.setHeightForWidth(commandLineKeyLabel->sizePolicy().hasHeightForWidth());
|
|
|
|
|
commandLineKeyLabel->setSizePolicy(sizePolicy);
|
|
|
|
|
commandLineKeyLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
|
|
|
|
|
|
|
|
|
|
m_commandLineTextEdit = new QPlainTextEdit(this);
|
|
|
|
|
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
|
sizePolicy1.setHorizontalStretch(0);
|
|
|
|
|
sizePolicy1.setVerticalStretch(0);
|
|
|
|
|
sizePolicy1.setHeightForWidth(m_commandLineTextEdit->sizePolicy().hasHeightForWidth());
|
|
|
|
|
m_commandLineTextEdit->setSizePolicy(sizePolicy1);
|
|
|
|
|
m_commandLineTextEdit->setReadOnly(true);
|
|
|
|
|
m_commandLineTextEdit->setTextInteractionFlags(Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse);
|
|
|
|
|
|
|
|
|
|
m_installRootValueLabel = new QLabel(this);
|
|
|
|
|
|
|
|
|
|
auto formLayout = new QFormLayout(this);
|
|
|
|
|
formLayout->setWidget(0, QFormLayout::LabelRole, installRootLabel);
|
|
|
|
|
formLayout->setWidget(0, QFormLayout::FieldRole, m_installRootValueLabel);
|
|
|
|
|
formLayout->setWidget(1, QFormLayout::LabelRole, flagsLabel);
|
|
|
|
|
formLayout->setLayout(1, QFormLayout::FieldRole, horizontalLayout);
|
|
|
|
|
formLayout->setWidget(2, QFormLayout::LabelRole, commandLineKeyLabel);
|
|
|
|
|
formLayout->setWidget(2, QFormLayout::FieldRole, m_commandLineTextEdit);
|
|
|
|
|
|
|
|
|
|
QWidget::setTabOrder(m_dryRunCheckBox, m_keepGoingCheckBox);
|
|
|
|
|
QWidget::setTabOrder(m_keepGoingCheckBox, m_removeFirstCheckBox);
|
|
|
|
|
QWidget::setTabOrder(m_removeFirstCheckBox, m_commandLineTextEdit);
|
|
|
|
|
|
|
|
|
|
installRootLabel->setText(QbsInstallStep::tr("Install root:"));
|
|
|
|
|
flagsLabel->setText(QbsInstallStep::tr("Flags:"));
|
|
|
|
|
m_dryRunCheckBox->setText(QbsInstallStep::tr("Dry run"));
|
|
|
|
|
m_keepGoingCheckBox->setText(QbsInstallStep::tr("Keep going"));
|
|
|
|
|
m_removeFirstCheckBox->setText(QbsInstallStep::tr("Remove first"));
|
|
|
|
|
commandLineKeyLabel->setText(QbsInstallStep::tr("Equivalent command line:"));
|
|
|
|
|
m_installRootValueLabel->setText(QString());
|
|
|
|
|
|
|
|
|
|
connect(m_removeFirstCheckBox, &QAbstractButton::toggled,
|
2017-05-04 12:16:38 +02:00
|
|
|
this, &QbsInstallStepConfigWidget::changeRemoveFirst);
|
2019-06-25 18:37:49 +02:00
|
|
|
connect(m_dryRunCheckBox, &QAbstractButton::toggled,
|
2017-05-04 12:16:38 +02:00
|
|
|
this, &QbsInstallStepConfigWidget::changeDryRun);
|
2019-06-25 18:37:49 +02:00
|
|
|
connect(m_keepGoingCheckBox, &QAbstractButton::toggled,
|
2017-05-04 12:16:38 +02:00
|
|
|
this, &QbsInstallStepConfigWidget::changeKeepGoing);
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
connect(m_step->target(), &Target::parsingFinished,
|
2017-05-04 12:16:38 +02:00
|
|
|
this, &QbsInstallStepConfigWidget::updateState);
|
|
|
|
|
|
|
|
|
|
updateState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsInstallStepConfigWidget::updateState()
|
|
|
|
|
{
|
|
|
|
|
if (!m_ignoreChange) {
|
2019-06-25 18:37:49 +02:00
|
|
|
m_installRootValueLabel->setText(m_step->installRoot());
|
|
|
|
|
m_removeFirstCheckBox->setChecked(m_step->removeFirst());
|
|
|
|
|
m_dryRunCheckBox->setChecked(m_step->dryRun());
|
|
|
|
|
m_keepGoingCheckBox->setChecked(m_step->keepGoing());
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-13 18:01:27 +01:00
|
|
|
QString command = m_step->buildConfig()->equivalentCommandLine(m_step->stepData());
|
2017-05-04 12:16:38 +02:00
|
|
|
|
2019-06-25 18:37:49 +02:00
|
|
|
m_commandLineTextEdit->setPlainText(command);
|
2017-05-04 12:16:38 +02:00
|
|
|
|
2019-11-08 12:21:46 +03:00
|
|
|
setSummaryText(QbsInstallStep::tr("<b>Qbs:</b> %1").arg(command));
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsInstallStepFactory:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
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
|
|
|
QbsInstallStepFactory::QbsInstallStepFactory()
|
2017-05-04 12:16:38 +02: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<QbsInstallStep>(Constants::QBS_INSTALLSTEP_ID);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
|
|
|
|
setSupportedDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
|
|
|
|
setSupportedProjectType(Constants::PROJECT_ID);
|
2018-05-14 17:50:56 +02:00
|
|
|
setDisplayName(QbsInstallStep::tr("Qbs Install"));
|
2017-05-04 12:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|