From 94c319f93309ff4cddd0280cdcbd48b50492db36 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 31 Dec 2016 13:04:38 +0100 Subject: AUTOGEN: Generators: Use separate header lists for MOC and UIC This is necessary for the skipMoc and skipUic lists to work properly. --- Source/cmQtAutoGenerators.cxx | 58 +++++++++++++++++++++++++++++++++---------- Source/cmQtAutoGenerators.h | 8 +++--- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index b323609..fac9d54 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -511,7 +511,8 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) std::map notIncludedMocs; std::map > includedUis; // collects all headers which may need to be mocced - std::set headerFiles; + std::set headerFilesMoc; + std::set headerFilesUic; // Parse sources { @@ -527,14 +528,16 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) return false; } // Find additional headers - this->SearchHeadersForCppFile(absFilename, headerExtensions, - headerFiles); + this->SearchHeadersForSourceFile(absFilename, headerExtensions, + headerFilesMoc, headerFilesUic); } } // Parse headers - headerFiles.insert(this->Headers.begin(), this->Headers.end()); - this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); + headerFilesMoc.insert(this->Headers.begin(), this->Headers.end()); + headerFilesUic.insert(this->Headers.begin(), this->Headers.end()); + this->ParseHeaders(headerFilesMoc, headerFilesUic, includedMocs, + notIncludedMocs, includedUis); // Generate files if (!this->MocExecutable.empty()) { @@ -847,10 +850,10 @@ bool cmQtAutoGenerators::ParseContentForMoc( return true; } -void cmQtAutoGenerators::SearchHeadersForCppFile( +void cmQtAutoGenerators::SearchHeadersForSourceFile( const std::string& absFilename, const std::vector& headerExtensions, - std::set& absHeaders) + std::set& absHeadersMoc, std::set& absHeadersUic) { // search for header files and private header files we may need to moc: const std::string basename = @@ -859,37 +862,64 @@ void cmQtAutoGenerators::SearchHeadersForCppFile( cmsys::SystemTools::GetRealPath(absFilename)) + '/'; + // Search for regular header for (std::vector::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); ++ext) { const std::string headerName = absPath + basename + "." + (*ext); if (cmsys::SystemTools::FileExists(headerName.c_str())) { - absHeaders.insert(headerName); + // Moc headers + if (!this->MocExecutable.empty() && + !ListContains(this->SkipMoc, absFilename)) { + absHeadersMoc.insert(headerName); + } + // Uic headers + if (!this->UicExecutable.empty() && + !ListContains(this->SkipUic, absFilename)) { + absHeadersUic.insert(headerName); + } break; } } + // Search for private header for (std::vector::const_iterator ext = headerExtensions.begin(); ext != headerExtensions.end(); ++ext) { const std::string privateHeaderName = absPath + basename + "_p." + (*ext); if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) { - absHeaders.insert(privateHeaderName); + // Moc headers + if (!this->MocExecutable.empty() && + !ListContains(this->SkipMoc, absFilename)) { + absHeadersMoc.insert(privateHeaderName); + } + // Uic headers + if (!this->UicExecutable.empty() && + !ListContains(this->SkipUic, absFilename)) { + absHeadersUic.insert(privateHeaderName); + } break; } } } void cmQtAutoGenerators::ParseHeaders( - const std::set& absHeaders, + const std::set& absHeadersMoc, + const std::set& absHeadersUic, const std::map& includedMocs, std::map& notIncludedMocs, std::map >& includedUis) { - for (std::set::const_iterator hIt = absHeaders.begin(); - hIt != absHeaders.end(); ++hIt) { + // Merged header files list to read files only once + std::set headerFiles; + headerFiles.insert(absHeadersMoc.begin(), absHeadersMoc.end()); + headerFiles.insert(absHeadersUic.begin(), absHeadersUic.end()); + + for (std::set::const_iterator hIt = headerFiles.begin(); + hIt != headerFiles.end(); ++hIt) { const std::string& headerName = *hIt; const std::string contents = ReadAll(headerName); // Parse header content for MOC if (!this->MocExecutable.empty() && + (absHeadersMoc.find(headerName) != absHeadersMoc.end()) && (includedMocs.find(headerName) == includedMocs.end())) { if (ListContains(this->SkipMoc, headerName)) { // Skip @@ -916,7 +946,9 @@ void cmQtAutoGenerators::ParseHeaders( } // Parse header content for UIC - this->ParseContentForUic(headerName, contents, includedUis); + if (absHeadersUic.find(headerName) != absHeadersUic.end()) { + this->ParseContentForUic(headerName, contents, includedUis); + } } } diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index dac23d9..1036cb7 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -55,13 +55,15 @@ private: std::map& includedMocs, std::map >& includedUis, bool relaxed); - void SearchHeadersForCppFile( + void SearchHeadersForSourceFile( const std::string& absFilename, const std::vector& headerExtensions, - std::set& absHeaders); + std::set& absHeadersMoc, + std::set& absHeadersUic); void ParseHeaders( - const std::set& absHeaders, + const std::set& absHeadersMoc, + const std::set& absHeadersUic, const std::map& includedMocs, std::map& notIncludedMocs, std::map >& includedUis); -- cgit v0.12