forked from qt-creator/qt-creator
ProjectExplorer: Pimpl AbstractProcessStep
Change-Id: I0f77ff2e88b29674c306b394093deb2060db70c8 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
152d2245d9
commit
04ae0c8dfb
@@ -40,6 +40,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/synchronousprocess.h>
|
#include <utils/synchronousprocess.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <projectexplorer/abstractprocessstep.h>
|
#include <projectexplorer/abstractprocessstep.h>
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@@ -32,6 +32,8 @@
|
|||||||
#include <projectexplorer/abstractprocessstep.h>
|
#include <projectexplorer/abstractprocessstep.h>
|
||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
|
|
||||||
|
#include <utils/environment.h>
|
||||||
|
|
||||||
namespace Utils { class QtcProcess; }
|
namespace Utils { class QtcProcess; }
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@@ -31,12 +31,14 @@
|
|||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
|
#include <projectexplorer/gnumakeparser.h>
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
|
||||||
#include <projectexplorer/gnumakeparser.h>
|
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/gnumakeparser.h>
|
#include <projectexplorer/gnumakeparser.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include <projectexplorer/deployconfiguration.h>
|
#include <projectexplorer/deployconfiguration.h>
|
||||||
#include <projectexplorer/gnumakeparser.h>
|
#include <projectexplorer/gnumakeparser.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/gcctoolchain.h>
|
#include <projectexplorer/gcctoolchain.h>
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
@@ -30,10 +30,11 @@
|
|||||||
#include "nimproject.h"
|
#include "nimproject.h"
|
||||||
#include "nimtoolchain.h"
|
#include "nimtoolchain.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
|
||||||
#include <projectexplorer/ioutputparser.h>
|
#include <projectexplorer/ioutputparser.h>
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include "../nimconstants.h"
|
#include "../nimconstants.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
@@ -27,25 +27,32 @@
|
|||||||
#include "ansifilterparser.h"
|
#include "ansifilterparser.h"
|
||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
#include "buildstep.h"
|
#include "buildstep.h"
|
||||||
|
#include "ioutputparser.h"
|
||||||
|
#include "processparameters.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
#include <coreplugin/reaper.h>
|
#include <coreplugin/reaper.h>
|
||||||
|
|
||||||
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QPair>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const int CACHE_SOFT_LIMIT = 500;
|
const int CACHE_SOFT_LIMIT = 500;
|
||||||
const int CACHE_HARD_LIMIT = 1000;
|
const int CACHE_HARD_LIMIT = 1000;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ProjectExplorer::AbstractProcessStep
|
\class ProjectExplorer::AbstractProcessStep
|
||||||
@@ -91,14 +98,35 @@ using namespace ProjectExplorer;
|
|||||||
Should be used in init().
|
Should be used in init().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, Core::Id id) :
|
class AbstractProcessStep::Private
|
||||||
BuildStep(bsl, id)
|
|
||||||
{
|
{
|
||||||
m_timer.setInterval(500);
|
public:
|
||||||
connect(&m_timer, &QTimer::timeout, this, &AbstractProcessStep::checkForCancel);
|
QTimer m_timer;
|
||||||
|
QFutureInterface<bool> *m_futureInterface = nullptr;
|
||||||
|
std::unique_ptr<Utils::QtcProcess> m_process;
|
||||||
|
std::unique_ptr<IOutputParser> m_outputParserChain;
|
||||||
|
ProcessParameters m_param;
|
||||||
|
QHash<QString, QPair<Utils::FileName, quint64>> m_filesCache;
|
||||||
|
QHash<QString, Utils::FileNameList> m_candidates;
|
||||||
|
quint64 m_cacheCounter = 0;
|
||||||
|
bool m_ignoreReturnValue = false;
|
||||||
|
bool m_skipFlush = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, Core::Id id) :
|
||||||
|
BuildStep(bsl, id),
|
||||||
|
d(new Private)
|
||||||
|
{
|
||||||
|
d->m_timer.setInterval(500);
|
||||||
|
connect(&d->m_timer, &QTimer::timeout, this, &AbstractProcessStep::checkForCancel);
|
||||||
setRunInGuiThread(true);
|
setRunInGuiThread(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractProcessStep::~AbstractProcessStep()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Deletes all existing output parsers and starts a new chain with the
|
Deletes all existing output parsers and starts a new chain with the
|
||||||
given parser.
|
given parser.
|
||||||
@@ -108,11 +136,11 @@ AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, Core::Id id) :
|
|||||||
|
|
||||||
void AbstractProcessStep::setOutputParser(IOutputParser *parser)
|
void AbstractProcessStep::setOutputParser(IOutputParser *parser)
|
||||||
{
|
{
|
||||||
m_outputParserChain.reset(new AnsiFilterParser);
|
d->m_outputParserChain.reset(new AnsiFilterParser);
|
||||||
m_outputParserChain->appendOutputParser(parser);
|
d->m_outputParserChain->appendOutputParser(parser);
|
||||||
|
|
||||||
connect(m_outputParserChain.get(), &IOutputParser::addOutput, this, &AbstractProcessStep::outputAdded);
|
connect(d->m_outputParserChain.get(), &IOutputParser::addOutput, this, &AbstractProcessStep::outputAdded);
|
||||||
connect(m_outputParserChain.get(), &IOutputParser::addTask, this, &AbstractProcessStep::taskAdded);
|
connect(d->m_outputParserChain.get(), &IOutputParser::addTask, this, &AbstractProcessStep::taskAdded);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -123,13 +151,13 @@ void AbstractProcessStep::appendOutputParser(IOutputParser *parser)
|
|||||||
if (!parser)
|
if (!parser)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QTC_ASSERT(m_outputParserChain, return);
|
QTC_ASSERT(d->m_outputParserChain, return);
|
||||||
m_outputParserChain->appendOutputParser(parser);
|
d->m_outputParserChain->appendOutputParser(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
IOutputParser *AbstractProcessStep::outputParser() const
|
IOutputParser *AbstractProcessStep::outputParser() const
|
||||||
{
|
{
|
||||||
return m_outputParserChain.get();
|
return d->m_outputParserChain.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::emitFaultyConfigurationMessage()
|
void AbstractProcessStep::emitFaultyConfigurationMessage()
|
||||||
@@ -140,7 +168,7 @@ void AbstractProcessStep::emitFaultyConfigurationMessage()
|
|||||||
|
|
||||||
bool AbstractProcessStep::ignoreReturnValue()
|
bool AbstractProcessStep::ignoreReturnValue()
|
||||||
{
|
{
|
||||||
return m_ignoreReturnValue;
|
return d->m_ignoreReturnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -152,7 +180,7 @@ bool AbstractProcessStep::ignoreReturnValue()
|
|||||||
|
|
||||||
void AbstractProcessStep::setIgnoreReturnValue(bool b)
|
void AbstractProcessStep::setIgnoreReturnValue(bool b)
|
||||||
{
|
{
|
||||||
m_ignoreReturnValue = b;
|
d->m_ignoreReturnValue = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -164,12 +192,12 @@ bool AbstractProcessStep::init(QList<const BuildStep *> &earlierSteps)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(earlierSteps);
|
Q_UNUSED(earlierSteps);
|
||||||
|
|
||||||
m_candidates.clear();
|
d->m_candidates.clear();
|
||||||
const Utils::FileNameList fl = project()->files(Project::AllFiles);
|
const Utils::FileNameList fl = project()->files(Project::AllFiles);
|
||||||
for (const Utils::FileName &file : fl)
|
for (const Utils::FileName &file : fl)
|
||||||
m_candidates[file.fileName()].push_back(file);
|
d->m_candidates[file.fileName()].push_back(file);
|
||||||
|
|
||||||
return !m_process;
|
return !d->m_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -179,7 +207,7 @@ bool AbstractProcessStep::init(QList<const BuildStep *> &earlierSteps)
|
|||||||
|
|
||||||
void AbstractProcessStep::run(QFutureInterface<bool> &fi)
|
void AbstractProcessStep::run(QFutureInterface<bool> &fi)
|
||||||
{
|
{
|
||||||
QDir wd(m_param.effectiveWorkingDirectory());
|
QDir wd(d->m_param.effectiveWorkingDirectory());
|
||||||
if (!wd.exists()) {
|
if (!wd.exists()) {
|
||||||
if (!wd.mkpath(wd.absolutePath())) {
|
if (!wd.mkpath(wd.absolutePath())) {
|
||||||
emit addOutput(tr("Could not create directory \"%1\"")
|
emit addOutput(tr("Could not create directory \"%1\"")
|
||||||
@@ -190,51 +218,56 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString effectiveCommand = m_param.effectiveCommand();
|
QString effectiveCommand = d->m_param.effectiveCommand();
|
||||||
if (!QFileInfo::exists(effectiveCommand)) {
|
if (!QFileInfo::exists(effectiveCommand)) {
|
||||||
processStartupFailed();
|
processStartupFailed();
|
||||||
reportRunResult(fi, false);
|
reportRunResult(fi, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_futureInterface = &fi;
|
d->m_futureInterface = &fi;
|
||||||
|
|
||||||
m_process.reset(new Utils::QtcProcess());
|
d->m_process.reset(new Utils::QtcProcess());
|
||||||
m_process->setUseCtrlCStub(Utils::HostOsInfo::isWindowsHost());
|
d->m_process->setUseCtrlCStub(Utils::HostOsInfo::isWindowsHost());
|
||||||
m_process->setWorkingDirectory(wd.absolutePath());
|
d->m_process->setWorkingDirectory(wd.absolutePath());
|
||||||
m_process->setEnvironment(m_param.environment());
|
d->m_process->setEnvironment(d->m_param.environment());
|
||||||
m_process->setCommand(effectiveCommand, m_param.effectiveArguments());
|
d->m_process->setCommand(effectiveCommand, d->m_param.effectiveArguments());
|
||||||
|
|
||||||
connect(m_process.get(), &QProcess::readyReadStandardOutput,
|
connect(d->m_process.get(), &QProcess::readyReadStandardOutput,
|
||||||
this, &AbstractProcessStep::processReadyReadStdOutput);
|
this, &AbstractProcessStep::processReadyReadStdOutput);
|
||||||
connect(m_process.get(), &QProcess::readyReadStandardError,
|
connect(d->m_process.get(), &QProcess::readyReadStandardError,
|
||||||
this, &AbstractProcessStep::processReadyReadStdError);
|
this, &AbstractProcessStep::processReadyReadStdError);
|
||||||
connect(m_process.get(), static_cast<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished),
|
connect(d->m_process.get(), static_cast<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished),
|
||||||
this, &AbstractProcessStep::slotProcessFinished);
|
this, &AbstractProcessStep::slotProcessFinished);
|
||||||
|
|
||||||
m_process->start();
|
d->m_process->start();
|
||||||
if (!m_process->waitForStarted()) {
|
if (!d->m_process->waitForStarted()) {
|
||||||
processStartupFailed();
|
processStartupFailed();
|
||||||
m_process.reset();
|
d->m_process.reset();
|
||||||
m_outputParserChain.reset();
|
d->m_outputParserChain.reset();
|
||||||
reportRunResult(fi, false);
|
reportRunResult(fi, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processStarted();
|
processStarted();
|
||||||
m_timer.start();
|
d->m_timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessParameters *AbstractProcessStep::processParameters()
|
||||||
|
{
|
||||||
|
return &d->m_param;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::cleanUp(QProcess *process)
|
void AbstractProcessStep::cleanUp(QProcess *process)
|
||||||
{
|
{
|
||||||
// The process has finished, leftover data is read in processFinished
|
// The process has finished, leftover data is read in processFinished
|
||||||
processFinished(process->exitCode(), process->exitStatus());
|
processFinished(process->exitCode(), process->exitStatus());
|
||||||
const bool returnValue = processSucceeded(process->exitCode(), process->exitStatus()) || m_ignoreReturnValue;
|
const bool returnValue = processSucceeded(process->exitCode(), process->exitStatus()) || d->m_ignoreReturnValue;
|
||||||
|
|
||||||
m_outputParserChain.reset();
|
d->m_outputParserChain.reset();
|
||||||
m_process.reset();
|
d->m_process.reset();
|
||||||
|
|
||||||
// Report result
|
// Report result
|
||||||
reportRunResult(*m_futureInterface, returnValue);
|
reportRunResult(*d->m_futureInterface, returnValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -247,8 +280,8 @@ void AbstractProcessStep::cleanUp(QProcess *process)
|
|||||||
void AbstractProcessStep::processStarted()
|
void AbstractProcessStep::processStarted()
|
||||||
{
|
{
|
||||||
emit addOutput(tr("Starting: \"%1\" %2")
|
emit addOutput(tr("Starting: \"%1\" %2")
|
||||||
.arg(QDir::toNativeSeparators(m_param.effectiveCommand()),
|
.arg(QDir::toNativeSeparators(d->m_param.effectiveCommand()),
|
||||||
m_param.prettyArguments()),
|
d->m_param.prettyArguments()),
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
BuildStep::OutputFormat::NormalMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,10 +293,10 @@ void AbstractProcessStep::processStarted()
|
|||||||
|
|
||||||
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
|
||||||
{
|
{
|
||||||
if (m_outputParserChain)
|
if (d->m_outputParserChain)
|
||||||
m_outputParserChain->flush();
|
d->m_outputParserChain->flush();
|
||||||
|
|
||||||
QString command = QDir::toNativeSeparators(m_param.effectiveCommand());
|
QString command = QDir::toNativeSeparators(d->m_param.effectiveCommand());
|
||||||
if (status == QProcess::NormalExit && exitCode == 0) {
|
if (status == QProcess::NormalExit && exitCode == 0) {
|
||||||
emit addOutput(tr("The process \"%1\" exited normally.").arg(command),
|
emit addOutput(tr("The process \"%1\" exited normally.").arg(command),
|
||||||
BuildStep::OutputFormat::NormalMessage);
|
BuildStep::OutputFormat::NormalMessage);
|
||||||
@@ -285,10 +318,10 @@ void AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus sta
|
|||||||
void AbstractProcessStep::processStartupFailed()
|
void AbstractProcessStep::processStartupFailed()
|
||||||
{
|
{
|
||||||
emit addOutput(tr("Could not start process \"%1\" %2")
|
emit addOutput(tr("Could not start process \"%1\" %2")
|
||||||
.arg(QDir::toNativeSeparators(m_param.effectiveCommand()),
|
.arg(QDir::toNativeSeparators(d->m_param.effectiveCommand()),
|
||||||
m_param.prettyArguments()),
|
d->m_param.prettyArguments()),
|
||||||
BuildStep::OutputFormat::ErrorMessage);
|
BuildStep::OutputFormat::ErrorMessage);
|
||||||
m_timer.stop();
|
d->m_timer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -305,17 +338,17 @@ bool AbstractProcessStep::processSucceeded(int exitCode, QProcess::ExitStatus st
|
|||||||
|
|
||||||
void AbstractProcessStep::processReadyReadStdOutput()
|
void AbstractProcessStep::processReadyReadStdOutput()
|
||||||
{
|
{
|
||||||
if (!m_process)
|
if (!d->m_process)
|
||||||
return;
|
return;
|
||||||
m_process->setReadChannel(QProcess::StandardOutput);
|
d->m_process->setReadChannel(QProcess::StandardOutput);
|
||||||
BuildConfiguration *bc = buildConfiguration();
|
BuildConfiguration *bc = buildConfiguration();
|
||||||
if (!bc)
|
if (!bc)
|
||||||
bc = target()->activeBuildConfiguration();
|
bc = target()->activeBuildConfiguration();
|
||||||
const bool utf8Output = bc && bc->environment().hasKey("VSLANG");
|
const bool utf8Output = bc && bc->environment().hasKey("VSLANG");
|
||||||
|
|
||||||
while (m_process->canReadLine()) {
|
while (d->m_process->canReadLine()) {
|
||||||
QString line = utf8Output ? QString::fromUtf8(m_process->readLine())
|
QString line = utf8Output ? QString::fromUtf8(d->m_process->readLine())
|
||||||
: QString::fromLocal8Bit(m_process->readLine());
|
: QString::fromLocal8Bit(d->m_process->readLine());
|
||||||
stdOutput(line);
|
stdOutput(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,18 +361,18 @@ void AbstractProcessStep::processReadyReadStdOutput()
|
|||||||
|
|
||||||
void AbstractProcessStep::stdOutput(const QString &line)
|
void AbstractProcessStep::stdOutput(const QString &line)
|
||||||
{
|
{
|
||||||
if (m_outputParserChain)
|
if (d->m_outputParserChain)
|
||||||
m_outputParserChain->stdOutput(line);
|
d->m_outputParserChain->stdOutput(line);
|
||||||
emit addOutput(line, BuildStep::OutputFormat::Stdout, BuildStep::DontAppendNewline);
|
emit addOutput(line, BuildStep::OutputFormat::Stdout, BuildStep::DontAppendNewline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::processReadyReadStdError()
|
void AbstractProcessStep::processReadyReadStdError()
|
||||||
{
|
{
|
||||||
if (!m_process)
|
if (!d->m_process)
|
||||||
return;
|
return;
|
||||||
m_process->setReadChannel(QProcess::StandardError);
|
d->m_process->setReadChannel(QProcess::StandardError);
|
||||||
while (m_process->canReadLine()) {
|
while (d->m_process->canReadLine()) {
|
||||||
QString line = QString::fromLocal8Bit(m_process->readLine());
|
QString line = QString::fromLocal8Bit(d->m_process->readLine());
|
||||||
stdError(line);
|
stdError(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,22 +385,22 @@ void AbstractProcessStep::processReadyReadStdError()
|
|||||||
|
|
||||||
void AbstractProcessStep::stdError(const QString &line)
|
void AbstractProcessStep::stdError(const QString &line)
|
||||||
{
|
{
|
||||||
if (m_outputParserChain)
|
if (d->m_outputParserChain)
|
||||||
m_outputParserChain->stdError(line);
|
d->m_outputParserChain->stdError(line);
|
||||||
emit addOutput(line, BuildStep::OutputFormat::Stderr, BuildStep::DontAppendNewline);
|
emit addOutput(line, BuildStep::OutputFormat::Stderr, BuildStep::DontAppendNewline);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFutureInterface<bool> *AbstractProcessStep::futureInterface() const
|
QFutureInterface<bool> *AbstractProcessStep::futureInterface() const
|
||||||
{
|
{
|
||||||
return m_futureInterface;
|
return d->m_futureInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProcessStep::checkForCancel()
|
void AbstractProcessStep::checkForCancel()
|
||||||
{
|
{
|
||||||
if (m_futureInterface->isCanceled() && m_timer.isActive()) {
|
if (d->m_futureInterface->isCanceled() && d->m_timer.isActive()) {
|
||||||
m_timer.stop();
|
d->m_timer.stop();
|
||||||
|
|
||||||
Core::Reaper::reap(m_process.release());
|
Core::Reaper::reap(d->m_process.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,23 +408,23 @@ void AbstractProcessStep::taskAdded(const Task &task, int linkedOutputLines, int
|
|||||||
{
|
{
|
||||||
// Do not bother to report issues if we do not care about the results of
|
// Do not bother to report issues if we do not care about the results of
|
||||||
// the buildstep anyway:
|
// the buildstep anyway:
|
||||||
if (m_ignoreReturnValue)
|
if (d->m_ignoreReturnValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// flush out any pending tasks before proceeding:
|
// flush out any pending tasks before proceeding:
|
||||||
if (!m_skipFlush && m_outputParserChain) {
|
if (!d->m_skipFlush && d->m_outputParserChain) {
|
||||||
m_skipFlush = true;
|
d->m_skipFlush = true;
|
||||||
m_outputParserChain->flush();
|
d->m_outputParserChain->flush();
|
||||||
m_skipFlush = false;
|
d->m_skipFlush = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task editable(task);
|
Task editable(task);
|
||||||
QString filePath = task.file.toString();
|
QString filePath = task.file.toString();
|
||||||
|
|
||||||
auto it = m_filesCache.find(filePath);
|
auto it = d->m_filesCache.find(filePath);
|
||||||
if (it != m_filesCache.end()) {
|
if (it != d->m_filesCache.end()) {
|
||||||
editable.file = it.value().first;
|
editable.file = it.value().first;
|
||||||
it.value().second = ++m_cacheCounter;
|
it.value().second = ++d->m_cacheCounter;
|
||||||
} else if (!filePath.isEmpty() && !filePath.startsWith('<') && !QDir::isAbsolutePath(filePath)) {
|
} else if (!filePath.isEmpty() && !filePath.startsWith('<') && !QDir::isAbsolutePath(filePath)) {
|
||||||
// We have no save way to decide which file in which subfolder
|
// We have no save way to decide which file in which subfolder
|
||||||
// is meant. Therefore we apply following heuristics:
|
// is meant. Therefore we apply following heuristics:
|
||||||
@@ -400,7 +433,7 @@ void AbstractProcessStep::taskAdded(const Task &task, int linkedOutputLines, int
|
|||||||
// 3. give up.
|
// 3. give up.
|
||||||
|
|
||||||
QString sourceFilePath = filePath;
|
QString sourceFilePath = filePath;
|
||||||
Utils::FileNameList possibleFiles = m_candidates.value(Utils::FileName::fromString(filePath).fileName());
|
Utils::FileNameList possibleFiles = d->m_candidates.value(Utils::FileName::fromString(filePath).fileName());
|
||||||
|
|
||||||
if (possibleFiles.count() == 1) {
|
if (possibleFiles.count() == 1) {
|
||||||
editable.file = possibleFiles.first();
|
editable.file = possibleFiles.first();
|
||||||
@@ -437,9 +470,9 @@ void AbstractProcessStep::outputAdded(const QString &string, BuildStep::OutputFo
|
|||||||
|
|
||||||
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
||||||
{
|
{
|
||||||
m_timer.stop();
|
d->m_timer.stop();
|
||||||
|
|
||||||
QProcess *process = m_process.get();
|
QProcess *process = d->m_process.get();
|
||||||
if (!process) // Happens when the process was canceled and handed over to the Reaper.
|
if (!process) // Happens when the process was canceled and handed over to the Reaper.
|
||||||
process = qobject_cast<QProcess *>(sender()); // The process was canceled!
|
process = qobject_cast<QProcess *>(sender()); // The process was canceled!
|
||||||
|
|
||||||
@@ -458,11 +491,11 @@ void AbstractProcessStep::slotProcessFinished(int, QProcess::ExitStatus)
|
|||||||
void AbstractProcessStep::purgeCache(bool useSoftLimit)
|
void AbstractProcessStep::purgeCache(bool useSoftLimit)
|
||||||
{
|
{
|
||||||
const int limit = useSoftLimit ? CACHE_SOFT_LIMIT : CACHE_HARD_LIMIT;
|
const int limit = useSoftLimit ? CACHE_SOFT_LIMIT : CACHE_HARD_LIMIT;
|
||||||
if (m_filesCache.size() <= limit)
|
if (d->m_filesCache.size() <= limit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const quint64 minCounter = m_cacheCounter - static_cast<quint64>(limit);
|
const quint64 minCounter = d->m_cacheCounter - static_cast<quint64>(limit);
|
||||||
std::remove_if(m_filesCache.begin(), m_filesCache.end(),
|
std::remove_if(d->m_filesCache.begin(), d->m_filesCache.end(),
|
||||||
[minCounter](const QPair<Utils::FileName, quint64> &entry) {
|
[minCounter](const QPair<Utils::FileName, quint64> &entry) {
|
||||||
return entry.second <= minCounter;
|
return entry.second <= minCounter;
|
||||||
});
|
});
|
||||||
@@ -471,5 +504,7 @@ void AbstractProcessStep::purgeCache(bool useSoftLimit)
|
|||||||
void AbstractProcessStep::insertInCache(const QString &relativePath, const Utils::FileName &absPath)
|
void AbstractProcessStep::insertInCache(const QString &relativePath, const Utils::FileName &absPath)
|
||||||
{
|
{
|
||||||
purgeCache(false);
|
purgeCache(false);
|
||||||
m_filesCache.insert(relativePath, qMakePair(absPath, ++m_cacheCounter));
|
d->m_filesCache.insert(relativePath, qMakePair(absPath, ++d->m_cacheCounter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace ProjectExplorer
|
||||||
|
@@ -26,24 +26,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "buildstep.h"
|
#include "buildstep.h"
|
||||||
#include "processparameters.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/ioutputparser.h>
|
#include <QProcess>
|
||||||
|
|
||||||
#include <utils/qtcprocess.h>
|
namespace Utils { class FileName; }
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QHash>
|
|
||||||
#include <QPair>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace Utils { class QtcProcess; }
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
class IOutputParser;
|
class IOutputParser;
|
||||||
|
class ProcessParameters;
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
class PROJECTEXPLORER_EXPORT AbstractProcessStep : public BuildStep
|
class PROJECTEXPLORER_EXPORT AbstractProcessStep : public BuildStep
|
||||||
@@ -54,7 +44,7 @@ public:
|
|||||||
bool init(QList<const BuildStep *> &earlierSteps) override;
|
bool init(QList<const BuildStep *> &earlierSteps) override;
|
||||||
void run(QFutureInterface<bool> &) override;
|
void run(QFutureInterface<bool> &) override;
|
||||||
|
|
||||||
ProcessParameters *processParameters() { return &m_param; }
|
ProcessParameters *processParameters();
|
||||||
|
|
||||||
bool ignoreReturnValue();
|
bool ignoreReturnValue();
|
||||||
void setIgnoreReturnValue(bool b);
|
void setIgnoreReturnValue(bool b);
|
||||||
@@ -67,6 +57,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
AbstractProcessStep(BuildStepList *bsl, Core::Id id);
|
AbstractProcessStep(BuildStepList *bsl, Core::Id id);
|
||||||
|
~AbstractProcessStep();
|
||||||
|
|
||||||
virtual void processStarted();
|
virtual void processStarted();
|
||||||
virtual void processFinished(int exitCode, QProcess::ExitStatus status);
|
virtual void processFinished(int exitCode, QProcess::ExitStatus status);
|
||||||
@@ -92,16 +83,8 @@ private:
|
|||||||
void purgeCache(bool useSoftLimit);
|
void purgeCache(bool useSoftLimit);
|
||||||
void insertInCache(const QString &relativePath, const Utils::FileName &absPath);
|
void insertInCache(const QString &relativePath, const Utils::FileName &absPath);
|
||||||
|
|
||||||
QTimer m_timer;
|
class Private;
|
||||||
QFutureInterface<bool> *m_futureInterface = nullptr;
|
Private *d;
|
||||||
std::unique_ptr<Utils::QtcProcess> m_process;
|
|
||||||
std::unique_ptr<IOutputParser> m_outputParserChain;
|
|
||||||
ProcessParameters m_param;
|
|
||||||
QHash<QString, QPair<Utils::FileName, quint64>> m_filesCache;
|
|
||||||
QHash<QString, Utils::FileNameList> m_candidates;
|
|
||||||
quint64 m_cacheCounter = 0;
|
|
||||||
bool m_ignoreReturnValue = false;
|
|
||||||
bool m_skipFlush = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "gnumakeparser.h"
|
#include "gnumakeparser.h"
|
||||||
#include "kitinformation.h"
|
#include "kitinformation.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
|
#include "processparameters.h"
|
||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <coreplugin/variablechooser.h>
|
#include <coreplugin/variablechooser.h>
|
||||||
|
#include <utils/environment.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QListWidgetItem);
|
QT_FORWARD_DECLARE_CLASS(QListWidgetItem);
|
||||||
|
|
||||||
|
namespace Utils { class Environment; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "processstep.h"
|
#include "processstep.h"
|
||||||
#include "buildstep.h"
|
#include "buildstep.h"
|
||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
|
#include "processparameters.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "kit.h"
|
#include "kit.h"
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/gnumakeparser.h>
|
#include <projectexplorer/gnumakeparser.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/xcodebuildparser.h>
|
#include <projectexplorer/xcodebuildparser.h>
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include <projectexplorer/buildmanager.h>
|
#include <projectexplorer/buildmanager.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/gnumakeparser.h>
|
#include <projectexplorer/gnumakeparser.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Utils { class FileName; }
|
namespace Utils { class FileName; }
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <projectexplorer/buildtargetinfo.h>
|
#include <projectexplorer/buildtargetinfo.h>
|
||||||
#include <projectexplorer/deployablefile.h>
|
#include <projectexplorer/deployablefile.h>
|
||||||
#include <projectexplorer/deploymentdata.h>
|
#include <projectexplorer/deploymentdata.h>
|
||||||
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user