From eff6e622d6cd66186ad42c9ec2ae6b2055008707 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 11 May 2019 21:17:05 +0200 Subject: Autogen: A missing info file is a critical error --- Source/cmQtAutoGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index f7e377d..e1c435b 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -279,10 +279,11 @@ bool cmQtAutoGenerator::Run(std::string const& infoFile, InfoFile_ = infoFile; cmSystemTools::ConvertToUnixSlashes(InfoFile_); if (!InfoFileTime_.Load(InfoFile_)) { - std::string msg = "Autogen: The info file "; + std::string msg = "AutoGen: The info file "; msg += Quoted(InfoFile_); msg += " is not readable\n"; cmSystemTools::Stderr(msg); + return false; } InfoDir_ = cmSystemTools::GetFilenamePath(infoFile); InfoConfig_ = config; -- cgit v0.12 From 081104fb003a56bb3d8330363795ace5b71bc3f8 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 11 May 2019 21:23:29 +0200 Subject: AutoRcc: Write re-generation reason and rcc command as one string In AUTORCC with verbose output write the rcc re-generation reason and the rcc command as on single string to avoid message chopping in concurrent builds. --- Source/cmQtAutoRcc.cxx | 59 +++++++++++++++++++++++++------------------------- Source/cmQtAutoRcc.h | 1 + 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index bb40c39..f841260 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -301,12 +301,10 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) // Test if the rcc output file exists if (!RccFileTime_.Load(RccFileOutput_)) { if (Log().Verbose()) { - std::string reason = "Generating "; - reason += Quoted(RccFileOutput_); - reason += " from its source file "; - reason += Quoted(QrcFile_); - reason += " because it doesn't exist"; - Log().Info(GenT::RCC, reason); + Reason = "Generating "; + Reason += Quoted(RccFileOutput_); + Reason += ", because it doesn't exist, from "; + Reason += Quoted(QrcFile_); } generate = true; return true; @@ -315,12 +313,10 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) // Test if the settings changed if (SettingsChanged_) { if (Log().Verbose()) { - std::string reason = "Generating "; - reason += Quoted(RccFileOutput_); - reason += " from "; - reason += Quoted(QrcFile_); - reason += " because the RCC settings changed"; - Log().Info(GenT::RCC, reason); + Reason = "Generating "; + Reason += Quoted(RccFileOutput_); + Reason += ", because the rcc settings changed, from "; + Reason += Quoted(QrcFile_); } generate = true; return true; @@ -329,11 +325,12 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) // Test if the rcc output file is older than the .qrc file if (RccFileTime_.Older(QrcFileTime_)) { if (Log().Verbose()) { - std::string reason = "Generating "; - reason += Quoted(RccFileOutput_); - reason += " because it is older than "; - reason += Quoted(QrcFile_); - Log().Info(GenT::RCC, reason); + Reason = "Generating "; + Reason += Quoted(RccFileOutput_); + Reason += ", because it is older than "; + Reason += Quoted(QrcFile_); + Reason += ", from "; + Reason += Quoted(QrcFile_); } generate = true; return true; @@ -354,6 +351,7 @@ bool cmQtAutoRcc::TestResources(bool& generate) } } + // Check if any resource file is newer than the rcc output file for (std::string const& resFile : Inputs_) { // Check if the resource file exists cmFileTime fileTime; @@ -365,16 +363,15 @@ bool cmQtAutoRcc::TestResources(bool& generate) Log().ErrorFile(GenT::RCC, QrcFile_, error); return false; } - // Check if the resource file is newer than the build file + // Check if the resource file is newer than the rcc output file if (RccFileTime_.Older(fileTime)) { if (Log().Verbose()) { - std::string reason = "Generating "; - reason += Quoted(RccFileOutput_); - reason += " from "; - reason += Quoted(QrcFile_); - reason += " because it is older than "; - reason += Quoted(resFile); - Log().Info(GenT::RCC, reason); + Reason = "Generating "; + Reason += Quoted(RccFileOutput_); + Reason += ", because it is older than "; + Reason += Quoted(resFile); + Reason += ", from "; + Reason += Quoted(QrcFile_); } generate = true; break; @@ -397,6 +394,7 @@ bool cmQtAutoRcc::TestInfoFile() return false; } if (RccFileTime_.Older(infoFileTime)) { + if (Log().Verbose()) { std::string reason = "Touching "; reason += Quoted(RccFileOutput_); @@ -424,7 +422,7 @@ bool cmQtAutoRcc::GenerateRcc() return false; } - // Start a rcc process + // Compose rcc command std::vector cmd; cmd.push_back(RccExecutable_); cmd.insert(cmd.end(), Options_.begin(), Options_.end()); @@ -432,12 +430,15 @@ bool cmQtAutoRcc::GenerateRcc() cmd.push_back(RccFileOutput_); cmd.push_back(QrcFile_); - // Log command + // Log reason and command if (Log().Verbose()) { - std::string msg = "Running command:\n"; + std::string msg = Reason; + if (!msg.empty() && (msg.back() != '\n')) { + msg += '\n'; + } msg += QuotedCommand(cmd); msg += '\n'; - cmSystemTools::Stdout(msg); + Log().Info(GenT::RCC, msg); } std::string rccStdOut; diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h index 01c3fb9..2dde574 100644 --- a/Source/cmQtAutoRcc.h +++ b/Source/cmQtAutoRcc.h @@ -67,6 +67,7 @@ private: std::string RccFileOutput_; std::string RccFilePublic_; cmFileTime RccFileTime_; + std::string Reason; std::vector Options_; std::vector Inputs_; // -- Settings file -- cgit v0.12 From 54903af84bc8656344e7fe1ea0a11d5f09e94f86 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 11 May 2019 22:13:39 +0200 Subject: AutoRcc: Don't read the info file time again In `AUTORCC` use the info file time that's available already instead of reading it again. --- Source/cmQtAutoRcc.cxx | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index f841260..7063f6a 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -383,18 +383,7 @@ bool cmQtAutoRcc::TestResources(bool& generate) bool cmQtAutoRcc::TestInfoFile() { // Test if the rcc output file is older than the info file - - cmFileTime infoFileTime; - if (!infoFileTime.Load(InfoFile())) { - std::string error; - error = "Could not find the info file "; - error += Quoted(InfoFile()); - error += '\n'; - Log().ErrorFile(GenT::RCC, QrcFile_, error); - return false; - } - if (RccFileTime_.Older(infoFileTime)) { - + if (RccFileTime_.Older(InfoFileTime())) { if (Log().Verbose()) { std::string reason = "Touching "; reason += Quoted(RccFileOutput_); -- cgit v0.12 From bd6c3f8609b87f6995acb2aef21aa572f0f73fa7 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 11 May 2019 21:30:20 +0200 Subject: AutoRcc: Rebuild if the rcc executable is newer than its output In AUTORCC add a test if the rcc executable is newer that the rcc output. If the rcc executable is newer, rebuild the output. --- Source/cmQtAutoRcc.cxx | 19 +++++++++++++++++++ Source/cmQtAutoRcc.h | 1 + 2 files changed, 20 insertions(+) diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index 7063f6a..922767d 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -75,6 +75,13 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) // - Rcc executable RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE"); + if (!RccExecutableTime_.Load(RccExecutable_)) { + std::string error = "The rcc executable "; + error += Quoted(RccExecutable_); + error += " does not exist."; + Log().ErrorFile(GenT::RCC, InfoFile(), error); + return false; + } RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS"); // - Job @@ -336,6 +343,18 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate) return true; } + // Test if the rcc output file is older than the rcc executable + if (RccFileTime_.Older(RccExecutableTime_)) { + if (Log().Verbose()) { + Reason = "Generating "; + Reason += Quoted(RccFileOutput_); + Reason += ", because it is older than the rcc executable, from "; + Reason += Quoted(QrcFile_); + } + generate = true; + return true; + } + return true; } diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h index 2dde574..636a667 100644 --- a/Source/cmQtAutoRcc.h +++ b/Source/cmQtAutoRcc.h @@ -54,6 +54,7 @@ private: std::string IncludeDir_; // -- Qt environment std::string RccExecutable_; + cmFileTime RccExecutableTime_; std::vector RccListOptions_; // -- Job std::string LockFile_; -- cgit v0.12 From 15004e431923035227bf502fe07c6bef2beb2d74 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sat, 11 May 2019 21:39:41 +0200 Subject: AutoRcc: Simplify error logging with utility lambda --- Source/cmQtAutoRcc.cxx | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index 922767d..7ac7339 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -3,6 +3,8 @@ #include "cmQtAutoRcc.h" #include "cmQtAutoGen.h" +#include + #include "cmAlgorithms.h" #include "cmCryptoHash.h" #include "cmDuration.h" @@ -49,11 +51,16 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) cmSystemTools::ExpandListArgument(InfoGetConfig(key), list); return list; }; + auto LogInfoError = [this](std::string const& msg) -> bool { + std::ostringstream err; + err << "In " << Quoted(this->InfoFile()) << ":\n" << msg; + this->Log().Error(GenT::RCC, err.str()); + return false; + }; // -- Read info file if (!makefile->ReadListFile(InfoFile())) { - Log().ErrorFile(GenT::RCC, InfoFile(), "File processing failed."); - return false; + return LogInfoError("File processing failed."); } // - Configurations @@ -63,14 +70,12 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) // - Directories AutogenBuildDir_ = InfoGet("ARCC_BUILD_DIR"); if (AutogenBuildDir_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "Build directory empty."); - return false; + return LogInfoError("Build directory empty."); } IncludeDir_ = InfoGetConfig("ARCC_INCLUDE_DIR"); if (IncludeDir_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "Include directory empty."); - return false; + return LogInfoError("Include directory empty."); } // - Rcc executable @@ -79,8 +84,7 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) std::string error = "The rcc executable "; error += Quoted(RccExecutable_); error += " does not exist."; - Log().ErrorFile(GenT::RCC, InfoFile(), error); - return false; + return LogInfoError(error); } RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS"); @@ -99,28 +103,22 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) // - Validity checks if (LockFile_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "Lock file name missing."); - return false; + return LogInfoError("Lock file name missing."); } if (SettingsFile_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "Settings file name missing."); - return false; + return LogInfoError("Settings file name missing."); } if (AutogenBuildDir_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "Autogen build directory missing."); - return false; + return LogInfoError("Autogen build directory missing."); } if (RccExecutable_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "rcc executable missing."); - return false; + return LogInfoError("rcc executable missing."); } if (QrcFile_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "rcc input file missing."); - return false; + return LogInfoError("rcc input file missing."); } if (RccFileName_.empty()) { - Log().ErrorFile(GenT::RCC, InfoFile(), "rcc output file missing."); - return false; + return LogInfoError("rcc output file missing."); } // Init derived information -- cgit v0.12