diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2016-12-28 10:43:25 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-01-10 11:49:15 (GMT) |
commit | 63d3ca4c1cab0c7b9c71d6c051c3b4c053eb7627 (patch) | |
tree | 89afdc5f45057566afe0700d644585cb3fcbbcb2 | |
parent | 6ae19bf32e232beb59a0c427d82c0761e8248ab8 (diff) | |
download | CMake-63d3ca4c1cab0c7b9c71d6c051c3b4c053eb7627.zip CMake-63d3ca4c1cab0c7b9c71d6c051c3b4c053eb7627.tar.gz CMake-63d3ca4c1cab0c7b9c71d6c051c3b4c053eb7627.tar.bz2 |
AUTOGEN: Make skipMoc and skipUic blacklists behave the same way
Before skipMoc was a list of files that were not included in the
sources. Now the skipMoc files are added to the sources as well in case
they are needed for uic processing. skipMoc becomes a blacklist just like
skipUic.
-rw-r--r-- | Source/cmQtAutoGeneratorInitializer.cxx | 49 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 113 |
2 files changed, 82 insertions, 80 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index f0847b1..0ed43b1 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -100,8 +100,8 @@ static std::string GetQtMajorVersion(cmGeneratorTarget const* target) static void SetupSourceFiles(cmGeneratorTarget const* target, std::vector<std::string>& skipMoc, - std::vector<std::string>& mocSources, - std::vector<std::string>& mocHeaders, + std::vector<std::string>& sources, + std::vector<std::string>& headers, std::vector<std::string>& skipUic) { cmMakefile* makefile = target->Target->GetMakefile(); @@ -113,26 +113,39 @@ static void SetupSourceFiles(cmGeneratorTarget const* target, for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) { cmSourceFile* sf = *fileIt; + const cmSystemTools::FileFormat fileType = + cmSystemTools::GetFileFormat(sf->GetExtension().c_str()); + + if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) && + !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) { + continue; + } + if (cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { + continue; + } + const bool fileSkipUic = + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC")); + const bool fileSkipMoc = + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + if (fileSkipUic && fileSkipMoc) { + continue; + } + + // Use file const std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath()); - const std::string ext = sf->GetExtension(); - - if (cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) { + // Add file name to sources or headers list + if (fileType == cmSystemTools::CXX_FILE_FORMAT) { + sources.push_back(absFile); + } else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { + headers.push_back(absFile); + } + // Add file name to skip lists on demand + if (fileSkipUic) { skipUic.push_back(absFile); } - - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) { - if (cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"))) { - skipMoc.push_back(absFile); - } else { - cmSystemTools::FileFormat fileType = - cmSystemTools::GetFileFormat(ext.c_str()); - if (fileType == cmSystemTools::CXX_FILE_FORMAT) { - mocSources.push_back(absFile); - } else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { - mocHeaders.push_back(absFile); - } - } + if (fileSkipMoc) { + skipMoc.push_back(absFile); } } } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 5877619..4b5e113 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -89,6 +89,12 @@ static std::string ReadAll(const std::string& filename) return stream.str(); } +static bool ListContains(const std::vector<std::string>& list, + const std::string& entry) +{ + return (std::find(list.begin(), list.end(), entry) != list.end()); +} + cmQtAutoGenerators::cmQtAutoGenerators() : Verbose(cmsys::SystemTools::HasEnv("VERBOSE")) , ColorOutput(true) @@ -502,56 +508,35 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) // key = moc source filepath, value = moc output filepath std::map<std::string, std::string> includedMocs; - // collect all headers which may need to be mocced + std::map<std::string, std::string> notIncludedMocs; + std::map<std::string, std::vector<std::string> > includedUis; + // collects all headers which may need to be mocced std::set<std::string> headerFiles; - const std::vector<std::string>& headerExtensions = - makefile->GetCMakeInstance()->GetHeaderExtensions(); - - std::map<std::string, std::vector<std::string> > includedUis; - std::map<std::string, std::vector<std::string> > skippedUis; - - for (std::vector<std::string>::const_iterator it = this->Sources.begin(); - it != this->Sources.end(); ++it) { - const std::string& absFilename = *it; - const bool skipUic = std::find(this->SkipUic.begin(), this->SkipUic.end(), - absFilename) != this->SkipUic.end(); - std::map<std::string, std::vector<std::string> >& uiFiles = - skipUic ? skippedUis : includedUis; - if (this->Verbose) { - std::ostringstream err; - err << "AUTOGEN: Checking " << absFilename << std::endl; - this->LogInfo(err.str()); - } - // Parse source file for MOC/UIC - if (!this->ParseSourceFile(absFilename, headerExtensions, includedMocs, - uiFiles, this->MocRelaxedMode)) { - return false; - } - // Find additional headers - this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles); - } + // Parse sources + { + const std::vector<std::string>& headerExtensions = + makefile->GetCMakeInstance()->GetHeaderExtensions(); - for (std::vector<std::string>::const_iterator it = this->SkipMoc.begin(); - it != this->SkipMoc.end(); ++it) { - if (std::find(this->SkipUic.begin(), this->SkipUic.end(), *it) != - this->SkipUic.end()) { + for (std::vector<std::string>::const_iterator it = this->Sources.begin(); + it != this->Sources.end(); ++it) { const std::string& absFilename = *it; - if (this->Verbose) { - std::ostringstream err; - err << "AUTOGEN: Checking " << absFilename << std::endl; - this->LogInfo(err.str()); + // Parse source file for MOC/UIC + if (!this->ParseSourceFile(absFilename, headerExtensions, includedMocs, + includedUis, this->MocRelaxedMode)) { + return false; } - this->ParseForUic(absFilename, includedUis); + // Find additional headers + this->SearchHeadersForCppFile(absFilename, headerExtensions, + headerFiles); } } + // Parse headers headerFiles.insert(this->Headers.begin(), this->Headers.end()); - - // key = moc source filepath, value = moc output filename - std::map<std::string, std::string> notIncludedMocs; this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis); + // Generate files if (!this->MocExecutable.empty()) { if (!this->GenerateMocFiles(includedMocs, notIncludedMocs)) { return false; @@ -588,11 +573,13 @@ bool cmQtAutoGenerators::ParseSourceFile( << "The file is empty\n"; this->LogWarning(err.str()); } else { - // Parse source contents for UIC - this->ParseContentForUic(absFilename, contentsString, includedUis); // Parse source contents for MOC success = this->ParseContentForMoc( absFilename, contentsString, headerExtensions, includedMocs, relaxed); + // Parse source contents for UIC + if (success) { + this->ParseContentForUic(absFilename, contentsString, includedUis); + } } return success; } @@ -616,31 +603,21 @@ bool cmQtAutoGenerators::requiresMocing(const std::string& text, return false; } -void cmQtAutoGenerators::ParseForUic( - const std::string& absFilename, +void cmQtAutoGenerators::ParseContentForUic( + const std::string& absFilename, const std::string& contentsString, std::map<std::string, std::vector<std::string> >& includedUis) { - if (this->UicExecutable.empty()) { + if (this->UicExecutable.empty() || + ListContains(this->SkipUic, absFilename)) { return; } - const std::string contentsString = ReadAll(absFilename); - if (contentsString.empty()) { + + if (this->Verbose) { std::ostringstream err; - err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" - << std::endl; - this->LogWarning(err.str()); - return; + err << "AUTOUIC: Checking " << absFilename << "\n"; + this->LogInfo(err.str()); } - this->ParseContentForUic(absFilename, contentsString, includedUis); -} -void cmQtAutoGenerators::ParseContentForUic( - const std::string& absFilename, const std::string& contentsString, - std::map<std::string, std::vector<std::string> >& includedUis) -{ - if (this->UicExecutable.empty()) { - return; - } const std::string realName = cmsys::SystemTools::GetRealPath(absFilename); const char* contentChars = contentsString.c_str(); if (strstr(contentChars, "ui_") != CM_NULLPTR) { @@ -664,10 +641,17 @@ bool cmQtAutoGenerators::ParseContentForMoc( const std::vector<std::string>& headerExtensions, std::map<std::string, std::string>& includedMocs, bool relaxed) { - if (this->MocExecutable.empty()) { + if (this->MocExecutable.empty() || + ListContains(this->SkipMoc, absFilename)) { return true; } + if (this->Verbose) { + std::ostringstream err; + err << "AUTOMOC: Checking " << absFilename << "\n"; + this->LogInfo(err.str()); + } + const std::string scannedFileAbsPath = cmsys::SystemTools::GetFilenamePath( cmsys::SystemTools::GetRealPath(absFilename)) + @@ -887,11 +871,14 @@ void cmQtAutoGenerators::ParseHeaders( const std::string& headerName = *hIt; const std::string contents = ReadAll(headerName); + // Parse header content for MOC if (!this->MocExecutable.empty() && - includedMocs.find(headerName) == includedMocs.end()) { + !ListContains(this->SkipMoc, headerName) && + (includedMocs.find(headerName) == includedMocs.end())) { + if (this->Verbose) { std::ostringstream err; - err << "AUTOGEN: Checking " << headerName << std::endl; + err << "AUTOMOC: Checking " << headerName << "\n"; this->LogInfo(err.str()); } @@ -903,6 +890,8 @@ void cmQtAutoGenerators::ParseHeaders( ".cpp"; } } + + // Parse header content for UIC this->ParseContentForUic(headerName, contents, includedUis); } } |