2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2013-09-24 18:07:45 +00:00
|
|
|
#ifndef cmQtAutoGenerators_h
|
|
|
|
#define cmQtAutoGenerators_h
|
2011-08-07 10:02:46 +00:00
|
|
|
|
2016-09-01 18:59:28 +00:00
|
|
|
#include <cmConfigure.h> // IWYU pragma: keep
|
2016-12-01 08:24:48 +00:00
|
|
|
#include <cmFilePathChecksum.h>
|
2016-12-27 13:52:49 +00:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2015-09-26 10:51:46 +00:00
|
|
|
#include <map>
|
2016-09-01 18:59:28 +00:00
|
|
|
#include <set>
|
2016-04-29 14:53:13 +00:00
|
|
|
#include <string>
|
2017-02-16 09:31:03 +00:00
|
|
|
#include <utility>
|
2016-04-29 14:53:13 +00:00
|
|
|
#include <vector>
|
2015-01-12 20:17:55 +00:00
|
|
|
|
2011-08-07 15:16:00 +00:00
|
|
|
class cmMakefile;
|
2015-09-26 16:54:56 +00:00
|
|
|
|
|
|
|
class cmQtAutoGenerators
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmQtAutoGenerators();
|
|
|
|
bool Run(const std::string& targetDirectory, const std::string& config);
|
|
|
|
|
|
|
|
private:
|
2017-02-17 10:56:02 +00:00
|
|
|
// - Types
|
|
|
|
|
|
|
|
/// @brief Used to extract additional dependencies from content text
|
|
|
|
struct MocDependFilter
|
|
|
|
{
|
|
|
|
std::string key;
|
|
|
|
cmsys::RegularExpression regExp;
|
|
|
|
};
|
|
|
|
typedef std::pair<std::string, cmsys::RegularExpression> MacroFilter;
|
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Configuration
|
2017-02-22 16:40:36 +00:00
|
|
|
bool MocDependFilterPush(const std::string& key, const std::string& regExp);
|
2013-10-02 11:50:31 +00:00
|
|
|
bool ReadAutogenInfoFile(cmMakefile* makefile,
|
2014-02-24 22:38:30 +00:00
|
|
|
const std::string& targetDirectory,
|
2014-02-10 03:48:34 +00:00
|
|
|
const std::string& config);
|
2011-08-07 15:16:00 +00:00
|
|
|
|
2017-02-15 10:01:31 +00:00
|
|
|
bool MocEnabled() const { return !this->MocExecutable.empty(); }
|
|
|
|
bool UicEnabled() const { return !this->UicExecutable.empty(); }
|
|
|
|
bool RccEnabled() const { return !this->RccExecutable.empty(); }
|
|
|
|
|
2017-02-14 16:52:13 +00:00
|
|
|
// - Settings file
|
2017-02-14 16:48:39 +00:00
|
|
|
void SettingsFileRead(cmMakefile* makefile,
|
|
|
|
const std::string& targetDirectory);
|
|
|
|
bool SettingsFileWrite(const std::string& targetDirectory);
|
2012-08-27 19:39:50 +00:00
|
|
|
|
2017-02-15 10:01:31 +00:00
|
|
|
bool GenerateAllAny() const
|
|
|
|
{
|
|
|
|
return (this->GenerateAllMoc || this->GenerateAllRcc ||
|
|
|
|
this->GenerateAllUic);
|
|
|
|
}
|
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Init and run
|
2017-02-15 18:30:08 +00:00
|
|
|
void Init(cmMakefile* makefile);
|
|
|
|
bool RunAutogen();
|
2016-12-02 10:21:52 +00:00
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Content analysis
|
2017-02-17 10:56:02 +00:00
|
|
|
bool MocRequired(const std::string& contentText,
|
2017-02-16 09:31:03 +00:00
|
|
|
std::string* macroName = CM_NULLPTR);
|
2017-02-17 10:56:02 +00:00
|
|
|
void MocFindDepends(
|
|
|
|
const std::string& absFilename, const std::string& contentText,
|
|
|
|
std::map<std::string, std::set<std::string> >& mocDepends);
|
|
|
|
|
2017-02-15 18:30:08 +00:00
|
|
|
bool MocSkip(const std::string& absFilename) const;
|
|
|
|
bool UicSkip(const std::string& absFilename) const;
|
2016-08-06 12:57:52 +00:00
|
|
|
|
2016-12-27 13:16:10 +00:00
|
|
|
bool ParseSourceFile(
|
|
|
|
const std::string& absFilename,
|
2017-02-16 16:53:19 +00:00
|
|
|
std::map<std::string, std::string>& mocsIncluded,
|
2017-02-17 10:56:02 +00:00
|
|
|
std::map<std::string, std::set<std::string> >& mocDepends,
|
2016-12-27 13:16:10 +00:00
|
|
|
std::map<std::string, std::vector<std::string> >& includedUis,
|
|
|
|
bool relaxed);
|
2017-01-11 12:41:14 +00:00
|
|
|
|
2017-02-15 18:30:08 +00:00
|
|
|
void SearchHeadersForSourceFile(const std::string& absFilename,
|
2017-02-16 16:53:19 +00:00
|
|
|
std::set<std::string>& mocHeaderFiles,
|
|
|
|
std::set<std::string>& uicHeaderFiles) const;
|
2016-05-16 14:34:04 +00:00
|
|
|
|
2017-03-02 18:39:50 +00:00
|
|
|
bool ParseHeaders(
|
2017-02-16 16:53:19 +00:00
|
|
|
const std::set<std::string>& mocHeaderFiles,
|
|
|
|
const std::set<std::string>& uicHeaderFiles,
|
|
|
|
const std::map<std::string, std::string>& mocsIncluded,
|
|
|
|
std::map<std::string, std::string>& mocsNotIncluded,
|
2017-02-17 10:56:02 +00:00
|
|
|
std::map<std::string, std::set<std::string> >& mocDepends,
|
2016-05-16 14:34:04 +00:00
|
|
|
std::map<std::string, std::vector<std::string> >& includedUis);
|
|
|
|
|
2017-02-17 10:56:02 +00:00
|
|
|
void UicParseContent(
|
|
|
|
const std::string& fileName, const std::string& contentText,
|
2016-05-16 14:34:04 +00:00
|
|
|
std::map<std::string, std::vector<std::string> >& includedUis);
|
|
|
|
|
2017-02-17 10:56:02 +00:00
|
|
|
bool MocParseSourceContent(
|
|
|
|
const std::string& absFilename, const std::string& contentText,
|
|
|
|
std::map<std::string, std::string>& mocsIncluded,
|
|
|
|
std::map<std::string, std::set<std::string> >& mocDepends, bool relaxed);
|
|
|
|
|
|
|
|
void MocParseHeaderContent(
|
|
|
|
const std::string& absFilename, const std::string& contentText,
|
|
|
|
std::map<std::string, std::string>& mocsNotIncluded,
|
|
|
|
std::map<std::string, std::set<std::string> >& mocDepends);
|
2016-12-28 09:25:16 +00:00
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Moc file generation
|
2017-01-11 14:08:24 +00:00
|
|
|
bool MocGenerateAll(
|
2017-02-16 16:53:19 +00:00
|
|
|
const std::map<std::string, std::string>& mocsIncluded,
|
2017-02-17 10:56:02 +00:00
|
|
|
const std::map<std::string, std::string>& mocsNotIncluded,
|
|
|
|
const std::map<std::string, std::set<std::string> >& mocDepends);
|
|
|
|
bool MocGenerateFile(
|
|
|
|
const std::string& sourceFile, const std::string& mocFileName,
|
2017-02-24 10:41:50 +00:00
|
|
|
const std::string& subDir,
|
2017-02-17 10:56:02 +00:00
|
|
|
const std::map<std::string, std::set<std::string> >& mocDepends);
|
2011-08-08 13:20:13 +00:00
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Uic file generation
|
2017-02-23 18:35:48 +00:00
|
|
|
bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile,
|
|
|
|
const std::string& includeString);
|
2017-01-11 14:08:24 +00:00
|
|
|
bool UicGenerateAll(
|
2017-01-11 12:41:14 +00:00
|
|
|
const std::map<std::string, std::vector<std::string> >& includedUis);
|
2017-01-11 14:08:24 +00:00
|
|
|
bool UicGenerateFile(const std::string& realName,
|
|
|
|
const std::string& uiInputFile,
|
|
|
|
const std::string& uiOutputFile);
|
2017-01-01 14:58:34 +00:00
|
|
|
|
2017-02-14 20:59:36 +00:00
|
|
|
// - Rcc file generation
|
|
|
|
bool RccGenerateAll();
|
|
|
|
bool RccGenerateFile(const std::string& qrcInputFile,
|
2017-01-11 14:08:24 +00:00
|
|
|
const std::string& qrcOutputFile, bool unique_n);
|
2016-11-30 20:08:54 +00:00
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Logging
|
2016-11-30 20:08:54 +00:00
|
|
|
void LogErrorNameCollision(
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& message,
|
2017-02-17 17:44:10 +00:00
|
|
|
const std::multimap<std::string, std::string>& collisions) const;
|
2017-02-17 10:56:02 +00:00
|
|
|
void LogBold(const std::string& message) const;
|
|
|
|
void LogInfo(const std::string& message) const;
|
|
|
|
void LogWarning(const std::string& message) const;
|
|
|
|
void LogError(const std::string& message) const;
|
|
|
|
void LogCommand(const std::vector<std::string>& command) const;
|
2016-11-30 20:08:54 +00:00
|
|
|
|
2017-01-11 12:41:14 +00:00
|
|
|
// - Utility
|
2017-02-14 23:04:49 +00:00
|
|
|
bool NameCollisionTest(
|
|
|
|
const std::map<std::string, std::string>& genFiles,
|
|
|
|
std::multimap<std::string, std::string>& collisions) const;
|
2017-02-14 22:59:07 +00:00
|
|
|
std::string ChecksumedPath(const std::string& sourceFile,
|
2017-02-14 23:04:49 +00:00
|
|
|
const char* basePrefix,
|
|
|
|
const char* baseSuffix) const;
|
2017-02-17 17:44:10 +00:00
|
|
|
bool MakeParentDirectory(const std::string& filename) const;
|
2017-03-06 18:57:49 +00:00
|
|
|
bool RunCommand(const std::vector<std::string>& command,
|
|
|
|
std::string& output) const;
|
2014-09-17 00:42:30 +00:00
|
|
|
|
2017-02-15 18:30:08 +00:00
|
|
|
bool FindHeader(std::string& header, const std::string& testBasePath) const;
|
2017-02-24 11:11:55 +00:00
|
|
|
|
|
|
|
std::string MocFindHeader(const std::string& sourcePath,
|
|
|
|
const std::string& includeBase) const;
|
|
|
|
bool MocFindIncludedFile(std::string& absFile, const std::string& sourceFile,
|
|
|
|
const std::string& includeString) const;
|
2017-02-15 18:19:37 +00:00
|
|
|
|
2016-12-04 10:38:31 +00:00
|
|
|
// - Target names
|
|
|
|
std::string OriginTargetName;
|
|
|
|
std::string AutogenTargetName;
|
|
|
|
// - Directories
|
|
|
|
std::string ProjectSourceDir;
|
|
|
|
std::string ProjectBinaryDir;
|
|
|
|
std::string CurrentSourceDir;
|
|
|
|
std::string CurrentBinaryDir;
|
|
|
|
std::string AutogenBuildSubDir;
|
|
|
|
// - Qt environment
|
2011-08-07 15:16:00 +00:00
|
|
|
std::string QtMajorVersion;
|
2011-08-08 13:20:13 +00:00
|
|
|
std::string MocExecutable;
|
2013-07-25 07:24:53 +00:00
|
|
|
std::string UicExecutable;
|
2013-09-15 12:41:07 +00:00
|
|
|
std::string RccExecutable;
|
2016-12-04 10:38:31 +00:00
|
|
|
// - File lists
|
2016-12-27 18:03:14 +00:00
|
|
|
std::vector<std::string> Sources;
|
|
|
|
std::vector<std::string> Headers;
|
2017-02-15 09:15:05 +00:00
|
|
|
// - Settings
|
|
|
|
std::string SettingsStringMoc;
|
|
|
|
std::string SettingsStringUic;
|
|
|
|
std::string SettingsStringRcc;
|
2016-12-04 10:38:31 +00:00
|
|
|
// - Moc
|
2017-02-15 12:23:27 +00:00
|
|
|
std::string MocCppFilenameRel;
|
|
|
|
std::string MocCppFilenameAbs;
|
|
|
|
std::vector<std::string> MocSkipList;
|
2017-02-16 10:10:46 +00:00
|
|
|
std::vector<std::string> MocIncludePaths;
|
2017-02-15 11:53:39 +00:00
|
|
|
std::vector<std::string> MocIncludes;
|
2017-02-15 09:36:51 +00:00
|
|
|
std::vector<std::string> MocDefinitions;
|
2011-11-01 13:33:11 +00:00
|
|
|
std::vector<std::string> MocOptions;
|
2017-02-17 10:56:02 +00:00
|
|
|
std::vector<MocDependFilter> MocDependFilters;
|
2016-12-04 10:38:31 +00:00
|
|
|
// - Uic
|
2017-02-15 09:56:44 +00:00
|
|
|
std::vector<std::string> UicSkipList;
|
2013-07-25 07:24:53 +00:00
|
|
|
std::vector<std::string> UicTargetOptions;
|
|
|
|
std::map<std::string, std::string> UicOptions;
|
2017-02-23 18:35:48 +00:00
|
|
|
std::vector<std::string> UicSearchPaths;
|
2016-12-04 10:38:31 +00:00
|
|
|
// - Rcc
|
|
|
|
std::vector<std::string> RccSources;
|
2013-09-15 12:41:07 +00:00
|
|
|
std::map<std::string, std::string> RccOptions;
|
2014-09-17 00:42:30 +00:00
|
|
|
std::map<std::string, std::vector<std::string> > RccInputs;
|
2016-12-04 10:38:31 +00:00
|
|
|
// - Utility
|
2016-12-01 08:24:48 +00:00
|
|
|
cmFilePathChecksum fpathCheckSum;
|
2017-02-15 18:30:08 +00:00
|
|
|
std::vector<std::string> HeaderExtensions;
|
2017-02-16 09:31:03 +00:00
|
|
|
MacroFilter MacroFilters[2];
|
2016-12-27 13:52:49 +00:00
|
|
|
cmsys::RegularExpression RegExpMocInclude;
|
|
|
|
cmsys::RegularExpression RegExpUicInclude;
|
2016-12-04 10:38:31 +00:00
|
|
|
// - Flags
|
2015-06-07 08:11:42 +00:00
|
|
|
bool IncludeProjectDirsBefore;
|
2011-08-08 13:20:13 +00:00
|
|
|
bool Verbose;
|
2011-08-14 14:43:04 +00:00
|
|
|
bool ColorOutput;
|
2011-08-08 13:20:13 +00:00
|
|
|
bool RunMocFailed;
|
2013-07-25 07:24:53 +00:00
|
|
|
bool RunUicFailed;
|
2013-09-15 12:41:07 +00:00
|
|
|
bool RunRccFailed;
|
2017-02-14 16:36:59 +00:00
|
|
|
bool GenerateAllMoc;
|
|
|
|
bool GenerateAllUic;
|
|
|
|
bool GenerateAllRcc;
|
2016-11-30 12:14:23 +00:00
|
|
|
bool MocRelaxedMode;
|
2011-08-07 10:02:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|