I have a Qt project setup with microsoft compiler (although I'm using QtCreator) and I noticed it seems to create a file named msvc_make.bat
, current contents are
chcp 65001
"C:\Qt\Tools\QtCreator\bin\jom.exe" %*
What is the purpose of this?
I have a Qt project setup with microsoft compiler (although I'm using QtCreator) and I noticed it seems to create a file named msvc_make.bat
, current contents are
chcp 65001
"C:\Qt\Tools\QtCreator\bin\jom.exe" %*
What is the purpose of this?
while creating a makefile for your project using qmake
,either nmake or jom is used to execute commands.
In the source code of Qt creator, this file ( msvc.bat
) is created in the msvctoolchain.cpp
file by the function wrappedMakeCommand()
{on line 1091}
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 << "\"" << QDir::toNativeSeparators(command) << "\" %*";
return wrapperPath;
}
which is used by MsvcToolChain::makeCommand()
{line 1104} function to create the make command
to build the project.
FilePath MsvcToolChain::makeCommand(const Environment &environment) const
{
bool useJom = ProjectExplorerPlugin::projectExplorerSettings().useJom;
const QString jom("jom.exe");
const QString nmake("nmake.exe");
Utils::FilePath tmp;
FilePath command;
if (useJom) {
tmp = environment.searchInPath(jom,
{Utils::FilePath::fromString(
QCoreApplication::applicationDirPath())});
if (!tmp.isEmpty())
command = tmp;
}
if (command.isEmpty()) {
tmp = environment.searchInPath(nmake);
if (!tmp.isEmpty())
command = tmp;
}
if (command.isEmpty())
command = FilePath::fromString(useJom ? jom : nmake);
if (environment.hasKey("VSLANG"))
return FilePath::fromString(wrappedMakeCommand(command.toString()));
return command;
}
when you look closely in the source code of this function, you will notice that it is just searching for the the required executable (jom.exe
or nmake.exe
)
after that, wrappedMakeCommand()
function is called when environment variable with key "VSLANG" is present ( contains information about the language of the VSCode )
in the function wrappedMakeCommand()
, developers used a batch file ( MSVC_make.bat
) to add another command chcp 65001
before executing the make file which enables the UTF-8 encoding to understand symbols from different languages just in case the system is running in another language (say Japanese).
all this information is my interpretation of why this file exists (from the knowledge gained from the source code of qt creator) and I am not 100% sure if this is the correct reason or not, but it made sense to me so answered here.
in case of any correction then do let me know via comments.