|
|
@@ -497,6 +497,10 @@ public:
|
|
|
|
|
|
protected:
|
|
|
ParseCacheT::FileHandleT CacheEntry;
|
|
|
+
|
|
|
+ private:
|
|
|
+ void MaybeWriteMocResponseFile(std::string const& outputFile,
|
|
|
+ std::vector<std::string>& cmd) const;
|
|
|
};
|
|
|
|
|
|
/** uic compiles a file. */
|
|
|
@@ -2025,6 +2029,8 @@ void cmQtAutoMocUicT::JobCompileMocT::Process()
|
|
|
cmd.push_back(outputFile);
|
|
|
// Add source file
|
|
|
cmd.push_back(sourceFile);
|
|
|
+
|
|
|
+ MaybeWriteMocResponseFile(outputFile, cmd);
|
|
|
}
|
|
|
|
|
|
// Execute moc command
|
|
|
@@ -2070,6 +2076,51 @@ void cmQtAutoMocUicT::JobCompileMocT::Process()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * Check if command line exceeds maximum length supported by OS
|
|
|
+ * (if on Windows) and switch to using a response file instead.
|
|
|
+ */
|
|
|
+void cmQtAutoMocUicT::JobCompileMocT::MaybeWriteMocResponseFile(
|
|
|
+ std::string const& outputFile, std::vector<std::string>& cmd) const
|
|
|
+{
|
|
|
+#ifdef _WIN32
|
|
|
+ // Ensure cmd is less than CommandLineLengthMax characters
|
|
|
+ size_t commandLineLength = cmd.size(); // account for separating spaces
|
|
|
+ for (std::string const& str : cmd) {
|
|
|
+ commandLineLength += str.length();
|
|
|
+ }
|
|
|
+ if (commandLineLength >= CommandLineLengthMax) {
|
|
|
+ // Command line exceeds maximum size allowed by OS
|
|
|
+ // => create response file
|
|
|
+ std::string const responseFile = cmStrCat(outputFile, ".rsp");
|
|
|
+
|
|
|
+ cmsys::ofstream fout(responseFile.c_str());
|
|
|
+ if (!fout) {
|
|
|
+ this->LogError(
|
|
|
+ GenT::MOC,
|
|
|
+ cmStrCat("AUTOMOC was unable to create a response file at\n ",
|
|
|
+ this->MessagePath(responseFile)));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto it = cmd.begin();
|
|
|
+ while (++it != cmd.end()) {
|
|
|
+ fout << *it << "\n";
|
|
|
+ }
|
|
|
+ fout.close();
|
|
|
+
|
|
|
+ // Keep all but executable
|
|
|
+ cmd.resize(1);
|
|
|
+
|
|
|
+ // Specify response file
|
|
|
+ cmd.push_back(cmStrCat('@', responseFile));
|
|
|
+ }
|
|
|
+#else
|
|
|
+ static_cast<void>(outputFile);
|
|
|
+ static_cast<void>(cmd);
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
void cmQtAutoMocUicT::JobCompileUicT::Process()
|
|
|
{
|
|
|
std::string const& sourceFile = this->Mapping->SourceFile->FileName;
|