diff options
-rw-r--r-- | Source/cmQtAutoGenerator.cxx | 48 | ||||
-rw-r--r-- | Source/cmQtAutoGenerator.h | 21 | ||||
-rw-r--r-- | Source/cmQtAutoGeneratorMocUic.cxx | 39 |
3 files changed, 33 insertions, 75 deletions
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index c1e6aabd4e..83a00cf926 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -261,6 +261,10 @@ bool cmQtAutoGenerator::FileWrite(std::string const& filename, }(); } +cmQtAutoGenerator::FileSystem::FileSystem() = default; + +cmQtAutoGenerator::FileSystem::~FileSystem() = default; + std::string cmQtAutoGenerator::FileSystem::GetRealPath( std::string const& filename) { @@ -380,18 +384,6 @@ bool cmQtAutoGenerator::FileSystem::FileRead(std::string& content, return cmQtAutoGenerator::FileRead(content, filename, error); } -bool cmQtAutoGenerator::FileSystem::FileRead(GenT genType, - std::string& content, - std::string const& filename) -{ - std::string error; - if (!FileRead(content, filename, &error)) { - Log()->ErrorFile(genType, filename, error); - return false; - } - return true; -} - bool cmQtAutoGenerator::FileSystem::FileWrite(std::string const& filename, std::string const& content, std::string* error) @@ -400,18 +392,6 @@ bool cmQtAutoGenerator::FileSystem::FileWrite(std::string const& filename, return cmQtAutoGenerator::FileWrite(filename, content, error); } -bool cmQtAutoGenerator::FileSystem::FileWrite(GenT genType, - std::string const& filename, - std::string const& content) -{ - std::string error; - if (!FileWrite(filename, content, &error)) { - Log()->ErrorFile(genType, filename, error); - return false; - } - return true; -} - bool cmQtAutoGenerator::FileSystem::FileDiffers(std::string const& filename, std::string const& content) { @@ -444,16 +424,6 @@ bool cmQtAutoGenerator::FileSystem::MakeDirectory(std::string const& dirname) return cmSystemTools::MakeDirectory(dirname); } -bool cmQtAutoGenerator::FileSystem::MakeDirectory(GenT genType, - std::string const& dirname) -{ - if (!MakeDirectory(dirname)) { - Log()->ErrorFile(genType, dirname, "Could not create directory"); - return false; - } - return true; -} - bool cmQtAutoGenerator::FileSystem::MakeParentDirectory( std::string const& filename) { @@ -461,16 +431,6 @@ bool cmQtAutoGenerator::FileSystem::MakeParentDirectory( return cmQtAutoGenerator::MakeParentDirectory(filename); } -bool cmQtAutoGenerator::FileSystem::MakeParentDirectory( - GenT genType, std::string const& filename) -{ - if (!MakeParentDirectory(filename)) { - Log()->ErrorFile(genType, filename, "Could not create parent directory"); - return false; - } - return true; -} - int cmQtAutoGenerator::ReadOnlyProcessT::PipeT::init(uv_loop_t* uv_loop, ReadOnlyProcessT* process) { diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h index 2993946840..862b18de53 100644 --- a/Source/cmQtAutoGenerator.h +++ b/Source/cmQtAutoGenerator.h @@ -78,13 +78,8 @@ public: class FileSystem { public: - FileSystem(Logger* log) - : Log_(log) - { - } - - /// @brief Logger - Logger* Log() const { return Log_; } + FileSystem(); + ~FileSystem(); // -- Paths /// @brief Wrapper for cmSystemTools::GetRealPath @@ -125,15 +120,9 @@ public: bool FileRead(std::string& content, std::string const& filename, std::string* error = nullptr); - /// @brief Error logging version - bool FileRead(GenT genType, std::string& content, - std::string const& filename); bool FileWrite(std::string const& filename, std::string const& content, std::string* error = nullptr); - /// @brief Error logging version - bool FileWrite(GenT genType, std::string const& filename, - std::string const& content); bool FileDiffers(std::string const& filename, std::string const& content); @@ -142,17 +131,11 @@ public: // -- Directory access bool MakeDirectory(std::string const& dirname); - /// @brief Error logging version - bool MakeDirectory(GenT genType, std::string const& dirname); - bool MakeParentDirectory(std::string const& filename); - /// @brief Error logging version - bool MakeParentDirectory(GenT genType, std::string const& filename); private: std::mutex Mutex_; cmFilePathChecksum FilePathChecksum_; - Logger* Log_; }; /// @brief Return value and output of an external process diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 607576fdc5..32e506750d 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -638,13 +638,15 @@ void cmQtAutoGeneratorMocUic::JobMocPredefsT::Process(WorkerT& wrk) if (!result.error()) { if (!fileExists || wrk.FileSys().FileDiffers(wrk.Moc().PredefsFileAbs, result.StdOut)) { - if (wrk.FileSys().FileWrite(GenT::MOC, wrk.Moc().PredefsFileAbs, - result.StdOut)) { + std::string error; + if (wrk.FileSys().FileWrite(wrk.Moc().PredefsFileAbs, result.StdOut, + &error)) { // Success } else { std::string emsg = "Writing "; emsg += Quoted(wrk.Moc().PredefsFileRel); - emsg += " failed."; + emsg += " failed. "; + emsg += error; wrk.LogFileError(GenT::MOC, wrk.Moc().PredefsFileAbs, emsg); } } else { @@ -835,7 +837,12 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk) void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk) { // Make sure the parent directory exists - if (wrk.FileSys().MakeParentDirectory(GenT::MOC, BuildFile)) { + if (!wrk.FileSys().MakeParentDirectory(BuildFile)) { + wrk.LogFileError(GenT::MOC, BuildFile, + "Could not create parent directory."); + return; + } + { // Compose moc command std::vector<std::string> cmd; cmd.push_back(wrk.Moc().Executable); @@ -950,7 +957,12 @@ bool cmQtAutoGeneratorMocUic::JobUicT::UpdateRequired(WorkerT& wrk) void cmQtAutoGeneratorMocUic::JobUicT::GenerateUic(WorkerT& wrk) { // Make sure the parent directory exists - if (wrk.FileSys().MakeParentDirectory(GenT::UIC, BuildFile)) { + if (!wrk.FileSys().MakeParentDirectory(BuildFile)) { + wrk.LogFileError(GenT::UIC, BuildFile, + "Could not create parent directory."); + return; + } + { // Compose uic command std::vector<std::string> cmd; cmd.push_back(wrk.Uic().Executable); @@ -1126,8 +1138,7 @@ void cmQtAutoGeneratorMocUic::WorkerT::UVProcessFinished() } cmQtAutoGeneratorMocUic::cmQtAutoGeneratorMocUic() - : FileSys_(&Logger_) - , Base_(&FileSys()) + : Base_(&FileSys()) , Moc_(&FileSys()) { // Precompile regular expressions @@ -1692,9 +1703,10 @@ void cmQtAutoGeneratorMocUic::SettingsFileWrite() SettingAppend("uic", SettingsStringUic_); } // Write settings file - if (!FileSys().FileWrite(GenT::GEN, SettingsFile_, content)) { + std::string error; + if (!FileSys().FileWrite(SettingsFile_, content, &error)) { Log().ErrorFile(GenT::GEN, SettingsFile_, - "Settings file writing failed"); + "Settings file writing failed. " + error); // Remove old settings file to trigger a full rebuild on the next run FileSys().FileRemove(SettingsFile_); RegisterJobError(); @@ -1705,7 +1717,9 @@ void cmQtAutoGeneratorMocUic::SettingsFileWrite() void cmQtAutoGeneratorMocUic::CreateDirectories() { // Create AUTOGEN include directory - if (!FileSys().MakeDirectory(GenT::GEN, Base().AutogenIncludeDir)) { + if (!FileSys().MakeDirectory(Base().AutogenIncludeDir)) { + Log().ErrorFile(GenT::GEN, Base().AutogenIncludeDir, + "Could not create directory."); RegisterJobError(); } } @@ -2004,9 +2018,10 @@ void cmQtAutoGeneratorMocUic::MocGenerateCompilation() if (Log().Verbose()) { Log().Info(GenT::MOC, "Generating MOC compilation " + compAbs); } - if (!FileSys().FileWrite(GenT::MOC, compAbs, content)) { + std::string error; + if (!FileSys().FileWrite(compAbs, content, &error)) { Log().ErrorFile(GenT::MOC, compAbs, - "mocs compilation file writing failed"); + "mocs compilation file writing failed. " + error); RegisterJobError(); return; } |