summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-05-13 14:41:50 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-05-13 14:42:02 (GMT)
commitf9feab40a195716a6bba11b39a809a18830df956 (patch)
tree3b0293538f62412bc21daaa2359ef22fb05a095f
parentdf6c4afa777098c6a2fcc01e4513ab5a6e444bc7 (diff)
parent15004e431923035227bf502fe07c6bef2beb2d74 (diff)
downloadCMake-f9feab40a195716a6bba11b39a809a18830df956.zip
CMake-f9feab40a195716a6bba11b39a809a18830df956.tar.gz
CMake-f9feab40a195716a6bba11b39a809a18830df956.tar.bz2
Merge topic 'autorcc_timestamp'
15004e4319 AutoRcc: Simplify error logging with utility lambda bd6c3f8609 AutoRcc: Rebuild if the rcc executable is newer than its output 54903af84b AutoRcc: Don't read the info file time again 081104fb00 AutoRcc: Write re-generation reason and rcc command as one string eff6e622d6 Autogen: A missing info file is a critical error Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3311
-rw-r--r--Source/cmQtAutoGenerator.cxx3
-rw-r--r--Source/cmQtAutoRcc.cxx123
-rw-r--r--Source/cmQtAutoRcc.h2
3 files changed, 69 insertions, 59 deletions
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;
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
index bb40c39..7ac7339 100644
--- a/Source/cmQtAutoRcc.cxx
+++ b/Source/cmQtAutoRcc.cxx
@@ -3,6 +3,8 @@
#include "cmQtAutoRcc.h"
#include "cmQtAutoGen.h"
+#include <sstream>
+
#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,18 +70,22 @@ 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
RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE");
+ if (!RccExecutableTime_.Load(RccExecutable_)) {
+ std::string error = "The rcc executable ";
+ error += Quoted(RccExecutable_);
+ error += " does not exist.";
+ return LogInfoError(error);
+ }
RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS");
// - Job
@@ -92,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
@@ -301,12 +306,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 +318,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 +330,24 @@ 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;
+ }
+
+ // 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;
@@ -354,6 +368,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 +380,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;
@@ -386,17 +400,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_);
@@ -424,7 +428,7 @@ bool cmQtAutoRcc::GenerateRcc()
return false;
}
- // Start a rcc process
+ // Compose rcc command
std::vector<std::string> cmd;
cmd.push_back(RccExecutable_);
cmd.insert(cmd.end(), Options_.begin(), Options_.end());
@@ -432,12 +436,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..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<std::string> RccListOptions_;
// -- Job
std::string LockFile_;
@@ -67,6 +68,7 @@ private:
std::string RccFileOutput_;
std::string RccFilePublic_;
cmFileTime RccFileTime_;
+ std::string Reason;
std::vector<std::string> Options_;
std::vector<std::string> Inputs_;
// -- Settings file