Browse Source

Autogen: Overhaul class variable names and sorting

Sebastian Holtermann 8 years ago
parent
commit
46ba6abe49
2 changed files with 83 additions and 86 deletions
  1. 45 45
      Source/cmQtAutoGenerators.cxx
  2. 38 41
      Source/cmQtAutoGenerators.h

+ 45 - 45
Source/cmQtAutoGenerators.cxx

@@ -236,12 +236,12 @@ static void UicMergeOptions(std::vector<std::string>& opts,
 cmQtAutoGenerators::cmQtAutoGenerators()
   : Verbose(cmsys::SystemTools::HasEnv("VERBOSE"))
   , ColorOutput(true)
-  , RunMocFailed(false)
-  , RunUicFailed(false)
-  , RunRccFailed(false)
-  , GenerateAllMoc(false)
-  , GenerateAllUic(false)
-  , GenerateAllRcc(false)
+  , MocSettingsChanged(false)
+  , MocRunFailed(false)
+  , UicSettingsChanged(false)
+  , UicRunFailed(false)
+  , RccSettingsChanged(false)
+  , RccRunFailed(false)
 {
 
   std::string colorEnv;
@@ -254,16 +254,16 @@ cmQtAutoGenerators::cmQtAutoGenerators()
     }
   }
 
-  this->MacroFilters[0].first = "Q_OBJECT";
-  this->MacroFilters[0].second.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
-  this->MacroFilters[1].first = "Q_GADGET";
-  this->MacroFilters[1].second.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]");
+  this->MocMacroFilters[0].first = "Q_OBJECT";
+  this->MocMacroFilters[0].second.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
+  this->MocMacroFilters[1].first = "Q_GADGET";
+  this->MocMacroFilters[1].second.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]");
 
   // Precompile regular expressions
