From 95d4e64a118983b504d852c328a415cbfe2f4b16 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Tue, 16 Nov 2010 03:40:13 -0800 Subject: [PATCH] If foo and foo.do exist, then foo is always a target, not a source file. The problem is if someone accidentally creates a file called "test" *before* .redo/gen^test got created, then 'redo test' would do nothing, because redo would assume it's a source file instead of a destination, according to djb's rule. But in this case, we know it's not, since test.do exists, so let's build it anyway. The problem is related to .PHONY rules in make. This workaround is kind of cheating, because we can't safely apply that rule if foo and default.do exist, even though default.do can be used to build foo. This probably won't happen very often... except with minimal/do, which creates these empty files even when it shouldn't. I'm not sure if I should try to fix that or not, though. --- redo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/redo.py b/redo.py index 90ad46e..9bd7225 100755 --- a/redo.py +++ b/redo.py @@ -99,7 +99,8 @@ def _preexec(t): def _build(t): - if os.path.exists(t) and not os.path.exists(sname('gen', t)): + if (os.path.exists(t) and not os.path.exists(sname('gen', t)) + and not os.path.exists('%s.do' % t)): # an existing source file that is not marked as a generated file. # This step is mentioned by djb in his notes. It turns out to be # important to prevent infinite recursion. For example, a rule