Ninja
Cleaner Struct Reference

#include <clean.h>

Public Member Functions

int CleanAll (bool generator=false)
 Clean all built files, except for files created by generator rules.
 
int CleanDead (const BuildLog::Entries &entries)
 Clean the files produced by previous builds that are no longer in the manifest.
 
int cleaned_files_count () const
 
 Cleaner (State *state, const BuildConfig &config, DiskInterface *disk_interface)
 Build a cleaner object with the given disk_interface.
 
int CleanRule (const char *rule)
 Clean the file produced by the given rule.
 
int CleanRule (const Rule *rule)
 Clean all the file built with the given rule rule.
 
int CleanRules (int rule_count, char *rules[])
 Clean the file produced by the given rules.
 
int CleanTarget (const char *target)
 Clean the given target target.
 
int CleanTarget (Node *target)
 Clean the given target and all the file built for it.
 
int CleanTargets (int target_count, char *targets[])
 Clean the given target targets.
 
bool IsVerbose () const
 

Private Member Functions

void DoCleanRule (const Rule *rule)
 
void DoCleanTarget (Node *target)
 Helper recursive method for CleanTarget().
 
bool FileExists (const std::string &path)
 
bool IsAlreadyRemoved (const std::string &path)
 
void LoadDyndeps ()
 Load dependencies from dyndep bindings.
 
void PrintFooter ()
 
void PrintHeader ()
 
void Remove (const std::string &path)
 Remove the given path file only if it has not been already removed.
 
void RemoveEdgeFiles (Edge *edge)
 Remove the depfile and rspfile for an Edge.
 
int RemoveFile (const std::string &path)
 Remove the file path.
 
void Report (const std::string &path)
 
void Reset ()
 

Private Attributes

std::set< Node * > cleaned_
 
int cleaned_files_count_
 
const BuildConfigconfig_
 
DiskInterfacedisk_interface_
 
DyndepLoader dyndep_loader_
 
std::set< std::string > removed_
 
Statestate_
 
int status_
 

Detailed Description

Definition at line 30 of file clean.h.

Constructor & Destructor Documentation

◆ Cleaner()

Cleaner::Cleaner ( State * state,
const BuildConfig & config,
DiskInterface * disk_interface )

Build a cleaner object with the given disk_interface.

Definition at line 27 of file clean.cc.

References cleaned_files_count_, config_, disk_interface_, dyndep_loader_, state_, and status_.

Member Function Documentation

◆ CleanAll()

int Cleaner::CleanAll ( bool generator = false)

Clean all built files, except for files created by generator rules.

Parameters
generatorIf set, also clean files created by generator rules.
Returns
non-zero if an error occurs.

Definition at line 104 of file clean.cc.

References LoadDyndeps(), PrintFooter(), PrintHeader(), Remove(), RemoveEdgeFiles(), Reset(), state_, and status_.

◆ CleanDead()

int Cleaner::CleanDead ( const BuildLog::Entries & entries)

Clean the files produced by previous builds that are no longer in the manifest.

Returns
non-zero if an error occurs.

Definition at line 127 of file clean.cc.

References Node::in_edge(), LoadDyndeps(), Node::out_edges(), PrintFooter(), PrintHeader(), Remove(), Reset(), state_, and status_.

◆ cleaned_files_count()

int Cleaner::cleaned_files_count ( ) const
inline
Returns
the number of file cleaned.

Definition at line 66 of file clean.h.

References cleaned_files_count_.

◆ CleanRule() [1/2]

int Cleaner::CleanRule ( const char * rule)

Clean the file produced by the given rule.

Returns
non-zero if an error occurs.

Definition at line 249 of file clean.cc.

References CleanRule(), Error(), Reset(), state_, and status_.

◆ CleanRule() [2/2]

int Cleaner::CleanRule ( const Rule * rule)

Clean all the file built with the given rule rule.

Returns
non-zero if an error occurs.

Definition at line 238 of file clean.cc.

References DoCleanRule(), LoadDyndeps(), PrintFooter(), PrintHeader(), Reset(), and status_.

Referenced by CleanRule().

◆ CleanRules()

int Cleaner::CleanRules ( int rule_count,
char * rules[] )

Clean the file produced by the given rules.

Returns
non-zero if an error occurs.

Definition at line 263 of file clean.cc.

References DoCleanRule(), Error(), IsVerbose(), LoadDyndeps(), PrintFooter(), PrintHeader(), Reset(), state_, and status_.

◆ CleanTarget() [1/2]

int Cleaner::CleanTarget ( const char * target)

Clean the given target target.

Returns
non-zero if an error occurs.

Definition at line 182 of file clean.cc.

References CleanTarget(), Error(), Reset(), state_, and status_.

◆ CleanTarget() [2/2]

int Cleaner::CleanTarget ( Node * target)

Clean the given target and all the file built for it.

Returns
non-zero if an error occurs.

Definition at line 171 of file clean.cc.

References DoCleanTarget(), LoadDyndeps(), PrintFooter(), PrintHeader(), Reset(), and status_.

Referenced by CleanTarget().

◆ CleanTargets()

