apenwarr-redo/redo-whichdo.py
Avery Pennarun 5c4f710f4e Raw logs contain @@REDO lines instead of formatted data.
This makes them more reliable to parse.  redo-log can parse each line,
format and print it, then recurse if necessary.  This got a little ugly
because I wanted 'redo --raw-logs' to work, which we want to format the
output nicely, but not call redo-log.

(As a result, --raw-logs has a different meaning to redo and
redo-log, which is kinda dumb.  I should fix that.)

As an added bonus, redo-log now handles indenting of recursive logs, so
if the build was a -> a/b -> a/b/c, and you look at the log for a/b, it
can still start at the top level indentation.
2018-11-17 10:27:44 -05:00

28 lines
685 B
Python
Executable file

#!/usr/bin/env python2
import sys, os
import vars_init
vars_init.init_no_state()
import paths
from logs import err
if len(sys.argv[1:]) != 1:
err('%s: exactly one argument expected.\n' % sys.argv[0])
sys.exit(1)
want = sys.argv[1]
if not want:
err('cannot build the empty target ("").\n')
sys.exit(204)
abswant = os.path.abspath(want)
for dodir,dofile,basedir,basename,ext in paths.possible_do_files(abswant):
dopath = os.path.join('/', dodir, dofile)
relpath = os.path.relpath(dopath, '.')
exists = os.path.exists(dopath)
assert('\n' not in relpath)
print relpath
if exists:
sys.exit(0)
sys.exit(1) # no appropriate dofile found