forked from qt-creator/qt-creator
QMakeStep: Use TaskTree for running qmake step
Change-Id: I8737a0fe3f8857db4e171001a73adde842d05d44 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -178,7 +178,6 @@ bool QMakeStep::init()
|
||||
if (!AbstractProcessStep::init())
|
||||
return false;
|
||||
|
||||
m_wasSuccess = true;
|
||||
QmakeBuildConfiguration *qmakeBc = qmakeBuildConfiguration();
|
||||
const QtVersion *qtVersion = QtKitAspect::qtVersion(kit());
|
||||
|
||||
@@ -283,10 +282,65 @@ void QMakeStep::doRun()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkWorkingDirectory())
|
||||
return;
|
||||
|
||||
m_needToRunQMake = false;
|
||||
|
||||
m_nextState = State::RUN_QMAKE;
|
||||
runNextCommand();
|
||||
using namespace Tasking;
|
||||
|
||||
const auto setupQMake = [this](QtcProcess &process) {
|
||||
m_outputFormatter->setLineParsers({new QMakeParser});
|
||||
ProcessParameters *pp = processParameters();
|
||||
pp->setCommandLine(m_qmakeCommand);
|
||||
setupProcess(&process);
|
||||
};
|
||||
|
||||
const auto setupMakeQMake = [this](QtcProcess &process) {
|
||||
auto *parser = new GnuMakeParser;
|
||||
parser->addSearchDir(processParameters()->workingDirectory());
|
||||
m_outputFormatter->setLineParsers({parser});
|
||||
ProcessParameters *pp = processParameters();
|
||||
pp->setCommandLine(m_makeCommand);
|
||||
setupProcess(&process);
|
||||
};
|
||||
|
||||
const auto onDone = [this](const QtcProcess &) {
|
||||
const QString command = displayedParameters()->effectiveCommand().toUserOutput();
|
||||
emit addOutput(Tr::tr("The process \"%1\" exited normally.").arg(command),
|
||||
OutputFormat::NormalMessage);
|
||||
};
|
||||
|
||||
const auto onError = [this](const QtcProcess &process) {
|
||||
const QString command = displayedParameters()->effectiveCommand().toUserOutput();
|
||||
if (process.result() == ProcessResult::FinishedWithError) {
|
||||
emit addOutput(Tr::tr("The process \"%1\" exited with code %2.")
|
||||
.arg(command, QString::number(process.exitCode())),
|
||||
OutputFormat::ErrorMessage);
|
||||
} else if (process.result() == ProcessResult::StartFailed) {
|
||||
emit addOutput(Tr::tr("Could not start process \"%1\" %2.")
|
||||
.arg(command, displayedParameters()->prettyArguments()),
|
||||
OutputFormat::ErrorMessage);
|
||||
const QString errorString = process.errorString();
|
||||
if (!errorString.isEmpty())
|
||||
emit addOutput(errorString, OutputFormat::ErrorMessage);
|
||||
} else {
|
||||
emit addOutput(Tr::tr("The process \"%1\" crashed.").arg(command),
|
||||
OutputFormat::ErrorMessage);
|
||||
}
|
||||
m_needToRunQMake = true;
|
||||
};
|
||||
|
||||
const auto onGroupDone = [this] {
|
||||
emit buildConfiguration()->buildDirectoryInitialized();
|
||||
};
|
||||
|
||||
QList<TaskItem> processList = {Process(setupQMake, onDone, onError)};
|
||||
if (m_runMakeQmake)
|
||||
processList << Process(setupMakeQMake, onDone, onError);
|
||||
processList << OnGroupDone(onGroupDone);
|
||||
|
||||
runTaskTree(Group(processList));
|
||||
}
|
||||
|
||||
void QMakeStep::setForced(bool b)
|
||||
@@ -294,61 +348,6 @@ void QMakeStep::setForced(bool b)
|
||||
m_forced = b;
|
||||
}
|
||||
|
||||
void QMakeStep::finish(ProcessResult result)
|
||||
{
|
||||
if (result != ProcessResult::StartFailed)
|
||||
emit buildConfiguration()->buildDirectoryInitialized();
|
||||
|
||||
if (result != ProcessResult::FinishedWithSuccess)
|
||||
m_needToRunQMake = true;
|
||||
|
||||
m_wasSuccess = isSuccess(result);
|
||||
runNextCommand();
|
||||
}
|
||||
|
||||
void QMakeStep::startOneCommand(const CommandLine &command)
|
||||
{
|
||||
ProcessParameters *pp = processParameters();
|
||||
pp->setCommandLine(command);
|
||||
|
||||
AbstractProcessStep::doRun();
|
||||
}
|
||||
|
||||
void QMakeStep::runNextCommand()
|
||||
{
|
||||
if (isCanceled())
|
||||
m_wasSuccess = false;
|
||||
|
||||
if (!m_wasSuccess)
|
||||
m_nextState = State::POST_PROCESS;
|
||||
|
||||
emit progress(static_cast<int>(m_nextState) * 100 / static_cast<int>(State::POST_PROCESS),
|
||||
QString());
|
||||
|
||||
switch (m_nextState) {
|
||||
case State::IDLE:
|
||||
return;
|
||||
case State::RUN_QMAKE:
|
||||
m_outputFormatter->setLineParsers({new QMakeParser});
|
||||
m_nextState = (m_runMakeQmake ? State::RUN_MAKE_QMAKE_ALL : State::POST_PROCESS);
|
||||
startOneCommand(m_qmakeCommand);
|
||||
return;
|
||||
case State::RUN_MAKE_QMAKE_ALL:
|
||||
{
|
||||
auto *parser = new GnuMakeParser;
|
||||
parser->addSearchDir(processParameters()->workingDirectory());
|
||||
m_outputFormatter->setLineParsers({parser});
|
||||
m_nextState = State::POST_PROCESS;
|
||||
startOneCommand(m_makeCommand);
|
||||
}
|
||||
return;
|
||||
case State::POST_PROCESS:
|
||||
m_nextState = State::IDLE;
|
||||
emit finished(m_wasSuccess);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QMakeStep::setUserArguments(const QString &arguments)
|
||||
{
|
||||
m_userArgs->setArguments(arguments);
|
||||
|
@@ -139,11 +139,6 @@ protected:
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
|
||||
private:
|
||||
void finish(Utils::ProcessResult result) override;
|
||||
|
||||
void startOneCommand(const Utils::CommandLine &command);
|
||||
void runNextCommand();
|
||||
|
||||
// slots for handling buildconfiguration/step signals
|
||||
void qtVersionChanged();
|
||||
void qmakeBuildConfigChanged();
|
||||
@@ -171,9 +166,6 @@ private:
|
||||
QStringList m_extraParserArgs;
|
||||
|
||||
// last values
|
||||
enum class State { IDLE = 0, RUN_QMAKE, RUN_MAKE_QMAKE_ALL, POST_PROCESS };
|
||||
bool m_wasSuccess = true;
|
||||
State m_nextState = State::IDLE;
|
||||
bool m_forced = false;
|
||||
bool m_needToRunQMake = false; // set in init(), read in run()
|
||||
|
||||
|
Reference in New Issue
Block a user