int Cleaner::CleanTargets ( int target_count,
char * targets[] )

Clean the given target targets.

Returns
non-zero if an error occurs.

Definition at line 196 of file clean.cc.

References CanonicalizePath(), DoCleanTarget(), Error(), IsVerbose(), LoadDyndeps(), PrintFooter(), PrintHeader(), Reset(), state_, and status_.

◆ DoCleanRule()

void Cleaner::DoCleanRule ( const Rule * rule)
private

Definition at line 223 of file clean.cc.

References Rule::name(), Remove(), RemoveEdgeFiles(), and state_.

Referenced by CleanRule(), and CleanRules().

◆ DoCleanTarget()

void Cleaner::DoCleanTarget ( Node * target)
private

Helper recursive method for CleanTarget().

Definition at line 150 of file clean.cc.

References cleaned_, DoCleanTarget(), Node::in_edge(), Node::path(), Remove(), and RemoveEdgeFiles().

Referenced by CleanTarget(), CleanTargets(), and DoCleanTarget().

◆ FileExists()

bool Cleaner::FileExists ( const std::string & path)
private
Returns
whether the file path exists.

Definition at line 42 of file clean.cc.

References disk_interface_, and Error().

Referenced by Remove().

◆ IsAlreadyRemoved()

bool Cleaner::IsAlreadyRemoved ( const std::string & path)
private
Returns
whether the given path has already been removed.

Definition at line 72 of file clean.cc.

References removed_.

Referenced by Remove().

◆ IsVerbose()

bool Cleaner::IsVerbose ( ) const
inline
Returns
whether the cleaner is in verbose mode.

Definition at line 71 of file clean.h.

References config_, BuildConfig::QUIET, and BuildConfig::VERBOSE.

Referenced by CleanRules(), CleanTargets(), PrintHeader(), and Report().

◆ LoadDyndeps()

void Cleaner::LoadDyndeps ( )
private

Load dependencies from dyndep bindings.

Definition at line 292 of file clean.cc.

References dyndep_loader_, Node::dyndep_pending(), and state_.

Referenced by CleanAll(), CleanDead(), CleanRule(), CleanRules(), CleanTarget(), and CleanTargets().

◆ PrintFooter()

void Cleaner::PrintFooter ( )
private

◆ PrintHeader()

void Cleaner::PrintHeader ( )
private

Definition at line 87 of file clean.cc.

References config_, IsVerbose(), and BuildConfig::QUIET.

Referenced by CleanAll(), CleanDead(), CleanRule(), CleanRules(), CleanTarget(), and CleanTargets().

◆ Remove()

void Cleaner::Remove ( const std::string & path)
private

Remove the given path file only if it has not been already removed.

Definition at line 56 of file clean.cc.

References config_, FileExists(), IsAlreadyRemoved(), removed_, RemoveFile(), Report(), and status_.

Referenced by CleanAll(), CleanDead(), DoCleanRule(), DoCleanTarget(), and RemoveEdgeFiles().

◆ RemoveEdgeFiles()

void Cleaner::RemoveEdgeFiles ( Edge * edge)
private

Remove the depfile and rspfile for an Edge.

Definition at line 77 of file clean.cc.

References Edge::GetUnescapedDepfile(), Edge::GetUnescapedRspfile(), and Remove().

Referenced by CleanAll(), DoCleanRule(), and DoCleanTarget().

◆ RemoveFile()

int Cleaner::RemoveFile ( const std::string & path)
private

Remove the file path.

Returns
whether the file has been removed.

Definition at line 38 of file clean.cc.

References disk_interface_.

Referenced by Remove().

◆ Report()

void Cleaner::Report ( const std::string & path)
private

Definition at line 50 of file clean.cc.

References cleaned_files_count_, and IsVerbose().

Referenced by Remove().

◆ Reset()

void Cleaner::Reset ( )
private

Member Data Documentation

◆ cleaned_

std::set<Node*> Cleaner::cleaned_
private

Definition at line 105 of file clean.h.

Referenced by DoCleanTarget(), and Reset().

◆ cleaned_files_count_

int Cleaner::cleaned_files_count_
private

Definition at line 106 of file clean.h.

Referenced by cleaned_files_count(), Cleaner(), PrintFooter(), Report(), and Reset().

◆ config_

const BuildConfig& Cleaner::config_
private

Definition at line 102 of file clean.h.

Referenced by Cleaner(), IsVerbose(), PrintFooter(), PrintHeader(), and Remove().

◆ disk_interface_

DiskInterface* Cleaner::disk_interface_
private

Definition at line 107 of file clean.h.

Referenced by Cleaner(), FileExists(), and RemoveFile().

◆ dyndep_loader_

DyndepLoader Cleaner::dyndep_loader_
private

Definition at line 103 of file clean.h.

Referenced by Cleaner(), and LoadDyndeps().

◆ removed_

std::set<std::string> Cleaner::removed_
private

Definition at line 104 of file clean.h.

Referenced by IsAlreadyRemoved(), Remove(), and Reset().

◆ state_

State* Cleaner::state_
private

◆ status_

int Cleaner::status_
private

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