| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
- #ifndef cmQtAutoGenerator_h
- #define cmQtAutoGenerator_h
- #include "cmConfigure.h" // IWYU pragma: keep
- #include "cmFileTime.h"
- #include "cmQtAutoGen.h"
- #include <cm/string_view>
- #include <mutex>
- #include <string>
- #include <vector>
- class cmMakefile;
- /** \class cmQtAutoGenerator
- * \brief Base class for QtAutoGen generators
- */
- class cmQtAutoGenerator : public cmQtAutoGen
- {
- public:
- // -- Types
- /** Thread safe logger. */
- class Logger
- {
- public:
- // -- Construction
- Logger();
- ~Logger();
- // -- Verbosity
- unsigned int Verbosity() const { return this->Verbosity_; }
- void SetVerbosity(unsigned int value) { this->Verbosity_ = value; }
- void RaiseVerbosity(std::string const& value);
- bool Verbose() const { return (this->Verbosity_ != 0); }
- void SetVerbose(bool value) { this->Verbosity_ = value ? 1 : 0; }
- // -- Color output
- bool ColorOutput() const { return this->ColorOutput_; }
- void SetColorOutput(bool value);
- // -- Log info
- void Info(GenT genType, cm::string_view message) const;
- // -- Log warning
- void Warning(GenT genType, cm::string_view message) const;
- // -- Log error
- void Error(GenT genType, cm::string_view message) const;
- void ErrorCommand(GenT genType, cm::string_view message,
- std::vector<std::string> const& command,
- std::string const& output) const;
- private:
- static std::string HeadLine(cm::string_view title);
- private:
- mutable std::mutex Mutex_;
- unsigned int Verbosity_ = 0;
- bool ColorOutput_ = false;
- };
- /** Project directories. */
- struct ProjectDirsT
- {
- std::string Source;
- std::string Binary;
- std::string CurrentSource;
- std::string CurrentBinary;
- };
- // -- File system methods
- static bool MakeParentDirectory(std::string const& filename);
- static bool FileRead(std::string& content, std::string const& filename,
- std::string* error = nullptr);
- static bool FileWrite(std::string const& filename,
- std::string const& content,
- std::string* error = nullptr);
- static bool FileDiffers(std::string const& filename,
- std::string const& content);
- public:
- // -- Constructors
- cmQtAutoGenerator();
- virtual ~cmQtAutoGenerator();
- cmQtAutoGenerator(cmQtAutoGenerator const&) = delete;
- cmQtAutoGenerator& operator=(cmQtAutoGenerator const&) = delete;
- // -- Run
- bool Run(std::string const& infoFile, std::string const& config);
- // -- InfoFile
- std::string const& InfoFile() const { return InfoFile_; }
- cmFileTime const& InfoFileTime() const { return InfoFileTime_; }
- std::string const& InfoDir() const { return InfoDir_; }
- std::string const& InfoConfig() const { return InfoConfig_; }
- // -- Directories
- ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; }
- // -- Utility
- static std::string SettingsFind(std::string const& content, const char* key);
- std::string MessagePath(cm::string_view path) const;
- protected:
- // -- Abstract processing interface
- virtual bool Init(cmMakefile* makefile) = 0;
- virtual bool Process() = 0;
- ProjectDirsT& ProjectDirsRef() { return ProjectDirs_; }
- private:
- // -- Info settings
- std::string InfoFile_;
- cmFileTime InfoFileTime_;
- std::string InfoDir_;
- std::string InfoConfig_;
- // -- Directories
- ProjectDirsT ProjectDirs_;
- };
- #endif
|