summaryrefslogtreecommitdiffstats
path: root/src/build_log.h
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2010-12-16 19:52:24 (GMT)
committerEvan Martin <martine@danga.com>2010-12-23 19:20:33 (GMT)
commit9a6fd1a97b64ea1245a7343aee1e584c401a391b (patch)
tree73e83a65f9c157ffdce98d45969cfa7c4f18757e /src/build_log.h
parent12e36285ae52feca764e8fb2a417a87b913fe3e6 (diff)
downloadNinja-9a6fd1a97b64ea1245a7343aee1e584c401a391b.zip
Ninja-9a6fd1a97b64ea1245a7343aee1e584c401a391b.tar.gz
Ninja-9a6fd1a97b64ea1245a7343aee1e584c401a391b.tar.bz2
add a class for logging builds (commands + timing)
Diffstat (limited to 'src/build_log.h')
-rw-r--r--src/build_log.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/build_log.h b/src/build_log.h
new file mode 100644
index 0000000..1d9463c
--- /dev/null
+++ b/src/build_log.h
@@ -0,0 +1,37 @@
+#include <map>
+#include <string>
+using namespace std;
+
+struct Edge;
+
+// Store a log of every command ran for every build.
+// It has a few uses:
+// 1) historical command lines for output files, so we know
+// when we need to rebuild due to the command changing
+// 2) historical timing information
+// 3) maybe we can generate some sort of build overview output
+// from it
+struct BuildLog {
+ bool OpenForWrite(const string& path, string* err);
+ void RecordCommand(Edge* edge, int time_ms);
+ void Close();
+
+ // Load the on-disk log.
+ bool Load(const string& path, string* err);
+
+ struct LogEntry {
+ string output;
+ string command;
+ int time_ms;
+ bool operator==(const LogEntry& o) {
+ return output == o.output && command == o.command && time_ms == o.time_ms;
+ }
+ };
+
+ // Lookup a previously-run command by its output path.
+ LogEntry* LookupByOutput(const string& path);
+
+ typedef map<string, LogEntry*> Log;
+ Log log_;
+ FILE* log_file_;
+};