summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerator.h
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-05-02 09:03:13 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-05-07 10:42:19 (GMT)
commit7d50e1c6118b292ea3061ec9fee0230c5d50a5ff (patch)
tree48d3f4c459c88cc2c02fa78b0279324e2fbb5cce /Source/cmQtAutoGenerator.h
parentc6f6e2b3053de02de149e80bd6a0f686a6731f68 (diff)
downloadCMake-7d50e1c6118b292ea3061ec9fee0230c5d50a5ff.zip
CMake-7d50e1c6118b292ea3061ec9fee0230c5d50a5ff.tar.gz
CMake-7d50e1c6118b292ea3061ec9fee0230c5d50a5ff.tar.bz2
Autogen: Refactor AUTOMOC and AUTOUIC and add source file parse data caching
New features ------------ CMake's `AUTOMOC` and `AUTOUIC` now cache information extracted when parsing source files in `CMakeFiles/<ORIGIN>_autogen.dir/ParseCache.txt`. This leads to faster `<ORIGIN>_autogen` target rebuilds, because source files will be parsed again only if they're newer than the `ParseCache.txt` file. The parse cache will be recomputed if it is older than the CMake executable. `AUTOMOC` and `AUTOUIC` now check if `moc` or `uic` output files are older than the `moc` or `uic` executable. If an output file is older than the compiler, it will be regenerated. Therefore if a new `moc` or `uic` version is installed, all output files will be regenerated. `AUTOMOC` and `AUTOUIC` error and warning messages are more detailed. Internal changes ---------------- `moc` and `uic` output file names are not computed in the `_autogen` target anymore but in `cmQtAutoGenInitializer`. This makes the available at the configuration stage for improved dependency computations (to be done). In `AutogenInfo.cmake`, equally sized lists for "source file names", "source file flags" and "compiler output file names" are passed to the `_autogen` target. This replaces the separate file lists for `AUTOMOC` and `AUTOUIC`. Files times are read from the file system only once by using `cmFileTime` instances instead of `cmQtAutoGenerator::FileSystem::FileIsOlderThan` calls. All calls to not thread safe file system functions are moved to non concurrent fence jobs (see `cmWorkerPool::JobT::IsFence()`). This renders the `cmQtAutoGenerator::FileSystem` wrapper class obsolete and it is removed. Instead of composing a single large settings string that is fed to the `cmCryptoHash`, now all setting sub strings are fed one by one to the `cmCryptoHash` and the finalized result is stored. The `std::mutex` in `cmQtAutoGenerator::Logger` is tagged `mutable` and most `cmQtAutoGenerator::Logger` methods become `const`. Outlook ------- This patch provides the framework required to - extract dependencies from `.ui` files in `AUTOUIC`. These will help to address issue #15420 "AUTOUIC: Track uic external inputs". - generate adaptive `make` and `ninja` files in the `_autogen` target. These will help to address issue #16776 "AUTOUIC: Ninja needs two passes to correctly build Qt project". - generate (possibly empty) `moc` and `uic` files for all headers instead of a `mocs_compilation.cpp` file. This will help to address issue #17277 "AUTOMOC: Provide a option to allow AUTOMOC to compile individual " "moc_x.cxx instead of including all in mocs_compilation.cxx"
Diffstat (limited to 'Source/cmQtAutoGenerator.h')
-rw-r--r--Source/cmQtAutoGenerator.h94
1 files changed, 19 insertions, 75 deletions
diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h
index 437fa20..ff4c4c9 100644
--- a/Source/cmQtAutoGenerator.h
+++ b/Source/cmQtAutoGenerator.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmFilePathChecksum.h"
+#include "cmFileTime.h"
#include "cmQtAutoGen.h"
#include <mutex>
@@ -14,13 +14,17 @@
class cmMakefile;
-/// @brief Base class for QtAutoGen gernerators
+/** \class cmQtAutoGenerator
+ * \brief Base class for QtAutoGen generators
+ */
class cmQtAutoGenerator : public cmQtAutoGen
{
public:
// -- Types
- /// @brief Thread safe logging
+ /**
+ * Thread safe logger
+ */
class Logger
{
public:
@@ -37,24 +41,24 @@ public:
bool ColorOutput() const { return this->ColorOutput_; }
void SetColorOutput(bool value);
// -- Log info
- void Info(GenT genType, std::string const& message);
+ void Info(GenT genType, std::string const& message) const;
// -- Log warning
- void Warning(GenT genType, std::string const& message);
+ void Warning(GenT genType, std::string const& message) const;
void WarningFile(GenT genType, std::string const& filename,
- std::string const& message);
+ std::string const& message) const;
// -- Log error
- void Error(GenT genType, std::string const& message);
+ void Error(GenT genType, std::string const& message) const;
void ErrorFile(GenT genType, std::string const& filename,
- std::string const& message);
+ std::string const& message) const;
void ErrorCommand(GenT genType, std::string const& message,
std::vector<std::string> const& command,
- std::string const& output);
+ std::string const& output) const;
private:
static std::string HeadLine(std::string const& title);
private:
- std::mutex Mutex_;
+ mutable std::mutex Mutex_;
unsigned int Verbosity_ = 0;
bool ColorOutput_ = false;
};
@@ -66,70 +70,8 @@ public:
static bool FileWrite(std::string const& filename,
std::string const& content,
std::string* error = nullptr);
-
- /// @brief Thread safe file system interface
- class FileSystem
- {
- public:
- FileSystem();
- ~FileSystem();
-
- // -- Paths
- /// @brief Wrapper for cmSystemTools::GetRealPath
- std::string GetRealPath(std::string const& filename);
- /// @brief Wrapper for cmSystemTools::CollapseFullPath
- std::string CollapseFullPath(std::string const& file,
- std::string const& dir);
- /// @brief Wrapper for cmSystemTools::SplitPath
- void SplitPath(const std::string& p, std::vector<std::string>& components,
- bool expand_home_dir = true);
- /// @brief Wrapper for cmSystemTools::JoinPath
- std::string JoinPath(const std::vector<std::string>& components);
- /// @brief Wrapper for cmSystemTools::JoinPath
- std::string JoinPath(std::vector<std::string>::const_iterator first,
- std::vector<std::string>::const_iterator last);
- /// @brief Wrapper for cmSystemTools::GetFilenameWithoutLastExtension
- std::string GetFilenameWithoutLastExtension(const std::string& filename);
- /// @brief Wrapper for cmQtAutoGen::SubDirPrefix
- std::string SubDirPrefix(std::string const& filename);
- /// @brief Wrapper for cmFilePathChecksum::setupParentDirs
- void setupFilePathChecksum(std::string const& currentSrcDir,
- std::string const& currentBinDir,
- std::string const& projectSrcDir,
- std::string const& projectBinDir);
- /// @brief Wrapper for cmFilePathChecksum::getPart
- std::string GetFilePathChecksum(std::string const& filename);
-
- // -- File access
- /// @brief Wrapper for cmSystemTools::FileExists
- bool FileExists(std::string const& filename);
- /// @brief Wrapper for cmSystemTools::FileExists
- bool FileExists(std::string const& filename, bool isFile);
- /// @brief Wrapper for cmSystemTools::FileLength
- unsigned long FileLength(std::string const& filename);
- bool FileIsOlderThan(std::string const& buildFile,
- std::string const& sourceFile,
- std::string* error = nullptr);
-
- bool FileRead(std::string& content, std::string const& filename,
- std::string* error = nullptr);
-
- bool FileWrite(std::string const& filename, std::string const& content,
- std::string* error = nullptr);
-
- bool FileDiffers(std::string const& filename, std::string const& content);
-
- bool FileRemove(std::string const& filename);
- bool Touch(std::string const& filename, bool create = false);
-
- // -- Directory access
- bool MakeDirectory(std::string const& dirname);
- bool MakeParentDirectory(std::string const& filename);
-
- private:
- std::mutex Mutex_;
- cmFilePathChecksum FilePathChecksum_;
- };
+ static bool FileDiffers(std::string const& filename,
+ std::string const& content);
public:
// -- Constructors
@@ -142,8 +84,9 @@ public:
// -- Run
bool Run(std::string const& infoFile, std::string const& config);
- // InfoFile
+ // -- 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_; }
@@ -158,6 +101,7 @@ protected:
private:
// -- Info settings
std::string InfoFile_;
+ cmFileTime InfoFileTime_;
std::string InfoDir_;
std::string InfoConfig_;
};