CMake: Use new AbstractProcessStep convenience functions

This is actually a slight change in behavior insofar as
the summary now uses the same environment as the build
itself. This should not matter, or even be more correct.

Change-Id: I48e5be6cb7b97606f80f563ba399c4b6ff61c3bf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2020-08-13 16:48:44 +02:00
parent 1d6779f185
commit e1d0b4cf48
2 changed files with 10 additions and 12 deletions

View File

@@ -50,6 +50,7 @@
#include <QRegularExpression>
using namespace ProjectExplorer;
using namespace Utils;
namespace CMakeProjectManager {
namespace Internal {
@@ -136,7 +137,6 @@ static bool isCurrentExecutableTarget(const QString &target)
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
AbstractProcessStep(bsl, id)
{
m_ninjaProgressString = "[%f/%t "; // ninja: [33/100
//: Default display name for the cmake make step.
setDefaultDisplayName(tr("CMake Build"));
@@ -146,6 +146,13 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
setLowPriority();
setEnvironmentModifier([](Environment &env) {
const QString ninjaProgressString = "[%f/%t "; // ninja: [33/100
Environment::setupEnglishOutput(&env);
if (!env.expandedValueForKey("NINJA_STATUS").startsWith(ninjaProgressString))
env.set("NINJA_STATUS", ninjaProgressString + "%o/sec] ");
});
connect(target(), &Target::parsingFinished,
this, &CMakeBuildStep::handleBuildTargetsChanges);
}
@@ -241,13 +248,7 @@ bool CMakeBuildStep::init()
setIgnoreReturnValue(m_buildTargets == QStringList(CMakeBuildStep::cleanTarget()));
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
Utils::Environment env = bc->environment();
Utils::Environment::setupEnglishOutput(&env);
if (!env.expandedValueForKey("NINJA_STATUS").startsWith(m_ninjaProgressString))
env.set("NINJA_STATUS", m_ninjaProgressString + "%o/sec] ");
pp->setEnvironment(env);
pp->setWorkingDirectory(bc->buildDirectory());
setupProcessParameters(pp);
pp->setCommandLine(cmakeCommand(rc));
pp->resolveAll();
@@ -568,9 +569,7 @@ void CMakeBuildStepConfigWidget::updateBuildTargets()
void CMakeBuildStepConfigWidget::updateDetails()
{
ProcessParameters param;
param.setMacroExpander(m_buildStep->macroExpander());
param.setEnvironment(m_buildStep->buildEnvironment());
param.setWorkingDirectory(m_buildStep->buildDirectory());
m_buildStep->setupProcessParameters(&param);
param.setCommandLine(m_buildStep->cmakeCommand(nullptr));
setSummaryText(param.summary(displayName()));