From 1cb000ece1f223761ef164a858ea09339e169d5c Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sat, 11 Dec 2010 21:19:15 -0800 Subject: [PATCH] redo.py: report when you're trying to rebuild a static file. In redo-ifchange, this might be a good idea, since you might just want to set a dependency on it, so we won't say anything from inside builder.py. But if you're calling redo.py, that means you expect it to be rebuilt, since there's no other reason to try. So print a warning. (This is what make does, more or less.) --- redo-ifchange.py | 5 +---- redo.py | 9 ++++++++- state.py | 4 ++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/redo-ifchange.py b/redo-ifchange.py index be8aa7f..a3cc7a7 100755 --- a/redo-ifchange.py +++ b/redo-ifchange.py @@ -10,14 +10,11 @@ import vars, state, builder, jwack from helpers import unlink from log import debug, debug2, err -def _nice(t): - return state.relpath(os.path.join(vars.BASE, t), vars.STARTDIR) - CLEAN = 0 DIRTY = 1 def dirty_deps(f, depth, max_changed): if vars.DEBUG >= 1: - debug('%s?%s\n' % (depth, _nice(f.name))) + debug('%s?%s\n' % (depth, f.nicename())) if f.failed_runid: debug('%s-- DIRTY (failed last time)\n' % depth) diff --git a/redo.py b/redo.py index db4ba7b..ce9e3bc 100755 --- a/redo.py +++ b/redo.py @@ -39,9 +39,16 @@ import vars_init vars_init.init(targets) import vars, state, builder, jwack -from log import err +from log import warn, err try: + for t in targets: + if os.path.exists(t): + f = state.File(name=t) + if not f.is_generated: + warn('%s: exists and not marked as generated; not redoing.\n' + % f.nicename()) + j = atoi(opt.jobs or 1) if j < 1 or j > 1000: err('invalid --jobs value: %r\n' % opt.jobs) diff --git a/state.py b/state.py index ce43ad1..5eaf1ce 100644 --- a/state.py +++ b/state.py @@ -276,6 +276,10 @@ class File(object): # a "unique identifier" stamp for a regular file return str((st.st_ctime, st.st_mtime, st.st_size, st.st_ino)) + def nicename(self): + return relpath(os.path.join(vars.BASE, self.name), vars.STARTDIR) + + # FIXME: I really want to use fcntl F_SETLK, F_SETLKW, etc here. But python # doesn't do the lockdata structure in a portable way, so we have to use