Ninja
|
Store a log of every command ran for every build. More...
#include <build_log.h>
Classes | |
struct | LogEntry |
Public Types | |
typedef ExternalStringHashMap < LogEntry * >::Type | Entries |
Public Member Functions | |
BuildLog () | |
void | Close () |
const Entries & | entries () const |
bool | Load (const string &path, string *err) |
Load the on-disk log. More... | |
LogEntry * | LookupByOutput (const string &path) |
Lookup a previously-run command by its output path. More... | |
bool | OpenForWrite (const string &path, string *err) |
bool | Recompact (const string &path, string *err) |
Rewrite the known log entries, throwing away old data. More... | |
void | RecordCommand (Edge *edge, int start_time, int end_time, TimeStamp restat_mtime=0) |
void | WriteEntry (FILE *f, const LogEntry &entry) |
Serialize an entry into a log file. More... | |
~BuildLog () | |
Private Attributes | |
Entries | entries_ |
FILE * | log_file_ |
bool | needs_recompaction_ |
Store a log of every command ran for every build.
It has a few uses:
1) (hashes of) command lines for existing output files, so we know when we need to rebuild due to the command changing 2) timing information, perhaps for generating reports 3) restat information
Definition at line 35 of file build_log.h.
typedef ExternalStringHashMap<LogEntry*>::Type BuildLog::Entries |
Definition at line 77 of file build_log.h.
BuildLog::BuildLog | ( | ) |
Definition at line 103 of file build_log.cc.
BuildLog::~BuildLog | ( | ) |
Definition at line 106 of file build_log.cc.
References Close().
void BuildLog::Close | ( | ) |
Definition at line 164 of file build_log.cc.
References log_file_.
Referenced by OpenForWrite(), and ~BuildLog().
|
inline |
Definition at line 78 of file build_log.h.
bool BuildLog::Load | ( | const string & | path, |
string * | err | ||
) |
Load the on-disk log.
Definition at line 221 of file build_log.cc.
References BuildLog::LogEntry::command_hash, BuildLog::LogEntry::end_time, entries_, BuildLog::LogEntry::HashCommand(), kCurrentVersion, kFileSignature, METRIC_RECORD, needs_recompaction_, BuildLog::LogEntry::output, LineReader::ReadLine(), BuildLog::LogEntry::restat_mtime, and BuildLog::LogEntry::start_time.
Referenced by main().
BuildLog::LogEntry * BuildLog::LookupByOutput | ( | const string & | path | ) |
Lookup a previously-run command by its output path.
Definition at line 337 of file build_log.cc.
References entries_.
Referenced by DependencyScan::RecomputeOutputDirty().
bool BuildLog::OpenForWrite | ( | const string & | path, |
string * | err | ||
) |
Definition at line 110 of file build_log.cc.
References Close(), kCurrentVersion, kFileSignature, log_file_, needs_recompaction_, Recompact(), and SetCloseOnExec().
Referenced by WriteTestData().
bool BuildLog::Recompact | ( | const string & | path, |
string * | err | ||
) |
Rewrite the known log entries, throwing away old data.
Definition at line 350 of file build_log.cc.
References entries_, kCurrentVersion, kFileSignature, METRIC_RECORD, and WriteEntry().
Referenced by OpenForWrite().
void BuildLog::RecordCommand | ( | Edge * | edge, |
int | start_time, | ||
int | end_time, | ||
TimeStamp | restat_mtime = 0 |
||
) |
Definition at line 139 of file build_log.cc.
References BuildLog::LogEntry::command_hash, BuildLog::LogEntry::end_time, entries_, Edge::EvaluateCommand(), BuildLog::LogEntry::HashCommand(), log_file_, BuildLog::LogEntry::output, Edge::outputs_, BuildLog::LogEntry::restat_mtime, BuildLog::LogEntry::start_time, and WriteEntry().
Referenced by Builder::FinishCommand(), and WriteTestData().
void BuildLog::WriteEntry | ( | FILE * | f, |
const LogEntry & | entry | ||
) |
Serialize an entry into a log file.
Definition at line 344 of file build_log.cc.
References BuildLog::LogEntry::command_hash, BuildLog::LogEntry::end_time, BuildLog::LogEntry::output, PRIx64, BuildLog::LogEntry::restat_mtime, and BuildLog::LogEntry::start_time.
Referenced by Recompact(), and RecordCommand().
|
private |
Definition at line 81 of file build_log.h.
Referenced by Load(), LookupByOutput(), Recompact(), and RecordCommand().
|
private |
Definition at line 82 of file build_log.h.
Referenced by Close(), OpenForWrite(), and RecordCommand().
|
private |
Definition at line 83 of file build_log.h.
Referenced by Load(), and OpenForWrite().