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();
|
ProcessParameters *pp = processParameters();
|
||||||
pp->setMacroExpander(bc->macroExpander());
|
pp->setMacroExpander(bc->macroExpander());
|
||||||
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
pp->setWorkingDirectory(bc->buildDirectory().toString());
|
||||||
Utils::Environment env = bc->environment();
|
pp->setEnvironment(environment(bc));
|
||||||
Utils::Environment::setupEnglishOutput(&env);
|
|
||||||
pp->setEnvironment(env);
|
|
||||||
pp->setCommand(make);
|
pp->setCommand(make);
|
||||||
pp->setArguments(allArguments());
|
pp->setArguments(allArguments());
|
||||||
pp->resolveAll();
|
pp->resolveAll();
|
||||||
@@ -119,7 +117,7 @@ QString MakeStep::defaultMakeCommand() const
|
|||||||
BuildConfiguration *bc = buildConfiguration();
|
BuildConfiguration *bc = buildConfiguration();
|
||||||
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
if (bc && tc)
|
if (bc && tc)
|
||||||
return tc->makeCommand(bc->environment());
|
return tc->makeCommand(environment(bc));
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +135,23 @@ Task MakeStep::makeCommandMissingTask()
|
|||||||
Constants::TASK_CATEGORY_BUILDSYSTEM);
|
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)
|
void MakeStep::setMakeCommand(const QString &command)
|
||||||
{
|
{
|
||||||
m_makeCommand = command;
|
m_makeCommand = command;
|
||||||
@@ -305,8 +320,6 @@ void MakeStepConfigWidget::setSummaryText(const QString &text)
|
|||||||
|
|
||||||
void MakeStepConfigWidget::updateDetails()
|
void MakeStepConfigWidget::updateDetails()
|
||||||
{
|
{
|
||||||
ToolChain *tc
|
|
||||||
= ToolChainKitInformation::toolChain(m_makeStep->target()->kit(), ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
|
||||||
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||||
|
|
||||||
const QString defaultMake = m_makeStep->defaultMakeCommand();
|
const QString defaultMake = m_makeStep->defaultMakeCommand();
|
||||||
@@ -329,19 +342,8 @@ void MakeStepConfigWidget::updateDetails()
|
|||||||
param.setWorkingDirectory(bc->buildDirectory().toString());
|
param.setWorkingDirectory(bc->buildDirectory().toString());
|
||||||
param.setCommand(m_makeStep->effectiveMakeCommand());
|
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.setArguments(m_makeStep->allArguments());
|
||||||
param.setEnvironment(env);
|
param.setEnvironment(m_makeStep->environment(bc));
|
||||||
|
|
||||||
if (param.commandMissing())
|
if (param.commandMissing())
|
||||||
setSummaryText(tr("<b>Make:</b> %1 not found in the environment.").arg(param.command())); // Override display text
|
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 QString msgNoMakeCommand();
|
||||||
static Task makeCommandMissingTask();
|
static Task makeCommandMissingTask();
|
||||||
|
|
||||||
|
Utils::Environment environment(BuildConfiguration *bc) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
|
@@ -151,24 +151,13 @@ bool QmakeMakeStep::init(QList<const BuildStep *> &earlierSteps)
|
|||||||
subProFile->objectExtension();
|
subProFile->objectExtension();
|
||||||
Utils::QtcProcess::addArg(&args, objectFile);
|
Utils::QtcProcess::addArg(&args, objectFile);
|
||||||
}
|
}
|
||||||
Utils::Environment env = bc->environment();
|
pp->setEnvironment(environment(bc));
|
||||||
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->setArguments(args);
|
pp->setArguments(args);
|
||||||
pp->resolveAll();
|
pp->resolveAll();
|
||||||
|
|
||||||
setOutputParser(new ProjectExplorer::GnuMakeParser());
|
setOutputParser(new ProjectExplorer::GnuMakeParser());
|
||||||
|
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit(),
|
||||||
|
ProjectExplorer::Constants::CXX_LANGUAGE_ID);
|
||||||
if (tc && tc->targetAbi().os() == Abi::DarwinOS)
|
if (tc && tc->targetAbi().os() == Abi::DarwinOS)
|
||||||
appendOutputParser(new XcodebuildParser);
|
appendOutputParser(new XcodebuildParser);
|
||||||
IOutputParser *parser = target()->kit()->createOutputParser();
|
IOutputParser *parser = target()->kit()->createOutputParser();
|
||||||
|
Reference in New Issue
Block a user