summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qmake/generators/win32/msvc_nmake.cpp41
-rw-r--r--qmake/generators/win32/msvc_nmake.h1
2 files changed, 35 insertions, 7 deletions
diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp
index c19c101d43..0b0efe4acf 100644
--- a/qmake/generators/win32/msvc_nmake.cpp
+++ b/qmake/generators/win32/msvc_nmake.cpp
@@ -566,9 +566,9 @@ void NmakeMakefileGenerator::writeBuildRulesPart(QTextStream &t)
if(!project->isEmpty("QMAKE_PRE_LINK"))
t << "\n\t" <<var("QMAKE_PRE_LINK");
if(project->isActiveConfig("staticlib")) {
- t << "\n\t$(LIBAPP) $(LIBFLAGS) " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n\t "
- << "$(OBJECTS)"
- << "\n<<";
+ t << "\n\t$(LIBAPP) $(LIBFLAGS) " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n\t ";
+ writeResponseFileFiles(t, project->values("OBJECTS"));
+ t << "<<";
} else {
const bool embedManifest = ((templateName == "app" && project->isActiveConfig("embed_manifest_exe"))
|| (templateName == "lib" && project->isActiveConfig("embed_manifest_dll")
@@ -652,11 +652,38 @@ void NmakeMakefileGenerator::writeLinkCommand(QTextStream &t, const QString &ext
t << "$(LINKER) $(LFLAGS)";
if (!extraFlags.isEmpty())
t << ' ' << extraFlags;
- t << " " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n"
- << "$(OBJECTS) $(LIBS)";
+ t << " " << var("QMAKE_LINK_O_FLAG") << "$(DESTDIR_TARGET) @<<\n";
+ writeResponseFileFiles(t, project->values("OBJECTS"));
+ t << "$(LIBS)\n";
if (!extraInlineFileContent.isEmpty())
- t << ' ' << extraInlineFileContent;
- t << "\n<<";
+ t << extraInlineFileContent << '\n';
+ t << "<<";
+}
+
+void NmakeMakefileGenerator::writeResponseFileFiles(QTextStream &t, const ProStringList &files)
+{
+ if (files.isEmpty())
+ return;
+ // Add line breaks in file lists in reponse files to work around LNK1170.
+ // The actual line length limit is 131070, but let's use a smaller limit
+ // in case other tools are similarly hampered.
+ const int maxLineLength = 1000;
+ int len = 0;
+ for (const ProString &file : files) {
+ const ProString escapedFilePath = escapeFilePath(file);
+ if (len) {
+ if (len + escapedFilePath.length() > maxLineLength) {
+ t << '\n';
+ len = 0;
+ } else {
+ t << ' ';
+ len++;
+ }
+ }
+ t << escapedFilePath;
+ len += escapedFilePath.length();
+ }
+ t << '\n';
}
int NmakeMakefileGenerator::msvcVersion() const
diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h
index 9c88934e36..f782f9d734 100644
--- a/qmake/generators/win32/msvc_nmake.h
+++ b/qmake/generators/win32/msvc_nmake.h
@@ -40,6 +40,7 @@ class NmakeMakefileGenerator : public Win32MakefileGenerator
void writeImplicitRulesPart(QTextStream &t);
void writeBuildRulesPart(QTextStream &t);
void writeLinkCommand(QTextStream &t, const QString &extraFlags = QString(), const QString &extraInlineFileContent = QString());
+ void writeResponseFileFiles(QTextStream &t, const ProStringList &files);
int msvcVersion() const;
void init();
static QStringList sourceFilesForImplicitRulesFilter();