diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-27 14:50:17 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-03-27 17:12:43 (GMT) |
commit | 87341d8328c7b3a1d50cfd534ff4cb44334a2561 (patch) | |
tree | 83479c41db2da0c4282565927d60150f5e5ac727 | |
parent | 5a15c9e7cb63fb5b884271a1184607a8fa87d442 (diff) | |
download | CMake-87341d8328c7b3a1d50cfd534ff4cb44334a2561.zip CMake-87341d8328c7b3a1d50cfd534ff4cb44334a2561.tar.gz CMake-87341d8328c7b3a1d50cfd534ff4cb44334a2561.tar.bz2 |
cmDepends: Define DependencyMap instead of DependencyVector
In `cmDepends` use
`typedef std::map<std::string, std::vector<std::string>> DependencyMap`
instead of defining a
`class DependencyVector : public std::vector<std::string>`
and using it in `std::map<std::string, DependencyVector>`.
Since `std::map<std::string, std::vector<std::string>>` is used in various
other places, we now reuse all of it's auto generated methods. This doesn't
happen when we use `DependencyVector` in a `std::map`, because it is a
different class than `std::vector<std::string>`.
-rw-r--r-- | Source/cmDepends.cxx | 10 | ||||
-rw-r--r-- | Source/cmDepends.h | 15 | ||||
-rw-r--r-- | Source/cmDependsC.cxx | 8 | ||||
-rw-r--r-- | Source/cmDependsC.h | 5 | ||||
-rw-r--r-- | Source/cmDependsJava.cxx | 3 | ||||
-rw-r--r-- | Source/cmDependsJava.h | 7 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 5 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 11 |
8 files changed, 28 insertions, 36 deletions
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 334f1e5..ed76dbf 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -61,7 +61,7 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/) bool cmDepends::Check(const std::string& makeFile, const std::string& internalFile, - std::map<std::string, DependencyVector>& validDeps) + DependencyMap& validDeps) { // Check whether dependencies must be regenerated. bool okay = true; @@ -101,9 +101,9 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/, return false; } -bool cmDepends::CheckDependencies( - std::istream& internalDepends, const std::string& internalDependsFileName, - std::map<std::string, DependencyVector>& validDeps) +bool cmDepends::CheckDependencies(std::istream& internalDepends, + const std::string& internalDependsFileName, + DependencyMap& validDeps) { // Read internal depends file time cmFileTime internalDependsTime; @@ -124,7 +124,7 @@ bool cmDepends::CheckDependencies( std::string dependee; cmFileTime dependerTime; cmFileTime dependeeTime; - DependencyVector* currentDependencies = nullptr; + std::vector<std::string>* currentDependencies = nullptr; while (std::getline(internalDepends, line)) { // Check if this an empty or a comment line diff --git a/Source/cmDepends.h b/Source/cmDepends.h index d9d5c67..b7475f0 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -24,6 +24,9 @@ class cmLocalGenerator; class cmDepends { public: + typedef std::map<std::string, std::vector<std::string>> DependencyMap; + +public: /** Instances need to know the build directory name and the relative path from the build directory to the target file. */ cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = ""); @@ -55,17 +58,13 @@ public: /** Write dependencies for the target file. */ bool Write(std::ostream& makeDepends, std::ostream& internalDepends); - class DependencyVector : public std::vector<std::string> - { - }; - /** Check dependencies for the target file. Returns true if dependencies are okay and false if they must be generated. If they must be generated Clear has already been called to wipe out the old dependencies. Dependencies which are still valid will be stored in validDeps. */ bool Check(const std::string& makeFile, const std::string& internalFile, - std::map<std::string, DependencyVector>& validDeps); + DependencyMap& validDeps); /** Clear dependencies for the target file so they will be regenerated. */ void Clear(const std::string& file); @@ -84,9 +83,9 @@ protected: // Check dependencies for the target file in the given stream. // Return false if dependencies must be regenerated and true // otherwise. - virtual bool CheckDependencies( - std::istream& internalDepends, const std::string& internalDependsFileName, - std::map<std::string, DependencyVector>& validDeps); + virtual bool CheckDependencies(std::istream& internalDepends, + const std::string& internalDependsFileName, + DependencyMap& validDeps); // Finalize the dependency information for the target. virtual bool Finalize(std::ostream& makeDepends, diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 7b78767..dc49c18 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -21,9 +21,8 @@ cmDependsC::cmDependsC() = default; -cmDependsC::cmDependsC( - cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang, - const std::map<std::string, DependencyVector>* validDeps) +cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir, + const std::string& lang, const DependencyMap* validDeps) : cmDepends(lg, targetDir) , ValidDeps(validDeps) { @@ -102,8 +101,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, this->LocalGenerator->MaybeConvertToRelativePath(binDir, obj); if (this->ValidDeps != nullptr) { - std::map<std::string, DependencyVector>::const_iterator tmpIt = - this->ValidDeps->find(obj_i); + auto const tmpIt = this->ValidDeps->find(obj_i); if (tmpIt != this->ValidDeps->end()) { dependencies.insert(tmpIt->second.begin(), tmpIt->second.end()); haveDeps = true; diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index eee5ae1..3fc839e 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -27,8 +27,7 @@ public: relative path from the build directory to the target file. */ cmDependsC(); cmDependsC(cmLocalGenerator* lg, const std::string& targetDir, - const std::string& lang, - const std::map<std::string, DependencyVector>* validDeps); + const std::string& lang, const DependencyMap* validDeps); /** Virtual destructor to cleanup subclasses properly. */ ~cmDependsC() override; @@ -81,7 +80,7 @@ public: }; protected: - const std::map<std::string, DependencyVector>* ValidDeps = nullptr; + const DependencyMap* ValidDeps = nullptr; std::set<std::string> Encountered; std::queue<UnscannedEntry> Unscanned; diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx index 2485e15..b17b2ba 100644 --- a/Source/cmDependsJava.cxx +++ b/Source/cmDependsJava.cxx @@ -24,8 +24,7 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources, bool cmDependsJava::CheckDependencies( std::istream& /*internalDepends*/, - const std::string& /*internalDependsFileName*/, - std::map<std::string, DependencyVector>& /*validDeps*/) + const std::string& /*internalDependsFileName*/, DependencyMap& /*validDeps*/) { return true; } diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index 109ef13..dd671a1 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -8,7 +8,6 @@ #include "cmDepends.h" #include <iosfwd> -#include <map> #include <set> #include <string> @@ -33,9 +32,9 @@ protected: bool WriteDependencies(const std::set<std::string>& sources, const std::string& file, std::ostream& makeDepends, std::ostream& internalDepends) override; - bool CheckDependencies( - std::istream& internalDepends, const std::string& internalDependsFileName, - std::map<std::string, DependencyVector>& validDeps) override; + bool CheckDependencies(std::istream& internalDepends, + const std::string& internalDependsFileName, + DependencyMap& validDeps) override; }; #endif diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f3d5a94..2857d39 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1312,7 +1312,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( // The build.make file may have explicit dependencies for the object // files but these will not affect the scanning process so they need // not be considered. - std::map<std::string, cmDepends::DependencyVector> validDependencies; + cmDepends::DependencyMap validDependencies; bool needRescanDependencies = false; if (!needRescanDirInfo) { cmDependsC checker; @@ -1352,8 +1352,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( bool cmLocalUnixMakefileGenerator3::ScanDependencies( std::string const& targetDir, std::string const& dependFile, - std::string const& internalDependFile, - std::map<std::string, cmDepends::DependencyVector>& validDeps) + std::string const& internalDependFile, cmDepends::DependencyMap& validDeps) { // Read the directory information file. cmMakefile* mf = this->Makefile; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index ba882da..7a0ea98 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -143,8 +143,7 @@ public: // File pairs for implicit dependency scanning. The key of the map // is the depender and the value is the explicit dependee. - struct ImplicitDependFileMap - : public std::map<std::string, cmDepends::DependencyVector> + struct ImplicitDependFileMap : public cmDepends::DependencyMap { }; struct ImplicitDependLanguageMap @@ -230,10 +229,10 @@ protected: const char* filename = nullptr); // Helper methods for dependency updates. - bool ScanDependencies( - std::string const& targetDir, std::string const& dependFile, - std::string const& internalDependFile, - std::map<std::string, cmDepends::DependencyVector>& validDeps); + bool ScanDependencies(std::string const& targetDir, + std::string const& dependFile, + std::string const& internalDependFile, + cmDepends::DependencyMap& validDeps); void CheckMultipleOutputs(bool verbose); private: |