summaryrefslogtreecommitdiffstats
path: root/src/clean.h
diff options
context:
space:
mode:
authorNicolas Despres <nicolas.despres@gmail.com>2011-05-02 14:09:10 (GMT)
committerNicolas Despres <nicolas.despres@gmail.com>2011-05-02 14:57:32 (GMT)
commit5113d8c29f2e165dabb05c5624055020704ba5fc (patch)
treeef3be3cbe13855200f03b182afeb2acb69d58ac6 /src/clean.h
parent23a7aa78bf2a8fffc27eec74e928c6681d11f094 (diff)
downloadNinja-5113d8c29f2e165dabb05c5624055020704ba5fc.zip
Ninja-5113d8c29f2e165dabb05c5624055020704ba5fc.tar.gz
Ninja-5113d8c29f2e165dabb05c5624055020704ba5fc.tar.bz2
Add a test for the clean tool.
It also fix a bug about the count of removed file reported.
Diffstat (limited to 'src/clean.h')
-rw-r--r--src/clean.h37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/clean.h b/src/clean.h
index 4513596..6194aa0 100644
--- a/src/clean.h
+++ b/src/clean.h
@@ -15,6 +15,8 @@
#ifndef NINJA_CLEAN_H_
#define NINJA_CLEAN_H_
+#include "build.h"
+
#include <string>
#include <set>
using namespace std;
@@ -23,15 +25,27 @@ struct State;
struct BuildConfig;
struct Node;
struct Rule;
+struct DiskInterface;
class Cleaner
{
public:
- /// Constructor.
+ /// Build a cleaner object with a real disk interface.
Cleaner(State* state, const BuildConfig& config);
+ /// Build a cleaner object with the given @a disk_interface
+ /// (Useful for testing).
+ Cleaner(State* state,
+ const BuildConfig& config,
+ DiskInterface* disk_interface);
+
/// Clean the given @a target and all the file built for it.
void CleanTarget(Node* target);
+ /// Clean the given target @a target.
+ /// @return non-zero if an error occurs.
+ int CleanTarget(const char* target);
+ /// Clean the given target @a targets.
+ /// @return non-zero if an error occurs.
int CleanTargets(int target_count, char* targets[]);
/// Clean all built files.
@@ -39,8 +53,24 @@ public:
/// Clean all the file built with the given rule @a rule.
void CleanRule(const Rule* rule);
+ /// Clean the file produced by the given @a rule.
+ /// @return non-zero if an error occurs.
+ int CleanRule(const char* rule);
+ /// Clean the file produced by the given @a rules.
+ /// @return non-zero if an error occurs.
int CleanRules(int rule_count, char* rules[]);
+ /// @return the number of file cleaned.
+ int cleaned_files_count() const {
+ return cleaned_files_count_;
+ }
+
+ /// @return whether the cleaner is in verbose mode.
+ bool IsVerbose() const {
+ return (config_.verbosity != BuildConfig::QUIET
+ && (config_.verbosity == BuildConfig::VERBOSE || config_.dry_run));
+ }
+
private:
/// Remove the file @a path.
/// @return whether the file has been removed.
@@ -60,9 +90,10 @@ private:
private:
State* state_;
- bool verbose_;
- bool dry_run_;
+ BuildConfig config_;
set<string> removed_;
+ int cleaned_files_count_;
+ DiskInterface* disk_interface_;
};
#endif // NINJA_CLEAN_H_