summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenInitializer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenInitializer.cxx133
1 files changed, 19 insertions, 114 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index ef8fe73..be96f1a 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -7,7 +7,6 @@
#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
-#include "cmDuration.h"
#include "cmFilePathChecksum.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
@@ -19,7 +18,6 @@
#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
-#include "cmProcessOutput.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocationKind.h"
#include "cmSourceGroup.h"
@@ -28,7 +26,6 @@
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmake.h"
-#include "cmsys/FStream.hxx"
#include "cmsys/SystemInformation.hxx"
#include <algorithm>
@@ -36,7 +33,6 @@
#include <deque>
#include <map>
#include <set>
-#include <sstream>
#include <string>
#include <utility>
#include <vector>
@@ -606,28 +602,19 @@ bool cmQtAutoGenInitializer::InitRcc()
bool cmQtAutoGenInitializer::InitScanFiles()
{
cmMakefile* makefile = this->Target->Target->GetMakefile();
+ auto const& kw = this->GlobalInitializer->kw();
- // String constants
- std::string const SKIP_AUTOGEN_str = "SKIP_AUTOGEN";
- std::string const SKIP_AUTOMOC_str = "SKIP_AUTOMOC";
- std::string const SKIP_AUTOUIC_str = "SKIP_AUTOUIC";
- std::string const SKIP_AUTORCC_str = "SKIP_AUTORCC";
- std::string const AUTOUIC_OPTIONS_str = "AUTOUIC_OPTIONS";
- std::string const AUTORCC_OPTIONS_str = "AUTORCC_OPTIONS";
- std::string const qrc_str = "qrc";
- std::string const ui_str = "ui";
-
- auto makeMUFile = [&](cmSourceFile* sf, std::string const& fullPath,
- bool muIt) -> MUFileHandle {
+ auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath,
+ bool muIt) -> MUFileHandle {
MUFileHandle muf = cm::make_unique<MUFile>();
muf->RealPath = cmSystemTools::GetRealPath(fullPath);
muf->SF = sf;
muf->Generated = sf->GetIsGenerated();
- bool const skipAutogen = sf->GetPropertyAsBool(SKIP_AUTOGEN_str);
+ bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
muf->SkipMoc = this->Moc.Enabled &&
- (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOMOC_str));
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOMOC));
muf->SkipUic = this->Uic.Enabled &&
- (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOUIC_str));
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
if (muIt) {
muf->MocIt = this->Moc.Enabled && !muf->SkipMoc;
muf->UicIt = this->Uic.Enabled && !muf->SkipUic;
@@ -678,8 +665,8 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// Register rcc enabled files
if (this->Rcc.Enabled) {
- if ((ext == qrc_str) && !sf->GetPropertyAsBool(SKIP_AUTOGEN_str) &&
- !sf->GetPropertyAsBool(SKIP_AUTORCC_str)) {
+ if ((ext == kw.qrc) && !sf->GetPropertyAsBool(kw.SKIP_AUTOGEN) &&
+ !sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) {
// Register qrc file
Qrc qrc;
qrc.QrcFile = cmSystemTools::GetRealPath(fullPath);
@@ -688,7 +675,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
qrc.Generated = sf->GetIsGenerated();
// RCC options
{
- std::string const opts = sf->GetSafeProperty(AUTORCC_OPTIONS_str);
+ std::string const opts = sf->GetSafeProperty(kw.AUTORCC_OPTIONS);
if (!opts.empty()) {
cmSystemTools::ExpandListArgument(opts, qrc.Options);
}
@@ -798,15 +785,15 @@ bool cmQtAutoGenInitializer::InitScanFiles()
this->AutogenTarget.Sources.emplace(sf, std::move(muf));
}
}
- } else if (this->Uic.Enabled && (ext == ui_str)) {
+ } else if (this->Uic.Enabled && (ext == kw.ui)) {
// .ui file
std::string realPath = cmSystemTools::GetRealPath(fullPath);
- bool const skipAutogen = sf->GetPropertyAsBool(SKIP_AUTOGEN_str);
+ bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
bool const skipUic =
- (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOUIC_str));
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
if (!skipUic) {
// Check if the .ui file has uic options
- std::string const uicOpts = sf->GetSafeProperty(AUTOUIC_OPTIONS_str);
+ std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS);
if (!uicOpts.empty()) {
this->Uic.FileFiles.push_back(std::move(realPath));
std::vector<std::string> optsVec;
@@ -834,11 +821,11 @@ bool cmQtAutoGenInitializer::InitScanFiles()
msg += '\n';
std::string property;
if (this->Moc.Enabled && this->Uic.Enabled) {
- property = "SKIP_AUTOGEN";
+ property = kw.SKIP_AUTOGEN;
} else if (this->Moc.Enabled) {
- property = "SKIP_AUTOMOC";
+ property = kw.SKIP_AUTOMOC;
} else if (this->Uic.Enabled) {
- property = "SKIP_AUTOUIC";
+ property = kw.SKIP_AUTOUIC;
}
msg += "For compatibility, CMake is excluding the GENERATED source "
"file(s):\n";
@@ -866,7 +853,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// Target rcc options
std::vector<std::string> optionsTarget;
cmSystemTools::ExpandListArgument(
- this->Target->GetSafeProperty("AUTORCC_OPTIONS"), optionsTarget);
+ this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS), optionsTarget);
// Check if file name is unique
for (Qrc& qrc : this->Rcc.Qrcs) {
@@ -944,7 +931,8 @@ bool cmQtAutoGenInitializer::InitScanFiles()
for (Qrc& qrc : this->Rcc.Qrcs) {
if (!qrc.Generated) {
std::string error;
- if (!RccListInputs(qrc.QrcFile, qrc.Resources, error)) {
+ RccLister const lister(this->Rcc.Executable, this->Rcc.ListOptions);
+ if (!lister.list(qrc.QrcFile, qrc.Resources, error)) {
cmSystemTools::Error(error);
return false;
}
@@ -1639,86 +1627,3 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
return true;
}
-
-/// @brief Reads the resource files list from from a .qrc file
-/// @arg fileName Must be the absolute path of the .qrc file
-/// @return True if the rcc file was successfully read
-bool cmQtAutoGenInitializer::RccListInputs(std::string const& fileName,
- std::vector<std::string>& files,
- std::string& error)
-{
- if (!cmSystemTools::FileExists(fileName)) {
- error = "rcc resource file does not exist:\n ";
- error += Quoted(fileName);
- error += "\n";
- return false;
- }
- if (this->Rcc.ExecutableExists && !this->Rcc.ListOptions.empty()) {
- // Use rcc for file listing
- if (this->Rcc.Executable.empty()) {
- error = "rcc executable not available";
- return false;
- }
-
- // Run rcc list command in the directory of the qrc file with the
- // pathless
- // qrc file name argument. This way rcc prints relative paths.
- // This avoids issues on Windows when the qrc file is in a path that
- // contains non-ASCII characters.
- std::string const fileDir = cmSystemTools::GetFilenamePath(fileName);
- std::string const fileNameName = cmSystemTools::GetFilenameName(fileName);
-
- bool result = false;
- int retVal = 0;
- std::string rccStdOut;
- std::string rccStdErr;
- {
- std::vector<std::string> cmd;
- cmd.push_back(this->Rcc.Executable);
- cmd.insert(cmd.end(), this->Rcc.ListOptions.begin(),
- this->Rcc.ListOptions.end());
- cmd.push_back(fileNameName);
- result = cmSystemTools::RunSingleCommand(
- cmd, &rccStdOut, &rccStdErr, &retVal, fileDir.c_str(),
- cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
- }
- if (!result || retVal) {
- error = "rcc list process failed for:\n ";
- error += Quoted(fileName);
- error += "\n";
- error += rccStdOut;
- error += "\n";
- error += rccStdErr;
- error += "\n";
- return false;
- }
- if (!RccListParseOutput(rccStdOut, rccStdErr, files, error)) {
- return false;
- }
- } else {
- // We can't use rcc for the file listing.
- // Read the qrc file content into string and parse it.
- {
- std::string qrcContents;
- {
- cmsys::ifstream ifs(fileName.c_str());
- if (ifs) {
- std::ostringstream osst;
- osst << ifs.rdbuf();
- qrcContents = osst.str();
- } else {
- error = "rcc file not readable:\n ";
- error += Quoted(fileName);
- error += "\n";
- return false;
- }
- }
- // Parse string content
- RccListParseContent(qrcContents, files);
- }
- }
-
- // Convert relative paths to absolute paths
- RccListConvertFullPath(cmSystemTools::GetFilenamePath(fileName), files);
- return true;
-}