From e1d0b4cf48cf7d5f4e1869b945b86f9fb48333d9 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 13 Aug 2020 16:48:44 +0200 Subject: [PATCH] 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 --- .../cmakeprojectmanager/cmakebuildstep.cpp | 21 +++++++++---------- .../cmakeprojectmanager/cmakebuildstep.h | 1 - 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 5f0aed90112..c8428ee278b 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -50,6 +50,7 @@ #include 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(¶m); param.setCommandLine(m_buildStep->cmakeCommand(nullptr)); setSummaryText(param.summary(displayName())); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.h b/src/plugins/cmakeprojectmanager/cmakebuildstep.h index a2e12aee1b8..960fc7b7264 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.h @@ -96,7 +96,6 @@ private: QMetaObject::Connection m_runTrigger; - QString m_ninjaProgressString; QStringList m_buildTargets; QString m_cmakeArguments; QString m_toolArguments;