diff --git a/src/plugins/projectexplorer/makestep.cpp b/src/plugins/projectexplorer/makestep.cpp index 76fabcbf213..5dca5676805 100644 --- a/src/plugins/projectexplorer/makestep.cpp +++ b/src/plugins/projectexplorer/makestep.cpp @@ -78,9 +78,7 @@ bool MakeStep::init(QList &earlierSteps) ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setWorkingDirectory(bc->buildDirectory().toString()); - Utils::Environment env = bc->environment(); - Utils::Environment::setupEnglishOutput(&env); - pp->setEnvironment(env); + pp->setEnvironment(environment(bc)); pp->setCommand(make); pp->setArguments(allArguments()); pp->resolveAll(); @@ -119,7 +117,7 @@ QString MakeStep::defaultMakeCommand() const BuildConfiguration *bc = buildConfiguration(); ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (bc && tc) - return tc->makeCommand(bc->environment()); + return tc->makeCommand(environment(bc)); return QString(); } @@ -137,6 +135,23 @@ Task MakeStep::makeCommandMissingTask() Constants::TASK_CATEGORY_BUILDSYSTEM); } +Utils::Environment MakeStep::environment(BuildConfiguration *bc) const +{ + Utils::Environment env = bc ? bc->environment() : Utils::Environment::systemEnvironment(); + Utils::Environment::setupEnglishOutput(&env); + if (makeCommand().isEmpty()) { + // We also prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose + ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), + ProjectExplorer::Constants::CXX_LANGUAGE_ID); + if (tc && tc->targetAbi().os() == Abi::WindowsOS + && tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) { + const QString makeFlags = "MAKEFLAGS"; + env.set(makeFlags, 'L' + env.value(makeFlags)); + } + } + return env; +} + void MakeStep::setMakeCommand(const QString &command) { m_makeCommand = command; @@ -305,8 +320,6 @@ void MakeStepConfigWidget::setSummaryText(const QString &text) void MakeStepConfigWidget::updateDetails() { - ToolChain *tc - = ToolChainKitInformation::toolChain(m_makeStep->target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID); BuildConfiguration *bc = m_makeStep->buildConfiguration(); const QString defaultMake = m_makeStep->defaultMakeCommand(); @@ -329,19 +342,8 @@ void MakeStepConfigWidget::updateDetails() param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(m_makeStep->effectiveMakeCommand()); - Utils::Environment env = bc->environment(); - Utils::Environment::setupEnglishOutput(&env); - // We prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose - // FIXME doing this without the user having a way to override this is rather bad - if (tc && m_makeStep->makeCommand().isEmpty()) { - if (tc->targetAbi().os() == Abi::WindowsOS - && tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) { - const QString makeFlags = "MAKEFLAGS"; - env.set(makeFlags, 'L' + env.value(makeFlags)); - } - } param.setArguments(m_makeStep->allArguments()); - param.setEnvironment(env); + param.setEnvironment(m_makeStep->environment(bc)); if (param.commandMissing()) setSummaryText(tr("Make: %1 not found in the environment.").arg(param.command())); // Override display text diff --git a/src/plugins/projectexplorer/makestep.h b/src/plugins/projectexplorer/makestep.h index e4ebe14c46e..9fd5f99cf1b 100644 --- a/src/plugins/projectexplorer/makestep.h +++ b/src/plugins/projectexplorer/makestep.h @@ -68,6 +68,8 @@ public: static QString msgNoMakeCommand(); static Task makeCommandMissingTask(); + Utils::Environment environment(BuildConfiguration *bc) const; + private: QVariantMap toMap() const override; bool fromMap(const QVariantMap &map) override; diff --git a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp index 9e826385405..4cf4d123279 100644 --- a/src/plugins/qmakeprojectmanager/qmakemakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakemakestep.cpp @@ -151,24 +151,13 @@ bool QmakeMakeStep::init(QList &earlierSteps) subProFile->objectExtension(); Utils::QtcProcess::addArg(&args, objectFile); } - Utils::Environment env = bc->environment(); - Utils::Environment::setupEnglishOutput(&env); - // We also prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose - ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), - ProjectExplorer::Constants::CXX_LANGUAGE_ID); - if (tc && makeCommand().isEmpty()) { - if (tc->targetAbi().os() == Abi::WindowsOS - && tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor) { - const QString makeFlags = "MAKEFLAGS"; - env.set(makeFlags, 'L' + env.value(makeFlags)); - } - } - - pp->setEnvironment(env); + pp->setEnvironment(environment(bc)); pp->setArguments(args); pp->resolveAll(); setOutputParser(new ProjectExplorer::GnuMakeParser()); + ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), + ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (tc && tc->targetAbi().os() == Abi::DarwinOS) appendOutputParser(new XcodebuildParser); IOutputParser *parser = target()->kit()->createOutputParser();