From 14a86c9ea7efae1b3acb01bc79f2f1f5ef23c5f1 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 11:28:40 +0200 Subject: Autogen: Protected calls to cmSystemTools::CollapseCombinedPath --- Source/cmQtAutoGenerator.cxx | 9 ++++++++- Source/cmQtAutoGenerator.h | 12 +++++++++++- Source/cmQtAutoGeneratorMocUic.cxx | 10 +++++----- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 1939bd4..7f133ab 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -146,13 +146,20 @@ void cmQtAutoGenerator::Logger::ErrorCommand( } } -std::string cmQtAutoGenerator::FileSystem::RealPath( +std::string cmQtAutoGenerator::FileSystem::GetRealPath( std::string const& filename) { std::lock_guard lock(Mutex_); return cmSystemTools::GetRealPath(filename); } +std::string cmQtAutoGenerator::FileSystem::CollapseCombinedPath( + std::string const& dir, std::string const& file) +{ + std::lock_guard lock(Mutex_); + return cmSystemTools::CollapseCombinedPath(dir, file); +} + bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename) { std::lock_guard lock(Mutex_); diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index e029d8d..5f59b5d 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -68,8 +68,17 @@ public: { } + /// @brief Logger Logger* Log() const { return Log_; } - std::string RealPath(std::string const& filename); + + // -- Paths + /// @brief Wrapper for cmSystemTools::GetRealPath + std::string GetRealPath(std::string const& filename); + /// @brief Wrapper for cmSystemTools::CollapseCombinedPath + std::string CollapseCombinedPath(std::string const& dir, + std::string const& file); + + // -- File access bool FileExists(std::string const& filename); bool FileIsOlderThan(std::string const& buildFile, std::string const& sourceFile, @@ -92,6 +101,7 @@ public: bool FileRemove(std::string const& filename); bool Touch(std::string const& filename); + // -- Directory access bool MakeDirectory(std::string const& dirname); /// @brief Error logging version bool MakeDirectory(GeneratorT genType, std::string const& dirname); diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 6be65ee..b034ec7 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -26,7 +26,7 @@ std::string cmQtAutoGeneratorMocUic::BaseSettingsT::AbsoluteBuildPath( std::string const& relativePath) const { - return cmSystemTools::CollapseCombinedPath(AutogenBuildDir, relativePath); + return FileSys->CollapseCombinedPath(AutogenBuildDir, relativePath); } /** @@ -106,7 +106,7 @@ std::string cmQtAutoGeneratorMocUic::MocSettingsT::FindIncludedFile( std::string testPath = sourcePath; testPath += includeString; if (FileSys->FileExists(testPath)) { - return FileSys->RealPath(testPath); + return FileSys->GetRealPath(testPath); } } // Search in include directories @@ -115,7 +115,7 @@ std::string cmQtAutoGeneratorMocUic::MocSettingsT::FindIncludedFile( fullPath.push_back('/'); fullPath += includeString; if (FileSys->FileExists(fullPath)) { - return FileSys->RealPath(fullPath); + return FileSys->GetRealPath(fullPath); } } // Return empty string @@ -487,7 +487,7 @@ std::string cmQtAutoGeneratorMocUic::JobParseT::MocFindIncludedHeader( } // Sanitize if (!header.empty()) { - header = wrk.FileSys().RealPath(header); + header = wrk.FileSys().GetRealPath(header); } return header; } @@ -569,7 +569,7 @@ std::string cmQtAutoGeneratorMocUic::JobParseT::UicFindIncludedFile( // Search for the .ui file! for (std::string const& testFile : testFiles) { if (wrk.FileSys().FileExists(testFile)) { - res = wrk.FileSys().RealPath(testFile); + res = wrk.FileSys().GetRealPath(testFile); break; } } -- cgit v0.12 From 65203ce407f589a6ba148baf64b07ada09205030 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 12:17:14 +0200 Subject: Autogen: Protected calls to cmSystemTools::Split/JoinPath --- Source/cmQtAutoGenerator.cxx | 23 +++++++++++++++++++++++ Source/cmQtAutoGenerator.h | 8 ++++++++ Source/cmQtAutoGeneratorMocUic.cxx | 4 ++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 7f133ab..1716189 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -160,6 +160,29 @@ std::string cmQtAutoGenerator::FileSystem::CollapseCombinedPath( return cmSystemTools::CollapseCombinedPath(dir, file); } +void cmQtAutoGenerator::FileSystem::SplitPath( + const std::string& p, std::vector& components, + bool expand_home_dir) +{ + std::lock_guard lock(Mutex_); + cmSystemTools::SplitPath(p, components, expand_home_dir); +} + +std::string cmQtAutoGenerator::FileSystem::JoinPath( + const std::vector& components) +{ + std::lock_guard lock(Mutex_); + return cmSystemTools::JoinPath(components); +} + +std::string cmQtAutoGenerator::FileSystem::JoinPath( + std::vector::const_iterator first, + std::vector::const_iterator last) +{ + std::lock_guard lock(Mutex_); + return cmSystemTools::JoinPath(first, last); +} + bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename) { std::lock_guard lock(Mutex_); diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 5f59b5d..33d0221 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -77,6 +77,14 @@ public: /// @brief Wrapper for cmSystemTools::CollapseCombinedPath std::string CollapseCombinedPath(std::string const& dir, std::string const& file); + /// @brief Wrapper for cmSystemTools::SplitPath + void SplitPath(const std::string& p, std::vector& components, + bool expand_home_dir = true); + /// @brief Wrapper for cmSystemTools::JoinPath + std::string JoinPath(const std::vector& components); + /// @brief Wrapper for cmSystemTools::JoinPath + std::string JoinPath(std::vector::const_iterator first, + std::vector::const_iterator last); // -- File access bool FileExists(std::string const& filename); diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index b034ec7..1cdbb96 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -1503,8 +1503,8 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) if (cmHasLiteralSuffix(path, ".framework/Headers")) { // Go up twice to get to the framework root std::vector pathComponents; - cmSystemTools::SplitPath(path, pathComponents); - std::string frameworkPath = cmSystemTools::JoinPath( + FileSys().SplitPath(path, pathComponents); + std::string frameworkPath = FileSys().JoinPath( pathComponents.begin(), pathComponents.end() - 2); frameworkPaths.insert(frameworkPath); } -- cgit v0.12 From 9a736158150852e9d011fabc0f4a33ce039be6fc Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 12:25:28 +0200 Subject: Autogen: Protected calls to cmSystemTools::GetFilenameWithoutLastExtension --- Source/cmQtAutoGenerator.cxx | 7 +++++++ Source/cmQtAutoGenerator.h | 2 ++ Source/cmQtAutoGeneratorMocUic.cxx | 10 +++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 1716189..77bf2ec 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -183,6 +183,13 @@ std::string cmQtAutoGenerator::FileSystem::JoinPath( return cmSystemTools::JoinPath(first, last); } +std::string cmQtAutoGenerator::FileSystem::GetFilenameWithoutLastExtension( + const std::string& filename) +{ + std::lock_guard lock(Mutex_); + return cmSystemTools::GetFilenameWithoutLastExtension(filename); +} + bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename) { std::lock_guard lock(Mutex_); diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 33d0221..d6ddbc3 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -85,6 +85,8 @@ public: /// @brief Wrapper for cmSystemTools::JoinPath std::string JoinPath(std::vector::const_iterator first, std::vector::const_iterator last); + /// @brief Wrapper for cmSystemTools::GetFilenameWithoutLastExtension + std::string GetFilenameWithoutLastExtension(const std::string& filename); // -- File access bool FileExists(std::string const& filename); diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 1cdbb96..a8ba2ba 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -168,7 +168,7 @@ void cmQtAutoGeneratorMocUic::JobParseT::Process(WorkerT& wrk) if (!meta.Content.empty()) { meta.FileDir = SubDirPrefix(FileName); meta.FileBase = - cmSystemTools::GetFilenameWithoutLastExtension(FileName); + wrk.FileSys().GetFilenameWithoutLastExtension(FileName); bool success = true; if (AutoMoc) { @@ -224,7 +224,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk, std::string incString = match.match(2); std::string incDir(SubDirPrefix(incString)); std::string incBase = - cmSystemTools::GetFilenameWithoutLastExtension(incString); + wrk.FileSys().GetFilenameWithoutLastExtension(incString); if (cmHasLiteralPrefix(incBase, "moc_")) { // moc_.cxx // Remove the moc_ part from the base name @@ -533,7 +533,7 @@ std::string cmQtAutoGeneratorMocUic::JobParseT::UicFindIncludedFile( { std::string res; std::string searchFile = - cmSystemTools::GetFilenameWithoutLastExtension(includeString).substr(3); + wrk.FileSys().GetFilenameWithoutLastExtension(includeString).substr(3); searchFile += ".ui"; // Collect search paths list std::deque testFiles; @@ -678,7 +678,7 @@ void cmQtAutoGeneratorMocUic::JobMocT::Process(WorkerT& wrk) } else { std::string rel = wrk.Base().FilePathChecksum.getPart(SourceFile); rel += "/moc_"; - rel += cmSystemTools::GetFilenameWithoutLastExtension(SourceFile); + rel += wrk.FileSys().GetFilenameWithoutLastExtension(SourceFile); rel += ".cpp"; // Register relative file path wrk.Gen().ParallelMocAutoRegister(rel); @@ -1417,7 +1417,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) { std::array bases; bases[0] = SubDirPrefix(src); - bases[0] += cmSystemTools::GetFilenameWithoutLastExtension(src); + bases[0] += FileSys().GetFilenameWithoutLastExtension(src); bases[1] = bases[0]; bases[1] += "_p"; for (std::string const& headerBase : bases) { -- cgit v0.12 From 719b24c87244ac612cfdc85da0e75140b87df673 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 12:29:47 +0200 Subject: Autogen: Protected calls to cmQtAutoGen::SubDirPrefix --- Source/cmQtAutoGenerator.cxx | 7 +++++++ Source/cmQtAutoGenerator.h | 2 ++ Source/cmQtAutoGeneratorMocUic.cxx | 10 +++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 77bf2ec..b5e1301 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -190,6 +190,13 @@ std::string cmQtAutoGenerator::FileSystem::GetFilenameWithoutLastExtension( return cmSystemTools::GetFilenameWithoutLastExtension(filename); } +std::string cmQtAutoGenerator::FileSystem::SubDirPrefix( + std::string const& filename) +{ + std::lock_guard lock(Mutex_); + return cmQtAutoGen::SubDirPrefix(filename); +} + bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename) { std::lock_guard lock(Mutex_); diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index d6ddbc3..b3a53bc 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -87,6 +87,8 @@ public: std::vector::const_iterator last); /// @brief Wrapper for cmSystemTools::GetFilenameWithoutLastExtension std::string GetFilenameWithoutLastExtension(const std::string& filename); + /// @brief Wrapper for cmQtAutoGen::SubDirPrefix + std::string SubDirPrefix(std::string const& filename); // -- File access bool FileExists(std::string const& filename); diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index a8ba2ba..c9dec10 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -166,7 +166,7 @@ void cmQtAutoGeneratorMocUic::JobParseT::Process(WorkerT& wrk) MetaT meta; if (wrk.FileSys().FileRead(meta.Content, FileName, &error)) { if (!meta.Content.empty()) { - meta.FileDir = SubDirPrefix(FileName); + meta.FileDir = wrk.FileSys().SubDirPrefix(FileName); meta.FileBase = wrk.FileSys().GetFilenameWithoutLastExtension(FileName); @@ -222,7 +222,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk, cmsys::RegularExpressionMatch match; while (wrk.Moc().RegExpInclude.find(contentChars, match)) { std::string incString = match.match(2); - std::string incDir(SubDirPrefix(incString)); + std::string incDir(wrk.FileSys().SubDirPrefix(incString)); std::string incBase = wrk.FileSys().GetFilenameWithoutLastExtension(incString); if (cmHasLiteralPrefix(incBase, "moc_")) { @@ -538,7 +538,7 @@ std::string cmQtAutoGeneratorMocUic::JobParseT::UicFindIncludedFile( // Collect search paths list std::deque testFiles; { - std::string const searchPath = SubDirPrefix(includeString); + std::string const searchPath = wrk.FileSys().SubDirPrefix(includeString); std::string searchFileFull; if (!searchPath.empty()) { @@ -798,7 +798,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk) } // Check dependency timestamps std::string error; - std::string sourceDir = SubDirPrefix(SourceFile); + std::string sourceDir = wrk.FileSys().SubDirPrefix(SourceFile); for (std::string const& depFileRel : Depends) { std::string depFileAbs = wrk.Moc().FindIncludedFile(sourceDir, depFileRel); @@ -1416,7 +1416,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) // Search for the default header file and a private header { std::array bases; - bases[0] = SubDirPrefix(src); + bases[0] = FileSys().SubDirPrefix(src); bases[0] += FileSys().GetFilenameWithoutLastExtension(src); bases[1] = bases[0]; bases[1] += "_p"; -- cgit v0.12 From ccc38fa509301a135e68542f9965f3ea9f0547b7 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 12:45:16 +0200 Subject: Autogen: Protected calls to cmFilePathChecksum Closes #17861 Closes #17862 --- Source/cmQtAutoGenerator.cxx | 16 ++++++++++++++++ Source/cmQtAutoGenerator.h | 9 +++++++++ Source/cmQtAutoGeneratorMocUic.cxx | 4 ++-- Source/cmQtAutoGeneratorMocUic.h | 2 -- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index b5e1301..f4444e3 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -197,6 +197,22 @@ std::string cmQtAutoGenerator::FileSystem::SubDirPrefix( return cmQtAutoGen::SubDirPrefix(filename); } +void cmQtAutoGenerator::FileSystem::setupFilePathChecksum( + std::string const& currentSrcDir, std::string const& currentBinDir, + std::string const& projectSrcDir, std::string const& projectBinDir) +{ + std::lock_guard lock(Mutex_); + FilePathChecksum_.setupParentDirs(currentSrcDir, currentBinDir, + projectSrcDir, projectBinDir); +} + +std::string cmQtAutoGenerator::FileSystem::GetFilePathChecksum( + std::string const& filename) +{ + std::lock_guard lock(Mutex_); + return FilePathChecksum_.getPart(filename); +} + bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename) { std::lock_guard lock(Mutex_); diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index b3a53bc..0995b46 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmFilePathChecksum.h" #include "cmQtAutoGen.h" #include "cmUVHandlePtr.h" #include "cmUVSignalHackRAII.h" // IWYU pragma: keep @@ -89,6 +90,13 @@ public: std::string GetFilenameWithoutLastExtension(const std::string& filename); /// @brief Wrapper for cmQtAutoGen::SubDirPrefix std::string SubDirPrefix(std::string const& filename); + /// @brief Wrapper for cmFilePathChecksum::setupParentDirs + void setupFilePathChecksum(std::string const& currentSrcDir, + std::string const& currentBinDir, + std::string const& projectSrcDir, + std::string const& projectBinDir); + /// @brief Wrapper for cmFilePathChecksum::getPart + std::string GetFilePathChecksum(std::string const& filename); // -- File access bool FileExists(std::string const& filename); @@ -124,6 +132,7 @@ public: private: std::mutex Mutex_; + cmFilePathChecksum FilePathChecksum_; Logger* Log_; }; diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index c9dec10..543bdf6 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -676,7 +676,7 @@ void cmQtAutoGeneratorMocUic::JobMocT::Process(WorkerT& wrk) BuildFile += '/'; BuildFile += IncludeString; } else { - std::string rel = wrk.Base().FilePathChecksum.getPart(SourceFile); + std::string rel = wrk.FileSys().GetFilePathChecksum(SourceFile); rel += "/moc_"; rel += wrk.FileSys().GetFilenameWithoutLastExtension(SourceFile); rel += ".cpp"; @@ -1444,7 +1444,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile) // ------------------------ // Init file path checksum generator - Base_.FilePathChecksum.setupParentDirs( + FileSys().setupFilePathChecksum( Base().CurrentSourceDir, Base().CurrentBinaryDir, Base().ProjectSourceDir, Base().ProjectBinaryDir); diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h index 696d5bd..2226954 100644 --- a/Source/cmQtAutoGeneratorMocUic.h +++ b/Source/cmQtAutoGeneratorMocUic.h @@ -5,7 +5,6 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmFilePathChecksum.h" #include "cmQtAutoGen.h" #include "cmQtAutoGenerator.h" #include "cmUVHandlePtr.h" @@ -95,7 +94,6 @@ public: std::string AutogenBuildDir; std::string AutogenIncludeDir; // - Files - cmFilePathChecksum FilePathChecksum; std::vector HeaderExtensions; // - File system FileSystem* FileSys; -- cgit v0.12 From 1d2c9d8c6d5ae93bd57e3dc8f1b54c54c3422644 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 13:36:47 +0200 Subject: Autogen: Use std::istreambuf_iterator for file so string reading This adds a dedicated mutex for file reading and writing to cmQtAutoGenerator::FileSystem. The purpose of the change is to avoid that long files reads block cmsys based path computations, which are protected by an other mutex. --- Source/cmQtAutoGenerator.cxx | 49 ++++++++++++++++++++++++++------------------ Source/cmQtAutoGenerator.h | 5 +++++ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index f4444e3..4aa1b1f 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -219,6 +219,20 @@ bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename) return cmSystemTools::FileExists(filename); } +bool cmQtAutoGenerator::FileSystem::FileExists(std::string const& filename, + bool isFile) +{ + std::lock_guard lock(Mutex_); + return cmSystemTools::FileExists(filename, isFile); +} + +unsigned long cmQtAutoGenerator::FileSystem::FileLength( + std::string const& filename) +{ + std::lock_guard lock(Mutex_); + return cmSystemTools::FileLength(filename); +} + bool cmQtAutoGenerator::FileSystem::FileIsOlderThan( std::string const& buildFile, std::string const& sourceFile, std::string* error) @@ -248,35 +262,30 @@ bool cmQtAutoGenerator::FileSystem::FileRead(std::string& content, std::string* error) { bool success = false; - { - std::lock_guard lock(Mutex_); - if (cmSystemTools::FileExists(filename, true)) { - std::size_t const length = cmSystemTools::FileLength(filename); + if (FileExists(filename, true)) { + unsigned long const length = FileLength(filename); + { + std::lock_guard lock(Mutex_); cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary)); if (ifs) { - if (length > 0) { - content.resize(length); - ifs.read(&content.front(), content.size()); - if (ifs) { - success = true; - } else { - content.clear(); - if (error != nullptr) { - error->append("Reading from the file failed."); - } - } + content.reserve(length); + content.assign(std::istreambuf_iterator{ ifs }, + std::istreambuf_iterator{}); + if (ifs) { + success = true; } else { - // Readable but empty file content.clear(); - success = true; + if (error != nullptr) { + error->append("Reading from the file failed."); + } } } else if (error != nullptr) { error->append("Opening the file for reading failed."); } - } else if (error != nullptr) { - error->append( - "The file does not exist, is not readable or is a directory."); } + } else if (error != nullptr) { + error->append( + "The file does not exist, is not readable or is a directory."); } return success; } diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 0995b46..299e4c2 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -99,7 +99,12 @@ public: std::string GetFilePathChecksum(std::string const& filename); // -- File access + /// @brief Wrapper for cmSystemTools::FileExists bool FileExists(std::string const& filename); + /// @brief Wrapper for cmSystemTools::FileExists + bool FileExists(std::string const& filename, bool isFile); + /// @brief Wrapper for cmSystemTools::FileLength + unsigned long FileLength(std::string const& filename); bool FileIsOlderThan(std::string const& buildFile, std::string const& sourceFile, std::string* error = nullptr); -- cgit v0.12 From b11e2c80b1e45fc12151c8392707d88b508191ca Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Tue, 3 Apr 2018 16:53:25 +0200 Subject: Autogen: Print moc/uic/rcc output to stdout The output of moc/uic/rcc used to be discarded unless the program failed. This lets moc/uic/rcc print their output to stdout even on success. Closes #17860 --- Source/cmQtAutoGeneratorMocUic.cxx | 14 +++++++++++--- Source/cmQtAutoGeneratorRcc.cxx | 8 ++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 543bdf6..e2fd158 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -853,8 +853,12 @@ void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk) ProcessResultT result; if (wrk.RunProcess(GeneratorT::MOC, result, cmd)) { // Moc command success + // Print moc output + if (!result.StdOut.empty()) { + wrk.LogInfo(GeneratorT::MOC, result.StdOut); + } + // Notify the generator that a not included file changed (on demand) if (IncludeString.empty()) { - // Notify the generator that a not included file changed wrk.Gen().ParallelMocAutoUpdated(); } } else { @@ -963,9 +967,13 @@ void cmQtAutoGeneratorMocUic::JobUicT::GenerateUic(WorkerT& wrk) ProcessResultT result; if (wrk.RunProcess(GeneratorT::UIC, result, cmd)) { - // Success + // Uic command success + // Print uic output + if (!result.StdOut.empty()) { + wrk.LogInfo(GeneratorT::UIC, result.StdOut); + } } else { - // Command failed + // Uic command failed { std::string emsg = "The uic process failed to compile\n "; emsg += Quoted(SourceFile); diff --git a/Source/cmQtAutoGeneratorRcc.cxx b/Source/cmQtAutoGeneratorRcc.cxx index 2bf00f7..84ec5e2 100644 --- a/Source/cmQtAutoGeneratorRcc.cxx +++ b/Source/cmQtAutoGeneratorRcc.cxx @@ -533,10 +533,14 @@ bool cmQtAutoGeneratorRcc::GenerateRcc() if (Process_->IsFinished()) { // Process is finished if (!ProcessResult_.error()) { - // Process success + // Rcc process success + // Print rcc output + if (!ProcessResult_.StdOut.empty()) { + Log().Info(GeneratorT::RCC, ProcessResult_.StdOut); + } BuildFileChanged_ = true; } else { - // Process failed + // Rcc process failed { std::string emsg = "The rcc process failed to compile\n "; emsg += Quoted(QrcFile_); -- cgit v0.12