ProjectExplorer: Fix switching build console to Utf8 for MSVC

Wrap make command into the script to switch console code page
to Utf8 before make (when the Kit check is on).

Task-number: QTCREATORBUG-20327
Change-Id: Ie3e372e52a09b93a41c5ac7ad63b7b14384655fb
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-04-27 12:34:13 +02:00
parent 8ea31bb1e1
commit 75afda1798
3 changed files with 39 additions and 10 deletions

View File

@@ -247,24 +247,46 @@ void AbstractMsvcToolChain::addToEnvironment(Utils::Environment &env) const
env = m_resultEnvironment;
}
static QString wrappedMakeCommand(const QString &command)
{
const QString wrapperPath = QDir::currentPath() + "/msvc_make.bat";
QFile wrapper(wrapperPath);
if (!wrapper.open(QIODevice::WriteOnly))
return command;
QTextStream stream(&wrapper);
stream << "chcp 65001\n";
stream << command << " %*";
return wrapperPath;
}
QString AbstractMsvcToolChain::makeCommand(const Utils::Environment &environment) const
{
bool useJom = ProjectExplorerPlugin::projectExplorerSettings().useJom;
const QString jom = QLatin1String("jom.exe");
const QString nmake = QLatin1String("nmake.exe");
const QString jom("jom.exe");
const QString nmake("nmake.exe");
Utils::FileName tmp;
QString command;
if (useJom) {
tmp = environment.searchInPath(jom, {Utils::FileName::fromString(QCoreApplication::applicationDirPath())});
if (!tmp.isEmpty())
return tmp.toString();
command = tmp.toString();
}
if (command.isEmpty()) {
tmp = environment.searchInPath(nmake);
if (!tmp.isEmpty())
return tmp.toString();
command = tmp.toString();
}
// Nothing found :(
return useJom ? jom : nmake;
if (command.isEmpty())
command = useJom ? jom : nmake;
if (environment.hasKey("VSLANG"))
return wrappedMakeCommand(command);
return command;
}
Utils::FileName AbstractMsvcToolChain::compilerCommand() const

View File

@@ -25,6 +25,7 @@
#include "abstractprocessstep.h"
#include "ansifilterparser.h"
#include "buildconfiguration.h"
#include "buildstep.h"
#include "project.h"
#include "task.h"
@@ -305,8 +306,11 @@ void AbstractProcessStep::processReadyReadStdOutput()
if (!m_process)
return;
m_process->setReadChannel(QProcess::StandardOutput);
const bool utf8Output = buildConfiguration()->environment().hasKey("VSLANG");
while (m_process->canReadLine()) {
QString line = QString::fromLocal8Bit(m_process->readLine());
QString line = utf8Output ? QString::fromUtf8(m_process->readLine())
: QString::fromLocal8Bit(m_process->readLine());
stdOutput(line);
}
}

View File

@@ -507,8 +507,11 @@ QWidget *KitEnvironmentConfigWidget::buttonWidget() const
void KitEnvironmentConfigWidget::initMSVCOutputSwitch(QVBoxLayout *layout)
{
m_vslangCheckbox = new QCheckBox(tr("Force English MSVC compiler output (VSLANG=1033)"));
m_vslangCheckbox = new QCheckBox(tr("Force UTF-8 MSVC compiler output"));
layout->addWidget(m_vslangCheckbox);
m_vslangCheckbox->setToolTip(tr("Either switches MSVC to English or keeps the language and "
"just forces UTF-8 output (may vary depending on the used MSVC "
"compiler)."));
connect(m_vslangCheckbox, &QCheckBox::toggled, this, [this](bool checked) {
QList<Utils::EnvironmentItem> changes
= EnvironmentKitInformation::environmentChanges(m_kit);