windeployqt: Proper error message when qtpaths.bat/.exe could not be run

If qtpaths cannt be found windeployqt should complain about that fact.
Previously it complained about "Unsupported platform".

Pick-to: 6.6 6.5
Change-Id: I4db954633c31ceac69c4d3c0e55cbe942c3272fd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit bf2f4678b0c1a17ad8d18809335cfb69d2c6527a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Oliver Wolff 2023-12-01 10:49:39 +01:00 committed by Qt Cherry-pick Bot
parent ca38ac7731
commit b876d260b6
2 changed files with 13 additions and 9 deletions

View File

@ -1777,18 +1777,18 @@ int main(int argc, char **argv)
const QMap<QString, QString> qtpathsVariables = const QMap<QString, QString> qtpathsVariables =
queryQtPaths(options.qtpathsBinary, &errorMessage); queryQtPaths(options.qtpathsBinary, &errorMessage);
const QString xSpec = qtpathsVariables.value(QStringLiteral("QMAKE_XSPEC")); const QString xSpec = qtpathsVariables.value(QStringLiteral("QMAKE_XSPEC"));
options.platform = platformFromMkSpec(xSpec);
if (options.platform == UnknownPlatform) {
std::wcerr << "Unsupported platform " << xSpec << '\n';
return 1;
}
if (qtpathsVariables.isEmpty() || xSpec.isEmpty() if (qtpathsVariables.isEmpty() || xSpec.isEmpty()
|| !qtpathsVariables.contains(QStringLiteral("QT_INSTALL_BINS"))) { || !qtpathsVariables.contains(QStringLiteral("QT_INSTALL_BINS"))) {
std::wcerr << "Unable to query qtpaths: " << errorMessage << '\n'; std::wcerr << "Unable to query qtpaths: " << errorMessage << '\n';
return 1; return 1;
} }
options.platform = platformFromMkSpec(xSpec);
if (options.platform == UnknownPlatform) {
std::wcerr << "Unsupported platform " << xSpec << '\n';
return 1;
}
// Read the Qt module information from the Qt installation directory. // Read the Qt module information from the Qt installation directory.
const QString modulesDir const QString modulesDir
= qtpathsVariables.value(QLatin1String("QT_INSTALL_ARCHDATA")) = qtpathsVariables.value(QLatin1String("QT_INSTALL_ARCHDATA"))

View File

@ -423,14 +423,18 @@ const char *qmakeInfixKey = "QT_INFIX";
QMap<QString, QString> queryQtPaths(const QString &qtpathsBinary, QString *errorMessage) QMap<QString, QString> queryQtPaths(const QString &qtpathsBinary, QString *errorMessage)
{ {
const QString binary = !qtpathsBinary.isEmpty() ? qtpathsBinary : QStringLiteral("qtpaths"); const QString binary = !qtpathsBinary.isEmpty() ? qtpathsBinary : QStringLiteral("qtpaths");
const QString colonSpace = QStringLiteral(": ");
QByteArray stdOut; QByteArray stdOut;
QByteArray stdErr; QByteArray stdErr;
unsigned long exitCode = 0; unsigned long exitCode = 0;
if (!runProcess(binary, QStringList(QStringLiteral("-query")), QString(), &exitCode, &stdOut, &stdErr, errorMessage)) if (!runProcess(binary, QStringList(QStringLiteral("-query")), QString(), &exitCode, &stdOut,
&stdErr, errorMessage)) {
*errorMessage = QStringLiteral("Error running binary ") + binary + colonSpace + *errorMessage;
return QMap<QString, QString>(); return QMap<QString, QString>();
}
if (exitCode) { if (exitCode) {
*errorMessage = binary + QStringLiteral(" returns ") + QString::number(exitCode) *errorMessage = binary + QStringLiteral(" returns ") + QString::number(exitCode)
+ QStringLiteral(": ") + QString::fromLocal8Bit(stdErr); + colonSpace + QString::fromLocal8Bit(stdErr);
return QMap<QString, QString>(); return QMap<QString, QString>();
} }
const QString output = QString::fromLocal8Bit(stdOut).trimmed().remove(u'\r'); const QString output = QString::fromLocal8Bit(stdOut).trimmed().remove(u'\r');
@ -466,7 +470,7 @@ QMap<QString, QString> queryQtPaths(const QString &qtpathsBinary, QString *error
} }
} else { } else {
std::wcerr << "Warning: Unable to read " << QDir::toNativeSeparators(qconfigPriFile.fileName()) std::wcerr << "Warning: Unable to read " << QDir::toNativeSeparators(qconfigPriFile.fileName())
<< ": " << qconfigPriFile.errorString()<< '\n'; << colonSpace << qconfigPriFile.errorString()<< '\n';
} }
return result; return result;
} }