diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-09-27 13:49:13 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-09-28 22:07:32 (GMT) |
commit | e0e9be3d575a255add19169d174c869fdebebbeb (patch) | |
tree | 9d8206c6415a65ff499e4fa8c411e568aaaf0f6d /Source/cmQtAutoRcc.cxx | |
parent | 820962edc9dd7481c440068dd894c1026abf671d (diff) | |
download | CMake-e0e9be3d575a255add19169d174c869fdebebbeb.zip CMake-e0e9be3d575a255add19169d174c869fdebebbeb.tar.gz CMake-e0e9be3d575a255add19169d174c869fdebebbeb.tar.bz2 |
Autogen: Make cmQtAutoRcc a free function
Diffstat (limited to 'Source/cmQtAutoRcc.cxx')
-rw-r--r-- | Source/cmQtAutoRcc.cxx | 103 |
1 files changed, 89 insertions, 14 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); +} |