Ninja
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
BuildLog Struct Reference

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 Entriesentries () const
 
bool Load (const string &path, string *err)
 Load the on-disk log. More...
 
LogEntryLookupByOutput (const string &path)
 Lookup a previously-run command by its output path. More...
 
bool OpenForWrite (const string &path, const BuildLogUser &user, string *err)
 
bool Recompact (const string &path, const BuildLogUser &user, string *err)
 Rewrite the known log entries, throwing away old data. More...
 
bool RecordCommand (Edge *edge, int start_time, int end_time, TimeStamp mtime=0)
 
bool 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_
 

Detailed Description

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 42 of file build_log.h.

Member Typedef Documentation

◆ Entries

Definition at line 84 of file build_log.h.

Constructor & Destructor Documentation

◆ BuildLog()

BuildLog::BuildLog ( )

Definition at line 120 of file build_log.cc.

◆ ~BuildLog()

BuildLog::~BuildLog ( )

Definition at line 123 of file build_log.cc.

References Close().

Member Function Documentation

◆ Close()

void BuildLog::Close ( )

Definition at line 187 of file build_log.cc.

References log_file_.

Referenced by Recompact(), and ~BuildLog().

◆ entries()

const Entries& BuildLog::entries ( ) const
inline

Definition at line 85 of file build_log.h.

◆ Load()

bool BuildLog::Load ( const string &  path,
string *  err 
)

◆ LookupByOutput()

BuildLog::LogEntry * BuildLog::LookupByOutput ( const string &  path)

Lookup a previously-run command by its output path.

Definition at line 360 of file build_log.cc.

References entries_.

Referenced by DependencyScan::RecomputeOutputDirty().

◆ OpenForWrite()

bool BuildLog::OpenForWrite ( const string &  path,
const BuildLogUser user,
string *  err 
)

◆ Recompact()

bool BuildLog::Recompact ( const string &  path,
const BuildLogUser user,
string *  err 
)

Rewrite the known log entries, throwing away old data.

Definition at line 373 of file build_log.cc.

References Close(), entries_, BuildLogUser::IsPathDead(), kCurrentVersion, kFileSignature, METRIC_RECORD, and WriteEntry().

Referenced by OpenForWrite().

◆ RecordCommand()

bool BuildLog::RecordCommand ( Edge edge,
int  start_time,
int  end_time,
TimeStamp  mtime = 0 
)

◆ WriteEntry()

bool BuildLog::WriteEntry ( FILE *  f,
const LogEntry entry 
)

Member Data Documentation

◆ entries_

Entries BuildLog::entries_
private

Definition at line 88 of file build_log.h.

Referenced by Load(), LookupByOutput(), Recompact(), and RecordCommand().

◆ log_file_

FILE* BuildLog::log_file_
private

Definition at line 89 of file build_log.h.

Referenced by Close(), OpenForWrite(), and RecordCommand().

◆ needs_recompaction_

bool BuildLog::needs_recompaction_
private

Definition at line 90 of file build_log.h.

Referenced by Load(), and OpenForWrite().


The documentation for this struct was generated from the following files: