summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure.py9
-rw-r--r--src/build.cc12
-rw-r--r--src/clean.cc20
-rw-r--r--src/clean_test.cc25
4 files changed, 50 insertions, 16 deletions
diff --git a/configure.py b/configure.py
index e498059..79d6ac9 100755
--- a/configure.py
+++ b/configure.py
@@ -260,11 +260,14 @@ if options.with_gtest:
path = options.with_gtest
gtest_all_incs = '-I%s -I%s' % (path, os.path.join(path, 'include'))
- gtest_cflags = '-fvisibility=hidden ' + gtest_all_incs
- objs += n.build(built('gtest-all.o'), 'cxx',
+ if platform == 'windows':
+ gtest_cflags = '/nologo /EHsc ' + gtest_all_incs
+ else:
+ gtest_cflags = '-fvisibility=hidden ' + gtest_all_incs
+ objs += n.build(built('gtest-all' + objext), 'cxx',
os.path.join(path, 'src/gtest-all.cc'),
variables=[('cflags', gtest_cflags)])
- objs += n.build(built('gtest_main.o'), 'cxx',
+ objs += n.build(built('gtest_main' + objext), 'cxx',
os.path.join(path, 'src/gtest_main.cc'),
variables=[('cflags', gtest_cflags)])
diff --git a/src/build.cc b/src/build.cc
index 74d310d..ac49d27 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -513,10 +513,6 @@ struct DryRunCommandRunner : public CommandRunner {
Builder::Builder(State* state, const BuildConfig& config)
: state_(state), config_(config) {
disk_interface_ = new RealDiskInterface;
- if (config.dry_run)
- command_runner_.reset(new DryRunCommandRunner);
- else
- command_runner_.reset(new RealCommandRunner(config));
status_ = new BuildStatus(config);
log_ = state->build_log_;
}
@@ -589,6 +585,14 @@ bool Builder::Build(string* err) {
int pending_commands = 0;
int failures_allowed = config_.failures_allowed;
+ // Set up the command runner if we haven't done so already.
+ if (!command_runner_.get()) {
+ if (config_.dry_run)
+ command_runner_.reset(new DryRunCommandRunner);
+ else
+ command_runner_.reset(new RealCommandRunner(config_));
+ }
+
// This main loop runs the entire build process.
// It is structured like this:
// First, we attempt to start as many commands as allowed by the
diff --git a/src/clean.cc b/src/clean.cc
index c6a294f..3fe23ec 100644
--- a/src/clean.cc
+++ b/src/clean.cc
@@ -102,7 +102,7 @@ int Cleaner::CleanAll(bool generator) {
for (vector<Edge*>::iterator e = state_->edges_.begin();
e != state_->edges_.end(); ++e) {
// Do not try to remove phony targets
- if ((*e)->rule_ == &State::kPhonyRule)
+ if ((*e)->is_phony())
continue;
// Do not remove generator's files unless generator specified.
if (!generator && (*e)->rule().generator())
@@ -123,14 +123,16 @@ int Cleaner::CleanAll(bool generator) {
}
void Cleaner::DoCleanTarget(Node* target) {
- if (target->in_edge()) {
- Remove(target->path());
- if (!target->in_edge()->rule().depfile().empty())
- Remove(target->in_edge()->EvaluateDepFile());
- if (target->in_edge()->HasRspFile())
- Remove(target->in_edge()->GetRspFile());
- for (vector<Node*>::iterator n = target->in_edge()->inputs_.begin();
- n != target->in_edge()->inputs_.end();
+ if (Edge* e = target->in_edge()) {
+ // Do not try to remove phony targets
+ if (!e->is_phony()) {
+ Remove(target->path());
+ if (!target->in_edge()->rule().depfile().empty())
+ Remove(target->in_edge()->EvaluateDepFile());
+ if (e->HasRspFile())
+ Remove(e->GetRspFile());
+ }
+ for (vector<Node*>::iterator n = e->inputs_.begin(); n != e->inputs_.end();
++n) {
DoCleanTarget(*n);
}
diff --git a/src/clean_test.cc b/src/clean_test.cc
index 2e3a6b0..5ed48da 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -347,3 +347,28 @@ TEST_F(CleanTest, CleanFailure) {
Cleaner cleaner(&state_, config_, &fs_);
EXPECT_NE(0, cleaner.CleanAll());
}
+
+TEST_F(CleanTest, CleanPhony) {
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"build phony: phony t1 t2\n"
+"build t1: cat\n"
+"build t2: cat\n"));
+
+ fs_.Create("phony", 1, "");
+ fs_.Create("t1", 1, "");
+ fs_.Create("t2", 1, "");
+
+ // Check that CleanAll does not remove "phony".
+ Cleaner cleaner(&state_, config_, &fs_);
+ EXPECT_EQ(0, cleaner.CleanAll());
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_NE(0, fs_.Stat("phony"));
+
+ fs_.Create("t1", 1, "");
+ fs_.Create("t2", 1, "");
+
+ // Check that CleanTarget does not remove "phony".
+ EXPECT_EQ(0, cleaner.CleanTarget("phony"));
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_NE(0, fs_.Stat("phony"));
+}