diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2019-12-22 09:36:31 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2020-07-06 13:40:45 +0000 |
commit | cd75446c1e6e9ce17f9bb536af97775ad62aef1a (patch) | |
tree | 931942dca1a3af38d8d5ff389151ccc78b5af9ef /qmake/generators/makefile.cpp | |
parent | 96cea3b1681dd24a0ec3a53078b78f902e3211a6 (diff) |
Makefile: Deduplicate logic for response file name
+ verify that the file was actually written.
Change-Id: I14a3c0b75f41f926b469109a1d7f2f80368ec9bb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'qmake/generators/makefile.cpp')
-rw-r--r-- | qmake/generators/makefile.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index c64ed284c1..f6f4edef9d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -3456,28 +3456,34 @@ ProKey MakefileGenerator::fullTargetVariable() const return "TARGET"; } -void MakefileGenerator::createResponseFile(const QString &fileName, const ProStringList &objList) +QString MakefileGenerator::createResponseFile(const QString &baseName, const ProStringList &objList) { + QString fileName = baseName + '.' + fileVar("QMAKE_ORIG_TARGET"); + if (!var("BUILD_NAME").isEmpty()) + fileName += '.' + var("BUILD_NAME"); + if (!var("MAKEFILE").isEmpty()) + fileName += '.' + var("MAKEFILE"); QString filePath = Option::output_dir + QDir::separator() + fileName; QFile file(filePath); - if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QTextStream t(&file); - for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) { - QString path = (*it).toQString(); - // In response files, whitespace and special characters are - // escaped with a backslash; backslashes themselves can either - // be escaped into double backslashes, or, as this is a list of - // path names, converted to forward slashes. - path.replace(QLatin1Char('\\'), QLatin1String("/")) - .replace(QLatin1Char(' '), QLatin1String("\\ ")) - .replace(QLatin1Char('\t'), QLatin1String("\\\t")) - .replace(QLatin1Char('"'), QLatin1String("\\\"")) - .replace(QLatin1Char('\''), QLatin1String("\\'")); - t << path << Qt::endl; - } - t.flush(); - file.close(); - } + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return QString(); + QTextStream t(&file); + for (ProStringList::ConstIterator it = objList.constBegin(); it != objList.constEnd(); ++it) { + QString path = (*it).toQString(); + // In response files, whitespace and special characters are + // escaped with a backslash; backslashes themselves can either + // be escaped into double backslashes, or, as this is a list of + // path names, converted to forward slashes. + path.replace(QLatin1Char('\\'), QLatin1String("/")) + .replace(QLatin1Char(' '), QLatin1String("\\ ")) + .replace(QLatin1Char('\t'), QLatin1String("\\\t")) + .replace(QLatin1Char('"'), QLatin1String("\\\"")) + .replace(QLatin1Char('\''), QLatin1String("\\'")); + t << path << Qt::endl; + } + t.flush(); + file.close(); + return fileName; } QT_END_NAMESPACE |