summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerator.h
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-09-20 20:39:13 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-25 14:07:09 (GMT)
commitd867e058924d348ee5ec5bba867965e8f1f276e2 (patch)
tree630f67b2bcce99327a769ef591b1f1698cf76742 /Source/cmQtAutoGenerator.h
parent881e3cfbf96c7b4f48304d3dfc07899c2e6703de (diff)
downloadCMake-d867e058924d348ee5ec5bba867965e8f1f276e2.zip
CMake-d867e058924d348ee5ec5bba867965e8f1f276e2.tar.gz
CMake-d867e058924d348ee5ec5bba867965e8f1f276e2.tar.bz2
Autogen: Use JSON instead of CMake script for info files
We used to store information for the _autogen target in a CMake script file AutogenInfo.cmake, which was imported by a temporary cmake instance in the _autogen target. This introduced the overhead of creating a temporary cmake instance and inherited the limitations of the CMake language which only supports lists. This patch introduces JSON files to pass information to AUTORCC and autogen_ targets. JSON files are more flexible for passing data, e.g. they support nested lists. The patch has the side effects that - AutogenInfo.cmake is renamed to AutogenInfo.json - AutogenOldSettings.txt is renamed to AutogenUsed.txt - RCC<qrcBaseName><checksum>Info.cmake is renamed to AutoRcc_<qrcBaseName>_<checksum>_Info.json - RCC<qrcBaseName><checksum>.lock is renamed to AutoRcc_<qrcBaseName>_<checksum>_Lock.lock - RCC<qrcBaseName><checksum>Settings.txt is renamed to AutoRcc_<qrcBaseName>_<checksum>_Used.txt
Diffstat (limited to 'Source/cmQtAutoGenerator.h')
-rw-r--r--Source/cmQtAutoGenerator.h49
1 files changed, 42 insertions, 7 deletions
diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h
index f60acb0..7f83fc6 100644
--- a/Source/cmQtAutoGenerator.h
+++ b/Source/cmQtAutoGenerator.h
@@ -7,15 +7,15 @@
#include "cmFileTime.h"
#include "cmQtAutoGen.h"
+#include "cm_jsoncpp_value.h"
#include <cm/string_view>
#include <mutex>
#include <string>
+#include <unordered_set>
#include <vector>
-class cmMakefile;
-
/** \class cmQtAutoGenerator
* \brief Base class for QtAutoGen generators
*/
@@ -34,7 +34,7 @@ public:
// -- Verbosity
unsigned int Verbosity() const { return this->Verbosity_; }
void SetVerbosity(unsigned int value) { this->Verbosity_ = value; }
- void RaiseVerbosity(std::string const& value);
+ void RaiseVerbosity(unsigned int value);
bool Verbose() const { return (this->Verbosity_ != 0); }
void SetVerbose(bool value) { this->Verbosity_ = value ? 1 : 0; }
// -- Color output
@@ -80,7 +80,7 @@ public:
public:
// -- Constructors
- cmQtAutoGenerator();
+ cmQtAutoGenerator(GenT genType);
virtual ~cmQtAutoGenerator();
cmQtAutoGenerator(cmQtAutoGenerator const&) = delete;
@@ -91,10 +91,39 @@ public:
// -- InfoFile
std::string const& InfoFile() const { return InfoFile_; }
+ Json::Value const& Info() const { return Info_; }
cmFileTime const& InfoFileTime() const { return InfoFileTime_; }
std::string const& InfoDir() const { return InfoDir_; }
std::string const& InfoConfig() const { return InfoConfig_; }
+ bool LogInfoError(GenT genType, cm::string_view message) const;
+ bool LogInfoError(cm::string_view message) const;
+
+ /** Returns true if strings were appended to the list. */
+ static bool JsonGetArray(std::vector<std::string>& list,
+ Json::Value const& jval);
+ /** Returns true if strings were found in the JSON array. */
+ static bool JsonGetArray(std::unordered_set<std::string>& list,
+ Json::Value const& jval);
+
+ std::string InfoConfigKey(std::string const& key) const;
+
+ /** Returns false if the JSON value isn't a string. */
+ bool InfoString(std::string const& key, std::string& value,
+ bool required) const;
+ bool InfoStringConfig(std::string const& key, std::string& value,
+ bool required) const;
+ bool InfoBool(std::string const& key, bool& value, bool required) const;
+ bool InfoUInt(std::string const& key, unsigned int& value,
+ bool required) const;
+ /** Returns false if the JSON value isn't an array. */
+ bool InfoArray(std::string const& key, std::vector<std::string>& list,
+ bool required) const;
+ bool InfoArray(std::string const& key, std::unordered_set<std::string>& list,
+ bool required) const;
+ bool InfoArrayConfig(std::string const& key, std::vector<std::string>& list,
+ bool required) const;
+
// -- Directories
ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; }
@@ -104,16 +133,22 @@ public:
protected:
// -- Abstract processing interface
- virtual bool Init(cmMakefile* makefile) = 0;
+ virtual bool InitFromInfo() = 0;
virtual bool Process() = 0;
- ProjectDirsT& ProjectDirsRef() { return ProjectDirs_; }
+ // - Utility classes
+ Logger const& Log() const { return Logger_; }
private:
- // -- Info settings
+ // -- Generator type
+ GenT GenType_;
+ // -- Logging
+ Logger Logger_;
+ // -- Info file
std::string InfoFile_;
cmFileTime InfoFileTime_;
std::string InfoDir_;
std::string InfoConfig_;
+ Json::Value Info_;
// -- Directories
ProjectDirsT ProjectDirs_;
};