qmake: Print error and exit if a response file cannot be created

This is always an error, and we should not silently return an empty
string and pretend that everything is in order.

Drive-by change: Add a comment stating what createResponseFile()
returns.

Pick-to: 6.3
Change-Id: I4ee940cfac826c7ae5d15e977b692f1368ab29ea
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Joerg Bornemann 2022-01-04 14:35:24 +01:00
parent ae294a42f0
commit 41f211d25f

View File

@ -3492,6 +3492,9 @@ ProKey MakefileGenerator::fullTargetVariable() const
return "TARGET";
}
/*
* Create a response file and return its file name.
*/
QString MakefileGenerator::createResponseFile(
const QString &baseName,
const ProStringList &objList,
@ -3504,8 +3507,11 @@ QString MakefileGenerator::createResponseFile(
fileName += '.' + var("MAKEFILE");
QString filePath = Option::output_dir + QDir::separator() + fileName;
QFile file(filePath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return QString();
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
fprintf(stderr, "Error: Cannot open response file '%s' for writing.\n",
qPrintable(filePath));
exit(1);
}
QTextStream t(&file);
for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) {
QString path = (*it).toQString();