diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 33 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 17 |
2 files changed, 30 insertions, 20 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 29ab7d0..dd7fbc8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2725,7 +2725,9 @@ void cmGlobalGenerator::AddToManifest(const std::string& config, // Add to the content listing for the file's directory. std::string dir = cmSystemTools::GetFilenamePath(f); std::string file = cmSystemTools::GetFilenameName(f); - this->DirectoryContentMap[dir].insert(file); + DirectoryContent& dc = this->DirectoryContentMap[dir]; + dc.Generated.insert(file); + dc.All.insert(file); } //---------------------------------------------------------------------------- @@ -2733,25 +2735,32 @@ std::set<std::string> const& cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk) { DirectoryContent& dc = this->DirectoryContentMap[dir]; - if(needDisk && !dc.LoadedFromDisk) + if(needDisk) { - // Load the directory content from disk. - cmsys::Directory d; - if(d.Load(dir)) + long mt = cmSystemTools::ModifiedTime(dir); + if (mt != dc.LastDiskTime) { - unsigned long n = d.GetNumberOfFiles(); - for(unsigned long i = 0; i < n; ++i) + // Reset to non-loaded directory content. + dc.All = dc.Generated; + + // Load the directory content from disk. + cmsys::Directory d; + if(d.Load(dir)) { - const char* f = d.GetFile(i); - if(strcmp(f, ".") != 0 && strcmp(f, "..") != 0) + unsigned long n = d.GetNumberOfFiles(); + for(unsigned long i = 0; i < n; ++i) { - dc.insert(f); + const char* f = d.GetFile(i); + if(strcmp(f, ".") != 0 && strcmp(f, "..") != 0) + { + dc.All.insert(f); + } } } + dc.LastDiskTime = mt; } - dc.LoadedFromDisk = true; } - return dc; + return dc.All; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 6b75298..08f061a 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -255,9 +255,9 @@ public: cmTargetManifest const& GetTargetManifest() const { return this->TargetManifest; } - /** Get the content of a directory. Directory listings are loaded - from disk at most once and cached. During the generation step - the content will include the target files to be built even if + /** Get the content of a directory. Directory listings are cached + and re-loaded from disk only when modified. During the generation + step the content will include the target files to be built even if they do not yet exist. */ std::set<std::string> const& GetDirectoryContent(std::string const& dir, bool needDisk = true); @@ -486,13 +486,14 @@ private: virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; } // Cache directory content and target files to be built. - struct DirectoryContent: public std::set<std::string> + struct DirectoryContent { - typedef std::set<std::string> derived; - bool LoadedFromDisk; - DirectoryContent(): LoadedFromDisk(false) {} + long LastDiskTime; + std::set<std::string> All; + std::set<std::string> Generated; + DirectoryContent(): LastDiskTime(-1) {} DirectoryContent(DirectoryContent const& dc): - derived(dc), LoadedFromDisk(dc.LoadedFromDisk) {} + LastDiskTime(dc.LastDiskTime), All(dc.All), Generated(dc.Generated) {} }; std::map<std::string, DirectoryContent> DirectoryContentMap; |