-  this->RegExpMocInclude.compile(
+  this->MocRegExpInclude.compile(
     "[\n][ \t]*#[ \t]*include[ \t]+"
     "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
-  this->RegExpUicInclude.compile("[\n][ \t]*#[ \t]*include[ \t]+"
+  this->UicRegExpInclude.compile("[\n][ \t]*#[ \t]*include[ \t]+"
                                  "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
 }
 
@@ -521,25 +521,25 @@ void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile,
   const std::string filename = SettingsFile(targetDirectory);
   if (makefile->ReadListFile(filename.c_str())) {
     if (!SettingsMatch(makefile, SettingsKeyMoc, this->SettingsStringMoc)) {
-      this->GenerateAllMoc = true;
+      this->MocSettingsChanged = true;
     }
     if (!SettingsMatch(makefile, SettingsKeyUic, this->SettingsStringUic)) {
-      this->GenerateAllUic = true;
+      this->UicSettingsChanged = true;
     }
     if (!SettingsMatch(makefile, SettingsKeyRcc, this->SettingsStringRcc)) {
-      this->GenerateAllRcc = true;
+      this->RccSettingsChanged = true;
     }
     // In case any setting changed remove the old settings file.
     // This triggers a full rebuild on the next run if the current
     // build is aborted before writing the current settings in the end.
-    if (this->GenerateAllAny()) {
+    if (this->AnySettingsChanged()) {
       cmSystemTools::RemoveFile(filename);
     }
   } else {
     // If the file could not be read re-generate everythiung.
-    this->GenerateAllMoc = true;
-    this->GenerateAllUic = true;
-    this->GenerateAllRcc = true;
+    this->MocSettingsChanged = true;
+    this->UicSettingsChanged = true;
+    this->RccSettingsChanged = true;
   }
 }
 
@@ -547,7 +547,7 @@ bool cmQtAutoGenerators::SettingsFileWrite(const std::string& targetDirectory)
 {
   bool success = true;
   // Only write if any setting changed
-  if (this->GenerateAllAny()) {
+  if (this->AnySettingsChanged()) {
     const std::string filename = SettingsFile(targetDirectory);
     if (this->Verbose) {
       this->LogInfo("AutoGen: Writing settings file " + filename);
@@ -588,7 +588,7 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
   }
 
   // Init file path checksum generator
-  fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir,
+  FPathChecksum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir,
                                 this->ProjectSourceDir,
                                 this->ProjectBinaryDir);
 
@@ -722,8 +722,8 @@ bool cmQtAutoGenerators::RunAutogen()
 bool cmQtAutoGenerators::MocRequired(const std::string& contentText,
                                      std::string* macroName)
 {
-  for (unsigned int ii = 0; ii != cmArraySize(this->MacroFilters); ++ii) {
-    MacroFilter& filter = this->MacroFilters[ii];
+  for (unsigned int ii = 0; ii != cmArraySize(this->MocMacroFilters); ++ii) {
+    MocMacroFilter& filter = this->MocMacroFilters[ii];
     // Run a simple find string operation before the expensive
     // regular expression check
     if (contentText.find(filter.first) != std::string::npos) {
@@ -852,9 +852,9 @@ void cmQtAutoGenerators::UicParseContent(
 
   const char* contentChars = contentText.c_str();
   if (strstr(contentChars, "ui_") != CM_NULLPTR) {
-    while (this->RegExpUicInclude.find(contentChars)) {
-      uisIncluded[absFilename].push_back(this->RegExpUicInclude.match(1));
-      contentChars += this->RegExpUicInclude.end();
+    while (this->UicRegExpInclude.find(contentChars)) {
+      uisIncluded[absFilename].push_back(this->UicRegExpInclude.match(1));
+      contentChars += this->UicRegExpInclude.end();
     }
   }
 }
@@ -887,8 +887,8 @@ bool cmQtAutoGenerators::MocParseSourceContent(
   const char* contentChars = contentText.c_str();
   if (strstr(contentChars, "moc") != CM_NULLPTR) {
     // Iterate over all included moc files
-    while (this->RegExpMocInclude.find(contentChars)) {
-      const std::string incString = this->RegExpMocInclude.match(1);
+    while (this->MocRegExpInclude.find(contentChars)) {
+      const std::string incString = this->MocRegExpInclude.match(1);
       // Basename of the moc include
       const std::string incSubDir(subDirPrefix(incString));
       const std::string incBasename =
@@ -1008,7 +1008,7 @@ bool cmQtAutoGenerators::MocParseSourceContent(
         }
       }
       // Forward content pointer
-      contentChars += this->RegExpMocInclude.end();
+      contentChars += this->MocRegExpInclude.end();
     }
   }
 
@@ -1222,7 +1222,7 @@ bool cmQtAutoGenerators::MocGenerateAll(
            mocsIncluded.begin();
          it != mocsIncluded.end(); ++it) {
       if (!this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) {
-        if (this->RunMocFailed) {
+        if (this->MocRunFailed) {
           return false;
         }
       }
@@ -1237,7 +1237,7 @@ bool cmQtAutoGenerators::MocGenerateAll(
       if (this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) {
         mocCompFileGenerated = true;
       } else {
-        if (this->RunMocFailed) {
+        if (this->MocRunFailed) {
           return false;
         }
       }
@@ -1315,7 +1315,7 @@ bool cmQtAutoGenerators::MocGenerateFile(
   const std::map<std::string, std::set<std::string> >& mocDepends)
 {
   bool mocGenerated = false;
-  bool generateMoc = this->GenerateAllMoc;
+  bool generateMoc = this->MocSettingsChanged;
 
   const std::string mocFileRel =
     this->AutogenBuildSubDir + subDir + mocFileName;
@@ -1384,11 +1384,11 @@ bool cmQtAutoGenerators::MocGenerateFile(
           this->LogError(ost.str());
         }
         cmSystemTools::RemoveFile(mocFileAbs);
-        this->RunMocFailed = true;
+        this->MocRunFailed = true;
       }
     } else {
       // Parent directory creation failed
-      this->RunMocFailed = true;
+      this->MocRunFailed = true;
     }
   }
   return mocGenerated;
@@ -1487,7 +1487,7 @@ bool cmQtAutoGenerators::UicGenerateAll(
            it->second.begin();
          sit != it->second.end(); ++sit) {
       if (!this->UicGenerateFile(it->first, sit->first, sit->second)) {
-        if (this->RunUicFailed) {
+        if (this->UicRunFailed) {
           return false;
         }
       }
@@ -1505,7 +1505,7 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
                                          const std::string& uiOutputFile)
 {
   bool uicGenerated = false;
-  bool generateUic = this->GenerateAllUic;
+  bool generateUic = this->UicSettingsChanged;
 
   const std::string uicFileRel =
     this->AutogenBuildSubDir + "include/" + uiOutputFile;
@@ -1555,11 +1555,11 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
           this->LogError(ost.str());
         }
         cmSystemTools::RemoveFile(uicFileAbs);
-        this->RunUicFailed = true;
+        this->UicRunFailed = true;
       }
     } else {
       // Parent directory creation failed
-      this->RunUicFailed = true;
+      this->UicRunFailed = true;
     }
   }
   return uicGenerated;
@@ -1601,7 +1601,7 @@ bool cmQtAutoGenerators::RccGenerateAll()
        si != qrcGenMap.end(); ++si) {
     bool unique = FileNameIsUnique(si->first, qrcGenMap);
     if (!this->RccGenerateFile(si->first, si->second, unique)) {
-      if (this->RunRccFailed) {
+      if (this->RccRunFailed) {
         return false;
       }
     }
@@ -1617,7 +1617,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
                                          bool unique_n)
 {
   bool rccGenerated = false;
-  bool generateRcc = this->GenerateAllRcc;
+  bool generateRcc = this->RccSettingsChanged;
 
   const std::string rccBuildFile = this->CurrentBinaryDir + rccOutputFile;
 
@@ -1638,7 +1638,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
         } else {
           files = CM_NULLPTR;
           this->LogError(error);
-          this->RunRccFailed = true;
+          this->RccRunFailed = true;
         }
       }
       // Test if any input file is newer than the build file
@@ -1664,7 +1664,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
         cmsys::SystemTools::GetFilenameWithoutLastExtension(rccInputFile);
       if (!unique_n) {
         symbolName += "_";
-        symbolName += fpathCheckSum.getPart(rccInputFile);
+        symbolName += FPathChecksum.getPart(rccInputFile);
       }
       // Replace '-' with '_'. The former is valid for
       // file names but not for symbol names.
@@ -1701,11 +1701,11 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
           this->LogError(ost.str());
         }
         cmSystemTools::RemoveFile(rccBuildFile);
-        this->RunRccFailed = true;
+        this->RccRunFailed = true;
       }
     } else {
       // Parent directory creation failed
-      this->RunRccFailed = true;
+      this->RccRunFailed = true;
     }
   }
   return rccGenerated;
@@ -1831,7 +1831,7 @@ std::string cmQtAutoGenerators::ChecksumedPath(const std::string& sourceFile,
                                                const char* basePrefix,
                                                const char* baseSuffix) const
 {
-  std::string res = fpathCheckSum.getPart(sourceFile);
+  std::string res = FPathChecksum.getPart(sourceFile);
   res += "/";
   res += basePrefix;
   res += cmsys::SystemTools::GetFilenameWithoutLastExtension(sourceFile);

+ 38 - 41
Source/cmQtAutoGenerators.h

@@ -23,7 +23,7 @@ public:
   bool Run(const std::string& targetDirectory, const std::string& config);
 
 private:
-  // - Types
+  // -- Types
 
   /// @brief Used to extract additional dependencies from content text
   struct MocDependFilter
@@ -31,9 +31,9 @@ private:
     std::string key;
     cmsys::RegularExpression regExp;
   };
-  typedef std::pair<std::string, cmsys::RegularExpression> MacroFilter;
+  typedef std::pair<std::string, cmsys::RegularExpression> MocMacroFilter;
 
-  // - Configuration
+  // -- Configuration
   bool MocDependFilterPush(const std::string& key, const std::string& regExp);
   bool ReadAutogenInfoFile(cmMakefile* makefile,
                            const std::string& targetDirectory,
@@ -43,22 +43,22 @@ private:
   bool UicEnabled() const { return !this->UicExecutable.empty(); }
   bool RccEnabled() const { return !this->RccExecutable.empty(); }
 
-  // - Settings file
+  // -- Settings file
   void SettingsFileRead(cmMakefile* makefile,
                         const std::string& targetDirectory);
   bool SettingsFileWrite(const std::string& targetDirectory);
 
-  bool GenerateAllAny() const
+  bool AnySettingsChanged() const
   {
-    return (this->GenerateAllMoc || this->GenerateAllRcc ||
-            this->GenerateAllUic);
+    return (this->MocSettingsChanged || this->RccSettingsChanged ||
+            this->UicSettingsChanged);
   }
 
-  // - Init and run
+  // -- Init and run
   void Init(cmMakefile* makefile);
   bool RunAutogen();
 
-  // - Content analysis
+  // -- Content analysis
   bool MocRequired(const std::string& contentText,
                    std::string* macroName = CM_NULLPTR);
   void MocFindDepends(
@@ -101,7 +101,7 @@ private:
     std::map<std::string, std::string>& mocsNotIncluded,
     std::map<std::string, std::set<std::string> >& mocDepends);
 
-  // - Moc file generation
+  // -- Moc file generation
   bool MocGenerateAll(
     const std::map<std::string, std::string>& mocsIncluded,
     const std::map<std::string, std::string>& mocsNotIncluded,
@@ -111,7 +111,7 @@ private:
     const std::string& subDir,
     const std::map<std::string, std::set<std::string> >& mocDepends);
 
-  // - Uic file generation
+  // -- Uic file generation
   bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile,
                            const std::string& includeString);
   bool UicGenerateAll(
@@ -120,12 +120,12 @@ private:
                        const std::string& uiInputFile,
                        const std::string& uiOutputFile);
 
-  // - Rcc file generation
+  // -- Rcc file generation
   bool RccGenerateAll();
   bool RccGenerateFile(const std::string& qrcInputFile,
                        const std::string& qrcOutputFile, bool unique_n);
 
-  // - Logging
+  // -- Logging
   void LogErrorNameCollision(
     const std::string& message,
     const std::multimap<std::string, std::string>& collisions) const;
@@ -135,7 +135,7 @@ private:
   void LogError(const std::string& message) const;
   void LogCommand(const std::vector<std::string>& command) const;
 
-  // - Utility
+  // -- Utility
   bool NameCollisionTest(
     const std::map<std::string, std::string>& genFiles,
     std::multimap<std::string, std::string>& collisions) const;
@@ -153,28 +153,36 @@ private:
   bool MocFindIncludedFile(std::string& absFile, const std::string& sourceFile,
                            const std::string& includeString) const;
 
-  // - Target names
+  // -- Target names
   std::string OriginTargetName;
   std::string AutogenTargetName;
-  // - Directories
+  // -- Directories
   std::string ProjectSourceDir;
   std::string ProjectBinaryDir;
   std::string CurrentSourceDir;
   std::string CurrentBinaryDir;
   std::string AutogenBuildSubDir;
-  // - Qt environment
+  // -- Qt environment
   std::string QtMajorVersion;
   std::string MocExecutable;
   std::string UicExecutable;
   std::string RccExecutable;
-  // - File lists
+  // -- File lists
   std::vector<std::string> Sources;
   std::vector<std::string> Headers;
-  // - Settings
+  std::vector<std::string> HeaderExtensions;
+  cmFilePathChecksum FPathChecksum;
+  // -- Settings
+  bool IncludeProjectDirsBefore;
+  bool Verbose;
+  bool ColorOutput;
   std::string SettingsStringMoc;
   std::string SettingsStringUic;
   std::string SettingsStringRcc;
-  // - Moc
+  // -- Moc
+  bool MocSettingsChanged;
+  bool MocRelaxedMode;
+  bool MocRunFailed;
   std::string MocCppFilenameRel;
   std::string MocCppFilenameAbs;
   std::string MocPredefsFileRel;
@@ -184,35 +192,24 @@ private:
   std::vector<std::string> MocIncludes;
   std::vector<std::string> MocDefinitions;
   std::vector<std::string> MocOptions;
+  std::vector<std::string> MocPredefsCmd;
   std::vector<MocDependFilter> MocDependFilters;
-  // - Uic
+  MocMacroFilter MocMacroFilters[2];
+  cmsys::RegularExpression MocRegExpInclude;
+  // -- Uic
+  bool UicSettingsChanged;
+  bool UicRunFailed;
   std::vector<std::string> UicSkipList;
   std::vector<std::string> UicTargetOptions;
   std::map<std::string, std::string> UicOptions;
   std::vector<std::string> UicSearchPaths;
-  // - Rcc
+  cmsys::RegularExpression UicRegExpInclude;
+  // -- Rcc
+  bool RccSettingsChanged;
+  bool RccRunFailed;
   std::vector<std::string> RccSources;
   std::map<std::string, std::string> RccOptions;
   std::map<std::string, std::vector<std::string> > RccInputs;
-  // - Utility
-  cmFilePathChecksum fpathCheckSum;
-  std::vector<std::string> HeaderExtensions;
-  MacroFilter MacroFilters[2];
-  cmsys::RegularExpression RegExpMocInclude;
-  cmsys::RegularExpression RegExpUicInclude;
-  // - moc_predefs
-  std::vector<std::string> MocPredefsCmd;
-  // - Flags
-  bool IncludeProjectDirsBefore;
-  bool Verbose;
-  bool ColorOutput;
-  bool RunMocFailed;
-  bool RunUicFailed;
-  bool RunRccFailed;
-  bool GenerateAllMoc;
-  bool GenerateAllUic;
-  bool GenerateAllRcc;
-  bool MocRelaxedMode;
 };
 
 #endif