From 08eace5a47620bb0a70448e0d6d71dce471bb2d2 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Mon, 28 Jan 2013 22:07:26 +0100 Subject: [PATCH] Do not remove old targets if ninja failed --- bin/gen_build | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/gen_build b/bin/gen_build index 921b64e1..08d0dcce 100755 --- a/bin/gen_build +++ b/bin/gen_build @@ -584,6 +584,7 @@ def all_targets(buildfile, builddir) Dir.chdir(File.dirname(buildfile)) do targets = %x{ ${TM_NINJA:-ninja} -f #{[ buildfile ].shelljoin } -t targets all } + return nil if $? != 0 targets.each do |line| if line =~ /.*(?=:(?! phony))/ path = $& @@ -739,11 +740,13 @@ end all_new_targets = all_targets(outfile, builddir) -targets_lost = all_old_targets - all_new_targets -targets_lost.each do |path| - if File.exists?(path) - STDERR << "Remove old target ‘#{path.sub(/#{Regexp.escape(builddir)}/, '$builddir')}’…\n" - File.unlink(path) +if all_old_targets && all_new_targets + targets_lost = all_old_targets - all_new_targets + targets_lost.each do |path| + if File.exists?(path) + STDERR << "Remove old target ‘#{path.sub(/#{Regexp.escape(builddir)}/, '$builddir')}’…\n" + File.unlink(path) + end end end