summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Farina <tfransosi@gmail.com>2011-05-31 16:36:23 (GMT)
committerEvan Martin <martine@danga.com>2011-05-31 16:39:45 (GMT)
commit2e173199dfb36de2843722664607160e397846dd (patch)
tree9dae69fd7207beb613aef2e40cacd592ec2b7a7e /src
parent0d4c9611aa6f8958cc2c7bf4355f46945d09c1a4 (diff)
downloadNinja-2e173199dfb36de2843722664607160e397846dd.zip
Ninja-2e173199dfb36de2843722664607160e397846dd.tar.gz
Ninja-2e173199dfb36de2843722664607160e397846dd.tar.bz2
ninja: Split StatCache struct into its own header file.
Note: This is a TODO in ninja_jumble.cc. Signed-off-by: Thiago Farina <tfarina@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/ninja.h20
-rw-r--r--src/ninja_jumble.cc20
-rw-r--r--src/stat_cache.cc38
-rw-r--r--src/stat_cache.h36
4 files changed, 78 insertions, 36 deletions
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_