* Check if command line exceeds maximum length supported by OS * (if on Windows) and switch to using a response file instead. */
| 804 | * (if on Windows) and switch to using a response file instead. |
| 805 | */ |
| 806 | void 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 | |
| 847 | bool cmQtAutoMocUicT::JobT::RunProcess(GenT genType, |
| 848 | cmWorkerPool::ProcessResultT& result, |