summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-09-27 13:49:13 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-09-28 22:07:32 (GMT)
commite0e9be3d575a255add19169d174c869fdebebbeb (patch)
tree9d8206c6415a65ff499e4fa8c411e568aaaf0f6d /Source
parent820962edc9dd7481c440068dd894c1026abf671d (diff)
downloadCMake-e0e9be3d575a255add19169d174c869fdebebbeb.zip
CMake-e0e9be3d575a255add19169d174c869fdebebbeb.tar.gz
CMake-e0e9be3d575a255add19169d174c869fdebebbeb.tar.bz2
Autogen: Make cmQtAutoRcc a free function
Diffstat (limited to 'Source')
-rw-r--r--Source/cmQtAutoRcc.cxx103
-rw-r--r--Source/cmQtAutoRcc.h72
-rw-r--r--Source/cmcmd.cxx3
3 files changed, 95 insertions, 83 deletions
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
index 579cda7..4a3ecfa 100644
--- a/Source/cmQtAutoRcc.cxx
+++ b/Source/cmQtAutoRcc.cxx
@@ -5,23 +5,91 @@
#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
#include "cmDuration.h"
+#include "cmFileLock.h"
#include "cmFileLockResult.h"
+#include "cmFileTime.h"
#include "cmProcessOutput.h"
#include "cmQtAutoGen.h"
+#include "cmQtAutoGenerator.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <cm/string_view>
-
#include <algorithm>
+#include <string>
+#include <vector>
+
+namespace {
-cmQtAutoRcc::cmQtAutoRcc()
+/** \class cmQtAutoRccT
+ * \brief AUTORCC generator
+ */
+class cmQtAutoRccT : public cmQtAutoGenerator
+{
+public:
+ cmQtAutoRccT();
+ ~cmQtAutoRccT() override;
+
+ cmQtAutoRccT(cmQtAutoRccT const&) = delete;
+ cmQtAutoRccT& operator=(cmQtAutoRccT const&) = delete;
+
+private:
+ // -- Utility
+ bool IsMultiConfig() const { return MultiConfig_; }
+ std::string MultiConfigOutput() const;
+
+ // -- Abstract processing interface
+ bool InitFromInfo(InfoT const& info) override;
+ bool Process() override;
+ // -- Settings file
+ bool SettingsFileRead();
+ bool SettingsFileWrite();
+ // -- Tests
+ bool TestQrcRccFiles(bool& generate);
+ bool TestResources(bool& generate);
+ bool TestInfoFile();
+ // -- Generation
+ bool GenerateRcc();
+ bool GenerateWrapper();
+
+private:
+ // -- Config settings
+ bool MultiConfig_ = false;
+ // -- Directories
+ std::string AutogenBuildDir_;
+ std::string IncludeDir_;
+ // -- Qt environment
+ std::string RccExecutable_;
+ cmFileTime RccExecutableTime_;
+ std::vector<std::string> RccListOptions_;
+ // -- Job
+ std::string LockFile_;
+ cmFileLock LockFileLock_;
+ std::string QrcFile_;
+ std::string QrcFileName_;
+ std::string QrcFileDir_;
+ cmFileTime QrcFileTime_;
+ std::string RccPathChecksum_;
+ std::string RccFileName_;
+ std::string RccFileOutput_;
+ std::string RccFilePublic_;
+ cmFileTime RccFileTime_;
+ std::string Reason;
+ std::vector<std::string> Options_;
+ std::vector<std::string> Inputs_;
+ // -- Settings file
+ std::string SettingsFile_;
+ std::string SettingsString_;
+ bool SettingsChanged_ = false;
+ bool BuildFileChanged_ = false;
+};
+
+cmQtAutoRccT::cmQtAutoRccT()
: cmQtAutoGenerator(GenT::RCC)
{
}
-cmQtAutoRcc::~cmQtAutoRcc() = default;
+cmQtAutoRccT::~cmQtAutoRccT() = default;
-bool cmQtAutoRcc::InitFromInfo(InfoT const& info)
+bool cmQtAutoRccT::InitFromInfo(InfoT const& info)
{
// -- Required settings
if (!info.GetBool("MULTI_CONFIG", MultiConfig_, true) ||
@@ -61,7 +129,7 @@ bool cmQtAutoRcc::InitFromInfo(InfoT const& info)
return true;
}
-bool cmQtAutoRcc::Process()
+bool cmQtAutoRccT::Process()
{
if (!SettingsFileRead()) {
return false;
@@ -94,13 +162,13 @@ bool cmQtAutoRcc::Process()
return SettingsFileWrite();
}
-std::string cmQtAutoRcc::MultiConfigOutput() const
+std::string cmQtAutoRccT::MultiConfigOutput() const
{
return cmStrCat(RccPathChecksum_, '/',
AppendFilenameSuffix(RccFileName_, "_CMAKE_"));
}
-bool cmQtAutoRcc::SettingsFileRead()
+bool cmQtAutoRccT::SettingsFileRead()
{
// Compose current settings strings
{
@@ -178,7 +246,7 @@ bool cmQtAutoRcc::SettingsFileRead()
return true;
}
-bool cmQtAutoRcc::SettingsFileWrite()
+bool cmQtAutoRccT::SettingsFileWrite()
{
// Only write if any setting changed
if (SettingsChanged_) {
@@ -205,7 +273,7 @@ bool cmQtAutoRcc::SettingsFileWrite()
}
/// Do basic checks if rcc generation is required
-bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
+bool cmQtAutoRccT::TestQrcRccFiles(bool& generate)
{
// Test if the rcc input file exists
if (!QrcFileTime_.Load(QrcFile_)) {
@@ -262,7 +330,7 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
return true;
}
-bool cmQtAutoRcc::TestResources(bool& generate)
+bool cmQtAutoRccT::TestResources(bool& generate)
{
// Read resource files list
if (Inputs_.empty()) {
@@ -301,7 +369,7 @@ bool cmQtAutoRcc::TestResources(bool& generate)
return true;
}
-bool cmQtAutoRcc::TestInfoFile()
+bool cmQtAutoRccT::TestInfoFile()
{
// Test if the rcc output file is older than the info file
if (RccFileTime_.Older(InfoFileTime())) {
@@ -324,7 +392,7 @@ bool cmQtAutoRcc::TestInfoFile()
return true;
}
-bool cmQtAutoRcc::GenerateRcc()
+bool cmQtAutoRccT::GenerateRcc()
{
// Make parent directory
if (!MakeParentDirectory(RccFileOutput_)) {
@@ -376,7 +444,7 @@ bool cmQtAutoRcc::GenerateRcc()
return true;
}
-bool cmQtAutoRcc::GenerateWrapper()
+bool cmQtAutoRccT::GenerateWrapper()
{
// Generate a wrapper source file on demand
if (IsMultiConfig()) {
@@ -426,3 +494,10 @@ bool cmQtAutoRcc::GenerateWrapper()
}
return true;
}
+
+} // End of unnamed namespace
+
+bool cmQtAutoRcc(cm::string_view infoFile, cm::string_view config)
+{
+ return cmQtAutoRccT().Run(infoFile, config);
+}
diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h
index 33c7960..a74b33a 100644
--- a/Source/cmQtAutoRcc.h
+++ b/Source/cmQtAutoRcc.h
@@ -5,74 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmFileLock.h"
-#include "cmFileTime.h"
-#include "cmQtAutoGenerator.h"
+#include <cm/string_view>
-#include <string>
-#include <vector>
-
-/** \class cmQtAutoRcc
- * \brief AUTORCC generator
+/**
+ * Process AUTORCC
+ * @return true on success
*/
-class cmQtAutoRcc : public cmQtAutoGenerator
-{
-public:
- cmQtAutoRcc();
- ~cmQtAutoRcc() override;
-
- cmQtAutoRcc(cmQtAutoRcc const&) = delete;
- cmQtAutoRcc& operator=(cmQtAutoRcc const&) = delete;
-
-private:
- // -- Utility
- bool IsMultiConfig() const { return MultiConfig_; }
- std::string MultiConfigOutput() const;
-
- // -- Abstract processing interface
- bool InitFromInfo(InfoT const& info) override;
- bool Process() override;
- // -- Settings file
- bool SettingsFileRead();
- bool SettingsFileWrite();
- // -- Tests
- bool TestQrcRccFiles(bool& generate);
- bool TestResources(bool& generate);
- bool TestInfoFile();
- // -- Generation
- bool GenerateRcc();
- bool GenerateWrapper();
-
-private:
- // -- Config settings
- bool MultiConfig_ = false;
- // -- Directories
- std::string AutogenBuildDir_;
- std::string IncludeDir_;
- // -- Qt environment
- std::string RccExecutable_;
- cmFileTime RccExecutableTime_;
- std::vector<std::string> RccListOptions_;
- // -- Job
- std::string LockFile_;
- cmFileLock LockFileLock_;
- std::string QrcFile_;
- std::string QrcFileName_;
- std::string QrcFileDir_;
- cmFileTime QrcFileTime_;
- std::string RccPathChecksum_;
- std::string RccFileName_;
- std::string RccFileOutput_;
- std::string RccFilePublic_;
- cmFileTime RccFileTime_;
- std::string Reason;
- std::vector<std::string> Options_;
- std::vector<std::string> Inputs_;
- // -- Settings file
- std::string SettingsFile_;
- std::string SettingsString_;
- bool SettingsChanged_ = false;
- bool BuildFileChanged_ = false;
-};
+bool cmQtAutoRcc(cm::string_view infoFile, cm::string_view config);
#endif
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index b6076db..f075e21 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1065,11 +1065,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
return autoGen.Run(infoFile, config) ? 0 : 1;
}
if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) {
- cmQtAutoRcc autoRcc;
cm::string_view const infoFile = args[2];
cm::string_view const config =
(args.size() > 3) ? cm::string_view(args[3]) : cm::string_view();
- return autoRcc.Run(infoFile, config) ? 0 : 1;
+ return cmQtAutoRcc(infoFile, config) ? 0 : 1;
}
#endif