Set LC_MESSAGES instead of LC_ALL for parsing the error output

Task-number: QTCREATORBUG-15855
Change-Id: I05aa83acb356840cfdacc92796b190fb8754ada0
Reviewed-by: hjk <hjk@theqtcompany.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Jarek Kobus
2016-04-07 13:06:01 +02:00
parent 6fc7fb5f57
commit 3f19774c0f
13 changed files with 36 additions and 29 deletions

View File

@@ -212,6 +212,26 @@ Environment Environment::systemEnvironment()
return *staticSystemEnvironment();
}
const char lcMessages[] = "LC_MESSAGES";
const char englishLocale[] = "en_US.utf8";
void Environment::setupEnglishOutput(Environment *environment)
{
environment->set(QLatin1String(lcMessages), QLatin1String(englishLocale));
}
void Environment::setupEnglishOutput(QProcessEnvironment *environment)
{
environment->insert(QLatin1String(lcMessages), QLatin1String(englishLocale));
}
void Environment::setupEnglishOutput(QStringList *environment)
{
Environment env(*environment);
setupEnglishOutput(&env);
*environment = env.toStringList();
}
void Environment::clear()
{
m_values.clear();

View File

@@ -65,6 +65,9 @@ public:
explicit Environment(OsType osType = HostOsInfo::hostOs()) : m_osType(osType) {}
explicit Environment(const QStringList &env, OsType osType = HostOsInfo::hostOs());
static Environment systemEnvironment();
static void setupEnglishOutput(Environment *environment);
static void setupEnglishOutput(QProcessEnvironment *environment);
static void setupEnglishOutput(QStringList *environment);
QStringList toStringList() const;
QProcessEnvironment toProcessEnvironment() const;

View File

@@ -174,9 +174,7 @@ bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env);
pp->setWorkingDirectory(bc->buildDirectory().toString());
pp->setCommand(tc ? tc->makeCommand(bc->environment()) : QLatin1String("make"));

View File

@@ -203,9 +203,7 @@ bool CMakeBuildStep::init(QList<const BuildStep *> &earlierSteps)
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
if (!env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString))
env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] "));
pp->setEnvironment(env);

View File

@@ -105,7 +105,7 @@ Utils::SynchronousProcessResponse CMakeTool::run(const QString &arg) const
cmake.setTimeoutS(1);
cmake.setFlags(Utils::SynchronousProcess::UnixTerminalDisabled);
Utils::Environment env = Utils::Environment::systemEnvironment();
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
cmake.setProcessEnvironment(env.toProcessEnvironment());
cmake.setTimeOutMessageBoxEnabled(false);

View File

@@ -27,6 +27,7 @@
#include "messagemanager.h"
#include "icore.h"
#include <utils/synchronousprocess.h>
#include <utils/environment.h>
#include <QProcess>
#include <QProcessEnvironment>
@@ -91,7 +92,7 @@ static bool runPatchHelper(const QByteArray &input, const QString &workingDirect
if (!workingDirectory.isEmpty())
patchProcess.setWorkingDirectory(workingDirectory);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
patchProcess.setProcessEnvironment(env);
QStringList args;
// Add argument 'apply' when git is used as patch command since git 2.5/Windows

View File

@@ -137,7 +137,7 @@ GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const
QProcess proc;
QStringList envLang = QProcess::systemEnvironment();
envLang.replaceInStrings(QRegExp(QLatin1String("^LC_ALL=.*")), QLatin1String("LC_ALL=C"));
Utils::Environment::setupEnglishOutput(&envLang);
proc.setEnvironment(envLang);
proc.start(debuggerCommand, args);

View File

@@ -108,9 +108,7 @@ bool GenericMakeStep::init(QList<const BuildStep *> &earlierSteps)
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString());
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env);
pp->setCommand(makeCommand(bc->environment()));
pp->setArguments(allArguments());

View File

@@ -111,9 +111,7 @@ bool IosBuildStep::init(QList<const BuildStep *> &earlierSteps)
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString());
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env);
pp->setCommand(buildCommand());
pp->setArguments(Utils::QtcProcess::joinArgs(allArguments()));

View File

@@ -90,9 +90,7 @@ bool IosPresetBuildStep::init(QList<const BuildStep *> &earlierSteps)
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory().toString());
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env);
pp->setCommand(command());
pp->setArguments(Utils::QtcProcess::joinArgs(arguments()));

View File

@@ -71,9 +71,8 @@ static QByteArray runGcc(const FileName &gcc, const QStringList &arguments, cons
return QByteArray();
QProcess cpp;
// Force locale: This function is used only to detect settings inside the tool chain, so this is save.
QStringList environment(env);
environment.append(QLatin1String("LC_ALL=C"));
Utils::Environment::setupEnglishOutput(&environment);
cpp.setEnvironment(environment);
cpp.start(gcc.toString(), arguments);

View File

@@ -71,9 +71,7 @@ bool AndroidPackageInstallationStep::init(QList<const BuildStep *> &earlierSteps
pp->setWorkingDirectory(bc->buildDirectory().toString());
pp->setCommand(tc->makeCommand(bc->environment()));
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
pp->setEnvironment(env);
const QString innerQuoted = Utils::QtcProcess::quoteArg(dirPath);
const QString outerQuoted = Utils::QtcProcess::quoteArg(QString::fromLatin1("INSTALL_ROOT=") + innerQuoted);

View File

@@ -233,9 +233,7 @@ bool MakeStep::init(QList<const BuildStep *> &earlierSteps)
Utils::QtcProcess::addArg(&args, objectFile);
}
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
Utils::Environment::setupEnglishOutput(&env);
// We also prepend "L" to the MAKEFLAGS, so that nmake / jom are less verbose
if (tc && m_makeCmd.isEmpty()) {
if (tc->targetAbi().os() == Abi::WindowsOS
@@ -415,9 +413,7 @@ void MakeStepConfigWidget::updateDetails()
QString args = m_makeStep->userArguments();
Utils::Environment env = bc->environment();
// Force output to english for the parsers. Do this here and not in the toolchain's
// addToEnvironment() to not screw up the users run environment.
env.set(QLatin1String("LC_ALL"), QLatin1String("C"));
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()) {