mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-22 07:25:02 +08:00
Autogen: cmQtAutoRcc string concatenation cleanups
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmQtAutoRcc.h"
|
#include "cmQtAutoRcc.h"
|
||||||
#include "cmQtAutoGen.h"
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "cmAlgorithms.h"
|
#include "cmAlgorithms.h"
|
||||||
#include "cmCryptoHash.h"
|
#include "cmCryptoHash.h"
|
||||||
@@ -11,10 +8,10 @@
|
|||||||
#include "cmFileLockResult.h"
|
#include "cmFileLockResult.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmProcessOutput.h"
|
#include "cmProcessOutput.h"
|
||||||
|
#include "cmQtAutoGen.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
#include "cm_string_view.hxx"
|
||||||
// -- Class methods
|
|
||||||
|
|
||||||
cmQtAutoRcc::cmQtAutoRcc() = default;
|
cmQtAutoRcc::cmQtAutoRcc() = default;
|
||||||
|
|
||||||
@@ -23,36 +20,27 @@ cmQtAutoRcc::~cmQtAutoRcc() = default;
|
|||||||
bool cmQtAutoRcc::Init(cmMakefile* makefile)
|
bool cmQtAutoRcc::Init(cmMakefile* makefile)
|
||||||
{
|
{
|
||||||
// -- Utility lambdas
|
// -- Utility lambdas
|
||||||
auto InfoGet = [makefile](std::string const& key) {
|
auto InfoGet = [makefile](cm::string_view key) {
|
||||||
return makefile->GetSafeDefinition(key);
|
return makefile->GetSafeDefinition(std::string(key));
|
||||||
};
|
};
|
||||||
auto InfoGetList =
|
auto InfoGetList =
|
||||||
[makefile](std::string const& key) -> std::vector<std::string> {
|
[makefile](cm::string_view key) -> std::vector<std::string> {
|
||||||
std::vector<std::string> list =
|
return cmExpandedList(makefile->GetSafeDefinition(std::string(key)));
|
||||||
cmExpandedList(makefile->GetSafeDefinition(key));
|
|
||||||
return list;
|
|
||||||
};
|
};
|
||||||
auto InfoGetConfig = [makefile,
|
auto InfoGetConfig = [makefile, this](cm::string_view key) -> std::string {
|
||||||
this](std::string const& key) -> std::string {
|
if (const char* valueConf =
|
||||||
const char* valueConf = nullptr;
|
makefile->GetDefinition(cmStrCat(key, '_', InfoConfig()))) {
|
||||||
{
|
return std::string(valueConf);
|
||||||
std::string keyConf = cmStrCat(key, '_', InfoConfig());
|
|
||||||
valueConf = makefile->GetDefinition(keyConf);
|
|
||||||
}
|
}
|
||||||
if (valueConf == nullptr) {
|
return makefile->GetSafeDefinition(std::string(key));
|
||||||
return makefile->GetSafeDefinition(key);
|
|
||||||
}
|
|
||||||
return std::string(valueConf);
|
|
||||||
};
|
};
|
||||||
auto InfoGetConfigList =
|
auto InfoGetConfigList =
|
||||||
[&InfoGetConfig](std::string const& key) -> std::vector<std::string> {
|
[&InfoGetConfig](cm::string_view key) -> std::vector<std::string> {
|
||||||
std::vector<std::string> list = cmExpandedList(InfoGetConfig(key));
|
return cmExpandedList(InfoGetConfig(key));
|
||||||
return list;
|
|
||||||
};
|
};
|
||||||
auto LogInfoError = [this](std::string const& msg) -> bool {
|
auto LogInfoError = [this](cm::string_view msg) -> bool {
|
||||||
std::ostringstream err;
|
this->Log().Error(GenT::RCC,
|
||||||
err << "In " << Quoted(this->InfoFile()) << ":\n" << msg;
|
cmStrCat("In ", Quoted(this->InfoFile()), ":\n", msg));
|
||||||
this->Log().Error(GenT::RCC, err.str());
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -79,9 +67,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile)
|
|||||||
// - Rcc executable
|
// - Rcc executable
|
||||||
RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE");
|
RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE");
|
||||||
if (!RccExecutableTime_.Load(RccExecutable_)) {
|
if (!RccExecutableTime_.Load(RccExecutable_)) {
|
||||||
std::string error = cmStrCat("The rcc executable ", Quoted(RccExecutable_),
|
return LogInfoError(cmStrCat("The rcc executable ", Quoted(RccExecutable_),
|
||||||
" does not exist.");
|
" does not exist."));
|
||||||
return LogInfoError(error);
|
|
||||||
}
|
}
|
||||||
RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS");
|
RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS");
|
||||||
|
|
||||||
@@ -169,10 +156,8 @@ bool cmQtAutoRcc::Process()
|
|||||||
|
|
||||||
std::string cmQtAutoRcc::MultiConfigOutput() const
|
std::string cmQtAutoRcc::MultiConfigOutput() const
|
||||||
{
|
{
|
||||||
static std::string const suffix = "_CMAKE_";
|
return cmStrCat(RccPathChecksum_, '/',
|
||||||
std::string res = cmStrCat(RccPathChecksum_, '/',
|
AppendFilenameSuffix(RccFileName_, "_CMAKE_"));
|
||||||
AppendFilenameSuffix(RccFileName_, suffix));
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmQtAutoRcc::SettingsFileRead()
|
bool cmQtAutoRcc::SettingsFileRead()
|
||||||
@@ -272,10 +257,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
|
|||||||
{
|
{
|
||||||
// Test if the rcc input file exists
|
// Test if the rcc input file exists
|
||||||
if (!QrcFileTime_.Load(QrcFile_)) {
|
if (!QrcFileTime_.Load(QrcFile_)) {
|
||||||
std::string error;
|
Log().ErrorFile(
|
||||||
error =
|
GenT::RCC, QrcFile_,
|
||||||
cmStrCat("The resources file ", Quoted(QrcFile_), " does not exist");
|
cmStrCat("The resources file ", Quoted(QrcFile_), " does not exist"));
|
||||||
Log().ErrorFile(GenT::RCC, QrcFile_, error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,10 +326,9 @@ bool cmQtAutoRcc::TestResources(bool& generate)
|
|||||||
// Check if the resource file exists
|
// Check if the resource file exists
|
||||||
cmFileTime fileTime;
|
cmFileTime fileTime;
|
||||||
if (!fileTime.Load(resFile)) {
|
if (!fileTime.Load(resFile)) {
|
||||||
std::string error;
|
Log().ErrorFile(GenT::RCC, QrcFile_,
|
||||||
error = cmStrCat("Could not find the resource file\n ", Quoted(resFile),
|
cmStrCat("Could not find the resource file\n ",
|
||||||
'\n');
|
Quoted(resFile), '\n'));
|
||||||
Log().ErrorFile(GenT::RCC, QrcFile_, error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check if the resource file is newer than the rcc output file
|
// Check if the resource file is newer than the rcc output file
|
||||||
@@ -367,10 +350,9 @@ bool cmQtAutoRcc::TestInfoFile()
|
|||||||
// Test if the rcc output file is older than the info file
|
// Test if the rcc output file is older than the info file
|
||||||
if (RccFileTime_.Older(InfoFileTime())) {
|
if (RccFileTime_.Older(InfoFileTime())) {
|
||||||
if (Log().Verbose()) {
|
if (Log().Verbose()) {
|
||||||
std::string reason =
|
Log().Info(GenT::RCC,
|
||||||
cmStrCat("Touching ", Quoted(RccFileOutput_),
|
cmStrCat("Touching ", Quoted(RccFileOutput_),
|
||||||
" because it is older than ", Quoted(InfoFile()));
|
" because it is older than ", Quoted(InfoFile())));
|
||||||
Log().Info(GenT::RCC, reason);
|
|
||||||
}
|
}
|
||||||
// Touch build file
|
// Touch build file
|
||||||
if (!cmSystemTools::Touch(RccFileOutput_, false)) {
|
if (!cmSystemTools::Touch(RccFileOutput_, false)) {
|
||||||
@@ -402,13 +384,9 @@ bool cmQtAutoRcc::GenerateRcc()
|
|||||||
|
|
||||||
// Log reason and command
|
// Log reason and command
|
||||||
if (Log().Verbose()) {
|
if (Log().Verbose()) {
|
||||||
std::string msg = Reason;
|
Log().Info(GenT::RCC,
|
||||||
if (!msg.empty() && (msg.back() != '\n')) {
|
cmStrCat(Reason, cmHasSuffix(Reason, '\n') ? "" : "\n",
|
||||||
msg += '\n';
|
QuotedCommand(cmd), '\n'));
|
||||||
}
|
|
||||||
msg += QuotedCommand(cmd);
|
|
||||||
msg += '\n';
|
|
||||||
Log().Info(GenT::RCC, msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rccStdOut;
|
std::string rccStdOut;
|
||||||
@@ -419,12 +397,11 @@ bool cmQtAutoRcc::GenerateRcc()
|
|||||||
cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
|
cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
|
||||||
if (!result || (retVal != 0)) {
|
if (!result || (retVal != 0)) {
|
||||||
// rcc process failed
|
// rcc process failed
|
||||||
{
|
Log().ErrorCommand(GenT::RCC,
|
||||||
std::string err =
|
cmStrCat("The rcc process failed to compile\n ",
|
||||||
cmStrCat("The rcc process failed to compile\n ", Quoted(QrcFile_),
|
Quoted(QrcFile_), "\ninto\n ",
|
||||||
"\ninto\n ", Quoted(RccFileOutput_));
|
Quoted(RccFileOutput_)),
|
||||||
Log().ErrorCommand(GenT::RCC, err, cmd, rccStdOut + rccStdErr);
|
cmd, rccStdOut + rccStdErr);
|
||||||
}
|
|
||||||
cmSystemTools::RemoveFile(RccFileOutput_);
|
cmSystemTools::RemoveFile(RccFileOutput_);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user