MCPcopy Create free account
hub / github.com/Kitware/CMake / MaybeWriteResponseFile

Method MaybeWriteResponseFile

Source/cmQtAutoMocUic.cxx:806–845  ·  view source on GitHub ↗

* Check if command line exceeds maximum length supported by OS * (if on Windows) and switch to using a response file instead. */

Source from the content-addressed store, hash-verified

804 * (if on Windows) and switch to using a response file instead.
805 */
806void cmQtAutoMocUicT::JobT::MaybeWriteResponseFile(
807 std::string const& outputFile, std::vector<std::string>& cmd) const
808{
809#ifdef _WIN32
810 // Ensure cmd is less than CommandLineLengthMax characters
811 size_t commandLineLength = cmd.size(); // account for separating spaces
812 for (std::string const& str : cmd) {
813 commandLineLength += str.length();
814 }
815 if (commandLineLength >= this->BaseConst().MaxCommandLineLength) {
816 // Command line exceeds maximum size allowed by OS
817 // => create response file
818 std::string const responseFile = cmStrCat(outputFile, ".rsp");
819
820 cmsys::ofstream fout(responseFile.c_str());
821 if (!fout) {
822 this->LogError(
823 GenT::MOC,
824 cmStrCat("AUTOMOC was unable to create a response file at\n ",
825 this->MessagePath(responseFile)));
826 return;
827 }
828
829 auto it = cmd.begin();
830 while (++it != cmd.end()) {
831 fout << *it << "\n";
832 }
833 fout.close();
834
835 // Keep all but executable
836 cmd.resize(1);
837
838 // Specify response file
839 cmd.emplace_back(cmStrCat('@', responseFile));
840 }
841#else
842 static_cast<void>(outputFile);
843 static_cast<void>(cmd);
844#endif
845}
846
847bool cmQtAutoMocUicT::JobT::RunProcess(GenT genType,
848 cmWorkerPool::ProcessResultT& result,

Callers

nothing calls this directly

Calls 11

LogErrorMethod · 0.95
MessagePathMethod · 0.95
lengthMethod · 0.80
c_strMethod · 0.80
emplace_backMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
closeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected