redo now saves the stderr from every .do script, for every target, into a file in the .redo directory. That means you can look up the logs from the most recent build of any target using the new redo-log command, for example: redo-log -r all The default is to show logs non-recursively, that is, it'll show when a target does redo-ifchange on another target, but it won't recurse into the logs for the latter target. With -r (recursive), it does. With -u (unchanged), it does even if redo-ifchange discovered that the target was already up-to-date; in that case, it prints the logs of the *most recent* time the target was generated. With --no-details, redo-log will show only the 'redo' lines, not the other log messages. For very noisy build systems (like recursing into a 'make' instance) this can be helpful to get an overview of what happened, without all the cruft. You can use the -f (follow) option like tail -f, to follow a build that's currently in progress until it finishes. redo itself spins up a copy of redo-log -r -f while it runs, so you can see what's going on. Still broken in this version: - No man page or new tests yet. - ANSI colors don't yet work (unless you use --raw-logs, which gives the old-style behaviour). - You can't redirect the output of a sub-redo to a file or a pipe right now, because redo-log is eating it. - The regex for matching 'redo' lines in the log is very gross. Instead, we should put the raw log files in a more machine-parseable format, and redo-log should turn that into human-readable format. - redo-log tries to "linearize" the logs, which makes them comprehensible even for a large parallel build. It recursively shows log messages for each target in depth-first tree order (by tracing into a new target every time it sees a 'redo' line). This works really well, but in some specific cases, the "topmost" redo instance can get stuck waiting for a jwack token, which makes it look like the whole build has stalled, when really redo-log is just waiting a long time for a particular subprocess to be able to continue. We'll need to add a specific workaround for that.
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
import os
|
|
from atoi import atoi
|
|
|
|
if not os.environ.get('REDO'):
|
|
import sys
|
|
sys.stderr.write('%s: error: must be run from inside a .do\n'
|
|
% sys.argv[0])
|
|
sys.exit(100)
|
|
|
|
PWD = os.environ.get('REDO_PWD', '')
|
|
TARGET = os.environ.get('REDO_TARGET', '')
|
|
DEPTH = os.environ.get('REDO_DEPTH', '')
|
|
DEBUG = atoi(os.environ.get('REDO_DEBUG', ''))
|
|
DEBUG_LOCKS = os.environ.get('REDO_DEBUG_LOCKS', '') and 1 or 0
|
|
DEBUG_PIDS = os.environ.get('REDO_DEBUG_PIDS', '') and 1 or 0
|
|
VERBOSE = os.environ.get('REDO_VERBOSE', '') and 1 or 0
|
|
XTRACE = os.environ.get('REDO_XTRACE', '') and 1 or 0
|
|
KEEP_GOING = os.environ.get('REDO_KEEP_GOING', '') and 1 or 0
|
|
RAW_LOGS = os.environ.get('REDO_RAW_LOGS', '') and 1 or 0
|
|
SHUFFLE = os.environ.get('REDO_SHUFFLE', '') and 1 or 0
|
|
STARTDIR = os.environ.get('REDO_STARTDIR', '')
|
|
RUNID = atoi(os.environ.get('REDO_RUNID')) or None
|
|
BASE = os.environ['REDO_BASE']
|
|
while BASE and BASE.endswith('/'):
|
|
BASE = BASE[:-1]
|
|
|
|
UNLOCKED = os.environ.get('REDO_UNLOCKED', '') and 1 or 0
|
|
os.environ['REDO_UNLOCKED'] = '' # not inheritable by subprocesses
|
|
|
|
NO_OOB = os.environ.get('REDO_NO_OOB', '') and 1 or 0
|
|
os.environ['REDO_NO_OOB'] = '' # not inheritable by subprocesses
|
|
|
|
|
|
def get_locks():
|
|
"""Get the list of held locks."""
|
|
return os.environ.get('REDO_LOCKS', '').split(':')
|
|
|
|
def add_lock(name):
|
|
"""Add a lock to the list of held locks."""
|
|
locks = set(get_locks())
|
|
locks.add(name)
|
|
os.environ['REDO_LOCKS'] = ':'.join(list(locks))
|