forked from qt-creator/qt-creator
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:
@@ -247,24 +247,46 @@ void AbstractMsvcToolChain::addToEnvironment(Utils::Environment &env) const
|
|||||||
env = m_resultEnvironment;
|
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
|
QString AbstractMsvcToolChain::makeCommand(const Utils::Environment &environment) const
|
||||||
{
|
{
|
||||||
bool useJom = ProjectExplorerPlugin::projectExplorerSettings().useJom;
|
bool useJom = ProjectExplorerPlugin::projectExplorerSettings().useJom;
|
||||||
const QString jom = QLatin1String("jom.exe");
|
const QString jom("jom.exe");
|
||||||
const QString nmake = QLatin1String("nmake.exe");
|
const QString nmake("nmake.exe");
|
||||||
Utils::FileName tmp;
|
Utils::FileName tmp;
|
||||||
|
|
||||||
|
QString command;
|
||||||
if (useJom) {
|
if (useJom) {
|
||||||
tmp = environment.searchInPath(jom, {Utils::FileName::fromString(QCoreApplication::applicationDirPath())});
|
tmp = environment.searchInPath(jom, {Utils::FileName::fromString(QCoreApplication::applicationDirPath())});
|
||||||
if (!tmp.isEmpty())
|
if (!tmp.isEmpty())
|
||||||
return tmp.toString();
|
command = tmp.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command.isEmpty()) {
|
||||||
tmp = environment.searchInPath(nmake);
|
tmp = environment.searchInPath(nmake);
|
||||||
if (!tmp.isEmpty())
|
if (!tmp.isEmpty())
|
||||||
return tmp.toString();
|
command = tmp.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// Nothing found :(
|
if (command.isEmpty())
|
||||||
return useJom ? jom : nmake;
|
command = useJom ? jom : nmake;
|
||||||
|
|
||||||
|
if (environment.hasKey("VSLANG"))
|
||||||
|
return wrappedMakeCommand(command);
|
||||||
|
|
||||||
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FileName AbstractMsvcToolChain::compilerCommand() const
|
Utils::FileName AbstractMsvcToolChain::compilerCommand() const
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "abstractprocessstep.h"
|
#include "abstractprocessstep.h"
|
||||||
#include "ansifilterparser.h"
|
#include "ansifilterparser.h"
|
||||||
|
#include "buildconfiguration.h"
|
||||||
#include "buildstep.h"
|
#include "buildstep.h"
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
@@ -305,8 +306,11 @@ void AbstractProcessStep::processReadyReadStdOutput()
|
|||||||
if (!m_process)
|
if (!m_process)
|
||||||
return;
|
return;
|
||||||
m_process->setReadChannel(QProcess::StandardOutput);
|
m_process->setReadChannel(QProcess::StandardOutput);
|
||||||
|
const bool utf8Output = buildConfiguration()->environment().hasKey("VSLANG");
|
||||||
|
|
||||||
while (m_process->canReadLine()) {
|
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);
|
stdOutput(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,8 +507,11 @@ QWidget *KitEnvironmentConfigWidget::buttonWidget() const
|
|||||||
|
|
||||||
void KitEnvironmentConfigWidget::initMSVCOutputSwitch(QVBoxLayout *layout)
|
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);
|
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) {
|
connect(m_vslangCheckbox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
QList<Utils::EnvironmentItem> changes
|
QList<Utils::EnvironmentItem> changes
|
||||||
= EnvironmentKitInformation::environmentChanges(m_kit);
|
= EnvironmentKitInformation::environmentChanges(m_kit);
|
||||||
|
|||||||
Reference in New Issue
Block a user