diff options
-rwxr-xr-x | configure.py | 2 | ||||
-rw-r--r-- | src/ninja.h | 20 | ||||
-rw-r--r-- | src/ninja_jumble.cc | 20 | ||||
-rw-r--r-- | src/stat_cache.cc | 38 | ||||
-rw-r--r-- | src/stat_cache.h | 36 |
5 files changed, 79 insertions, 37 deletions
diff --git a/configure.py b/configure.py index 5b66279..cf3eaf4 100755 --- a/configure.py +++ b/configure.py @@ -127,7 +127,7 @@ if platform not in ('mingw'): n.comment('Core source files all build into ninja library.') for name in ['build', 'build_log', 'clean', 'eval_env', 'graph', 'graphviz', - 'parsers', 'util', + 'parsers', 'util', 'stat_cache', 'ninja_jumble']: objs += cxx(name) if platform == 'mingw': diff --git a/src/ninja.h b/src/ninja.h index 5487cbe..8102bb7 100644 --- a/src/ninja.h +++ b/src/ninja.h @@ -15,19 +15,19 @@ #ifndef NINJA_NINJA_H_ #define NINJA_NINJA_H_ +#include <assert.h> + #include <algorithm> #include <queue> #include <set> #include <string> #include <vector> -#include <assert.h> +#include "eval_env.h" +#include "stat_cache.h" using namespace std; -#include "eval_env.h" -#include "hash_map.h" - struct Edge; struct FileStat; struct Node; @@ -68,18 +68,6 @@ struct RealDiskInterface : public DiskInterface { virtual int RemoveFile(const string& path); }; -/// Mapping of path -> FileStat. -struct StatCache { - typedef hash_map<string, FileStat*> Paths; - Paths paths_; - - FileStat* GetFile(const string& path); - - /// Dump the mapping to stdout (useful for debugging). - void Dump(); - void Reload(); -}; - /// Global state (file status, loaded rules) for a single run. struct State { State(); diff --git a/src/ninja_jumble.cc b/src/ninja_jumble.cc index b6bf097..34fcc6d 100644 --- a/src/ninja_jumble.cc +++ b/src/ninja_jumble.cc @@ -99,26 +99,6 @@ int RealDiskInterface::RemoveFile(const string& path) { } } -FileStat* StatCache::GetFile(const string& path) { - Paths::iterator i = paths_.find(path); - if (i != paths_.end()) - return i->second; - FileStat* file = new FileStat(path); - paths_[path] = file; - return file; -} - -void StatCache::Dump() { - for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) { - FileStat* file = i->second; - printf("%s %s\n", - file->path_.c_str(), - file->status_known() - ? (file->node_->dirty_ ? "dirty" : "clean") - : "unknown"); - } -} - const Rule State::kPhonyRule("phony"); State::State() : build_log_(NULL) { diff --git a/src/stat_cache.cc b/src/stat_cache.cc new file mode 100644 index 0000000..bdf20a8 --- /dev/null +++ b/src/stat_cache.cc @@ -0,0 +1,38 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "stat_cache.h" + +#include <stdio.h> + +#include "graph.h" + +FileStat* StatCache::GetFile(const std::string& path) { + Paths::iterator i = paths_.find(path); + if (i != paths_.end()) + return i->second; + FileStat* file = new FileStat(path); + paths_[path] = file; + return file; +} + +void StatCache::Dump() { + for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) { + FileStat* file = i->second; + printf("%s %s\n", + file->path_.c_str(), + file->status_known() ? (file->node_->dirty_ ? "dirty" : "clean") + : "unknown"); + } +} diff --git a/src/stat_cache.h b/src/stat_cache.h new file mode 100644 index 0000000..d71d700 --- /dev/null +++ b/src/stat_cache.h @@ -0,0 +1,36 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef NINJA_STAT_CACHE_H_ +#define NINJA_STAT_CACHE_H_ + +#include <string> + +#include "hash_map.h" + +struct FileStat; + +/// Mapping of path -> FileStat. +struct StatCache { + FileStat* GetFile(const std::string& path); + + /// Dump the mapping to stdout (useful for debugging). + void Dump(); + void Reload(); + + typedef hash_map<std::string, FileStat*> Paths; + Paths paths_; +}; + +#endif // NINJA_STAT_CACHE_H_ |