PE: Use original vcvarsall.bat to do environment cleanup

Amends ae07c31976

Calling a VS2022 vcvarsall.bat /clean_env in a VS2019 environment causes
failures. Using the original vcvarsall.bat does the proper cleanup.

Change-Id: I12426e9eb97baecae5357e6bb419333464ea1ded
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Cristian Adam
2022-10-23 14:45:12 +02:00
parent 51c1accfa5
commit 534c312d27

View File

@@ -2085,23 +2085,21 @@ std::optional<QString> MsvcToolChain::generateEnvironmentSettings(const Utils::E
// Create a batch file to create and save the env settings // Create a batch file to create and save the env settings
Utils::TempFileSaver saver(Utils::TemporaryDirectory::masterDirectoryPath() + "/XXXXXX.bat"); Utils::TempFileSaver saver(Utils::TemporaryDirectory::masterDirectoryPath() + "/XXXXXX.bat");
auto makeCall = [](const QString &batchFile, const QString &batchArgs) -> QByteArray { QByteArray call = "call ";
QByteArray call = "call "; call += ProcessArgs::quoteArg(batchFile).toLocal8Bit();
call += ProcessArgs::quoteArg(batchFile).toLocal8Bit(); if (!batchArgs.isEmpty()) {
if (!batchArgs.isEmpty()) { call += ' ';
call += ' '; call += batchArgs.toLocal8Bit();
call += batchArgs.toLocal8Bit(); }
}
return call;
};
QByteArray callCleanEnv = makeCall(batchFile, "/clean_env");
QByteArray call = makeCall(batchFile, batchArgs);
if (Utils::HostOsInfo::isWindowsHost()) if (Utils::HostOsInfo::isWindowsHost())
saver.write("chcp 65001\r\n"); saver.write("chcp 65001\r\n");
saver.write("set VSCMD_SKIP_SENDTELEMETRY=1\r\n"); saver.write("set VSCMD_SKIP_SENDTELEMETRY=1\r\n");
saver.write("set CLINK_NOAUTORUN=1\r\n"); saver.write("set CLINK_NOAUTORUN=1\r\n");
saver.write(callCleanEnv + "\r\n"); saver.write("setlocal enableextensions\r\n");
saver.write("if defined VCINSTALLDIR (\r\n");
saver.write(" call \"%VCINSTALLDIR%/Auxiliary/Build/vcvarsall.bat\" /clean_env\r\n");
saver.write(")\r\n");
saver.write(call + "\r\n"); saver.write(call + "\r\n");
saver.write("@echo " + marker.toLocal8Bit() + "\r\n"); saver.write("@echo " + marker.toLocal8Bit() + "\r\n");
saver.write("set\r\n"); saver.write("set\r\n");