Commit 3d863b21 authored by dt's avatar dt

Show progress for building cmake projects.

Parse percent output of cmake, report via QtConcurrent and modify the
BuildManager to also report the progress to the ProgressManager.
parent dee34912
......@@ -50,6 +50,7 @@ using namespace CMakeProjectManager::Internal;
MakeStep::MakeStep(CMakeProject *pro)
: AbstractProcessStep(pro), m_pro(pro), m_buildParser(0)
{
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
}
MakeStep::~MakeStep()
......@@ -107,7 +108,10 @@ bool MakeStep::init(const QString &buildConfiguration)
void MakeStep::run(QFutureInterface<bool> &fi)
{
m_futureInterface = &fi;
m_futureInterface->setProgressRange(0, 100);
AbstractProcessStep::run(fi);
m_futureInterface = 0;
}
QString MakeStep::name()
......@@ -134,6 +138,12 @@ void MakeStep::stdOut(const QString &line)
{
if (m_buildParser)
m_buildParser->stdOutput(line);
if (m_percentProgress.indexIn(line) != -1) {
bool ok = false;
int percent = m_percentProgress.cap(1).toInt(&ok);;
if (ok)
m_futureInterface->setProgressValue(percent);
}
AbstractProcessStep::stdOut(line);
}
......
......@@ -73,6 +73,8 @@ private:
CMakeProject *m_pro;
ProjectExplorer::BuildParserInterface *m_buildParser;
QSet<QString> m_openDirectories;
QRegExp m_percentProgress;
QFutureInterface<bool> *m_futureInterface;
};
class MakeStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget
......
......@@ -65,6 +65,11 @@ BuildManager::BuildManager(ProjectExplorerPlugin *parent)
connect(&m_watcher, SIGNAL(finished()),
this, SLOT(nextBuildQueue()));
connect(&m_watcher, SIGNAL(progressValueChanged(int)),
this, SLOT(progressChanged()));
connect(&m_watcher, SIGNAL(progressRangeChanged(int, int)),
this, SLOT(progressChanged()));
m_outputWindow = new CompileOutputWindow(this);
pm->addObject(m_outputWindow);
......@@ -115,7 +120,7 @@ void BuildManager::cancel()
this, SLOT(addToOutputWindow(QString)));
decrementActiveBuildSteps(m_currentBuildStep->project());
m_progressFutureInterface->setProgressValueAndText(m_progress, "Build canceled"); //TODO NBS fix in qtconcurrent
m_progressFutureInterface->setProgressValueAndText(m_progress*100, "Build canceled"); //TODO NBS fix in qtconcurrent
clearBuildQueue();
}
return;
......@@ -184,7 +189,7 @@ void BuildManager::startBuildQueue()
connect(progress, SIGNAL(clicked()), this, SLOT(showBuildResults()));
progress->setWidget(new BuildProgress(m_taskWindow));
m_progress = 0;
m_progressFutureInterface->setProgressRange(0, m_maxProgress);
m_progressFutureInterface->setProgressRange(0, m_maxProgress * 100);
m_running = true;
m_canceling = false;
......@@ -194,9 +199,9 @@ void BuildManager::startBuildQueue()
nextStep();
} else {
// Already running
m_progressFutureInterface->setProgressRange(0, m_maxProgress);
m_progressFutureInterface->setProgressRange(0, m_maxProgress * 100);
const QString &progressText = tr("Finished %1 of %2 build steps").arg(m_progress).arg(m_maxProgress);
m_progressFutureInterface->setProgressValueAndText(m_progress, progressText);
m_progressFutureInterface->setProgressValueAndText(m_progress*100, progressText);
}
}
......@@ -231,7 +236,7 @@ void BuildManager::nextBuildQueue()
++m_progress;
const QString &progressText = tr("Finished %1 of %2 build steps").arg(m_progress).arg(m_maxProgress);
m_progressFutureInterface->setProgressValueAndText(m_progress, progressText);
m_progressFutureInterface->setProgressValueAndText(m_progress*100, progressText);
bool result = m_watcher.result();
if (!result) {
......@@ -239,7 +244,7 @@ void BuildManager::nextBuildQueue()
addToOutputWindow(tr("<font color=\"#ff0000\">Error while building project %1</font>").arg(m_currentBuildStep->project()->name()));
addToOutputWindow(tr("<font color=\"#ff0000\">When executing build step '%1'</font>").arg(m_currentBuildStep->displayName()));
// NBS TODO fix in qtconcurrent
m_progressFutureInterface->setProgressValueAndText(m_progress, tr("Error while building project %1").arg(m_currentBuildStep->project()->name()));
m_progressFutureInterface->setProgressValueAndText(m_progress*100, tr("Error while building project %1").arg(m_currentBuildStep->project()->name()));
}
decrementActiveBuildSteps(m_currentBuildStep->project());
......@@ -249,6 +254,17 @@ void BuildManager::nextBuildQueue()
clearBuildQueue();
}
void BuildManager::progressChanged()
{
if (!m_progressFutureInterface)
return;
int range = m_watcher.progressMaximum() - m_watcher.progressMinimum();
if (range != 0) {
int percent = (m_watcher.progressValue() - m_watcher.progressMinimum()) * 100 / range;
m_progressFutureInterface->setProgressValue(m_progress * 100 + percent);
}
}
void BuildManager::nextStep()
{
if (!m_buildQueue.empty()) {
......@@ -279,8 +295,9 @@ void BuildManager::nextStep()
m_watcher.setFuture(QtConcurrent::run(&BuildStep::run, m_currentBuildStep));
} else {
m_running = false;
m_previousBuildStepProject = 0;
m_previousBuildStepProject = 0;
m_progressFutureInterface->reportFinished();
m_progressWatcher.setFuture(QFuture<void>());
delete m_progressFutureInterface;
m_progressFutureInterface = 0;
m_maxProgress = 0;
......
......@@ -97,6 +97,7 @@ private slots:
void addToOutputWindow(const QString &string);
void nextBuildQueue();
void progressChanged();
void emitCancelMessage();
void showBuildResults();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment