Skip to content

Commit

Permalink
Add build task percentage output
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Sep 6, 2016
1 parent 6050149 commit d80d75a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
28 changes: 28 additions & 0 deletions src/project_manager/ros_make_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void ROSMakeStep::ctor()
{
setDefaultDisplayName(QCoreApplication::translate("ROSProjectManager::Internal::ROSMakeStep",
ROS_MS_DISPLAY_NAME));

m_percentProgress = QRegExp(QLatin1String("\\[\\s{0,2}(\\d{1,3})%\\]")); // Example: [ 82%] [ 82%] [ 87%]
}

ROSBuildConfiguration *ROSMakeStep::rosBuildConfiguration() const
Expand Down Expand Up @@ -196,6 +198,32 @@ void ROSMakeStep::run(QFutureInterface<bool> &fi)
AbstractProcessStep::run(fi);
}

void ROSMakeStep::processStarted()
{
futureInterface()->setProgressRange(0, 100);
AbstractProcessStep::processStarted();
}

void ROSMakeStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
AbstractProcessStep::processFinished(exitCode, status);
futureInterface()->setProgressValue(100);
}

void ROSMakeStep::stdOutput(const QString &line)
{
AbstractProcessStep::stdOutput(line);
int pos = 0;
while ((pos = m_percentProgress.indexIn(line, pos)) != -1) {
bool ok = false;
int percent = m_percentProgress.cap(1).toInt(&ok);
if (ok)
futureInterface()->setProgressValue(percent);

pos += m_percentProgress.matchedLength();
}
}

BuildStepConfigWidget *ROSMakeStep::createConfigWidget()
{
return new ROSMakeStepConfigWidget(this);
Expand Down
17 changes: 11 additions & 6 deletions src/project_manager/ros_make_step.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class ROSMakeStep : public ProjectExplorer::AbstractProcessStep
ROSMakeStep(ProjectExplorer::BuildStepList *parent);
~ROSMakeStep();

bool init(QList<const BuildStep *> &earlierSteps);
void run(QFutureInterface<bool> &fi);
ROSBuildConfiguration *rosBuildConfiguration() const;
bool init(QList<const BuildStep *> &earlierSteps) override;
void run(QFutureInterface<bool> &fi) override;
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
bool immutable() const override;

ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
bool immutable() const;
ROSBuildConfiguration *rosBuildConfiguration() const;
bool buildsTarget(const QString &target) const;
void setBuildTarget(const QString &target, bool on);
QString allArguments(QString initial_arguments) const;
Expand All @@ -66,7 +66,11 @@ class ROSMakeStep : public ProjectExplorer::AbstractProcessStep
ROSMakeStep(ProjectExplorer::BuildStepList *parent, ROSMakeStep *bs);
ROSMakeStep(ProjectExplorer::BuildStepList *parent, Core::Id id);
QStringList automaticallyAddedArguments() const;
bool fromMap(const QVariantMap &map);
bool fromMap(const QVariantMap &map) override;

void stdOutput(const QString &line) override;
void processStarted() override;
void processFinished(int exitCode, QProcess::ExitStatus status) override;

private:
void ctor();
Expand All @@ -75,6 +79,7 @@ class ROSMakeStep : public ProjectExplorer::AbstractProcessStep
QStringList m_buildTargets;
QString m_makeArguments;
QString m_makeCommand;
QRegExp m_percentProgress;
bool m_clean;
};

Expand Down

0 comments on commit d80d75a

Please sign in to comment.