forked from qt-creator/qt-creator
MakeSteps: Unify environment code
Cleaning up a mess with different environments being used at different places. Change-Id: I038c440c78e7c195d0154d1642d2573af56008b2 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -78,9 +78,7 @@ bool MakeStep::init(QList<const BuildStep *> &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("<b>Make:</b> %1 not found in the environment.").arg(param.command())); // Override display text
|
||||
|
@@ -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;
|
||||
|
@@ -151,24 +151,13 @@ bool QmakeMakeStep::init(QList<const BuildStep *> &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();
|
||||
|
Reference in New Issue
Block a user