2010-12-19 02:31:40 -08:00
|
|
|
import sys, os
|
|
|
|
|
import vars, state, builder
|
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-13 04:05:42 -05:00
|
|
|
from logs import debug
|
2010-12-19 02:31:40 -08:00
|
|
|
|
|
|
|
|
CLEAN = 0
|
|
|
|
|
DIRTY = 1
|
|
|
|
|
|
2010-12-19 03:39:37 -08:00
|
|
|
def isdirty(f, depth, max_changed,
|
2018-10-30 23:03:46 -04:00
|
|
|
already_checked,
|
2010-12-19 03:39:37 -08:00
|
|
|
is_checked=state.File.is_checked,
|
|
|
|
|
set_checked=state.File.set_checked_save):
|
2018-10-30 23:03:46 -04:00
|
|
|
if f.id in already_checked:
|
|
|
|
|
raise state.CyclicDependencyError()
|
|
|
|
|
# make a copy of the list, so upon returning, our parent's copy
|
|
|
|
|
# is unaffected
|
|
|
|
|
already_checked = list(already_checked) + [f.id]
|
|
|
|
|
|
2010-12-19 02:31:40 -08:00
|
|
|
if vars.DEBUG >= 1:
|
|
|
|
|
debug('%s?%s\n' % (depth, f.nicename()))
|
|
|
|
|
|
|
|
|
|
if f.failed_runid:
|
|
|
|
|
debug('%s-- DIRTY (failed last time)\n' % depth)
|
|
|
|
|
return DIRTY
|
|
|
|
|
if f.changed_runid == None:
|
|
|
|
|
debug('%s-- DIRTY (never built)\n' % depth)
|
|
|
|
|
return DIRTY
|
|
|
|
|
if f.changed_runid > max_changed:
|
|
|
|
|
debug('%s-- DIRTY (built)\n' % depth)
|
|
|
|
|
return DIRTY # has been built more recently than parent
|
2010-12-19 03:39:37 -08:00
|
|
|
if is_checked(f):
|
2010-12-19 02:31:40 -08:00
|
|
|
if vars.DEBUG >= 1:
|
|
|
|
|
debug('%s-- CLEAN (checked)\n' % depth)
|
|
|
|
|
return CLEAN # has already been checked during this session
|
|
|
|
|
if not f.stamp:
|
|
|
|
|
debug('%s-- DIRTY (no stamp)\n' % depth)
|
|
|
|
|
return DIRTY
|
|
|
|
|
|
|
|
|
|
newstamp = f.read_stamp()
|
|
|
|
|
if f.stamp != newstamp:
|
|
|
|
|
if newstamp == state.STAMP_MISSING:
|
|
|
|
|
debug('%s-- DIRTY (missing)\n' % depth)
|
|
|
|
|
else:
|
|
|
|
|
debug('%s-- DIRTY (mtime)\n' % depth)
|
|
|
|
|
if f.csum:
|
|
|
|
|
return [f]
|
|
|
|
|
else:
|
|
|
|
|
return DIRTY
|
|
|
|
|
|
|
|
|
|
must_build = []
|
|
|
|
|
for mode,f2 in f.deps():
|
|
|
|
|
dirty = CLEAN
|
|
|
|
|
if mode == 'c':
|
|
|
|
|
if os.path.exists(os.path.join(vars.BASE, f2.name)):
|
|
|
|
|
debug('%s-- DIRTY (created)\n' % depth)
|
|
|
|
|
dirty = DIRTY
|
|
|
|
|
elif mode == 'm':
|
|
|
|
|
sub = isdirty(f2, depth = depth + ' ',
|
|
|
|
|
max_changed = max(f.changed_runid,
|
2010-12-19 03:39:37 -08:00
|
|
|
f.checked_runid),
|
2018-10-30 23:03:46 -04:00
|
|
|
already_checked=already_checked,
|
2010-12-19 03:39:37 -08:00
|
|
|
is_checked=is_checked, set_checked=set_checked)
|
2010-12-19 02:31:40 -08:00
|
|
|
if sub:
|
|
|
|
|
debug('%s-- DIRTY (sub)\n' % depth)
|
|
|
|
|
dirty = sub
|
|
|
|
|
else:
|
|
|
|
|
assert(mode in ('c','m'))
|
|
|
|
|
if not f.csum:
|
|
|
|
|
# f is a "normal" target: dirty f2 means f is instantly dirty
|
2015-05-06 17:56:14 -04:00
|
|
|
if dirty == DIRTY:
|
|
|
|
|
# f2 is definitely dirty, so f definitely needs to
|
|
|
|
|
# redo.
|
|
|
|
|
return DIRTY
|
|
|
|
|
elif isinstance(dirty,list):
|
|
|
|
|
# our child f2 might be dirty, but it's not sure yet. It's
|
|
|
|
|
# given us a list of targets we have to redo in order to
|
|
|
|
|
# be sure.
|
|
|
|
|
must_build += dirty
|
2010-12-19 02:31:40 -08:00
|
|
|
else:
|
|
|
|
|
# f is "checksummable": dirty f2 means f needs to redo,
|
|
|
|
|
# but f might turn out to be clean after that (ie. our parent
|
|
|
|
|
# might not be dirty).
|
|
|
|
|
if dirty == DIRTY:
|
|
|
|
|
# f2 is definitely dirty, so f definitely needs to
|
|
|
|
|
# redo. However, after that, f might turn out to be
|
|
|
|
|
# unchanged.
|
|
|
|
|
return [f]
|
|
|
|
|
elif isinstance(dirty,list):
|
|
|
|
|
# our child f2 might be dirty, but it's not sure yet. It's
|
|
|
|
|
# given us a list of targets we have to redo in order to
|
|
|
|
|
# be sure.
|
|
|
|
|
must_build += dirty
|
|
|
|
|
|
|
|
|
|
if must_build:
|
|
|
|
|
# f is *maybe* dirty because at least one of its children is maybe
|
|
|
|
|
# dirty. must_build has accumulated a list of "topmost" uncertain
|
|
|
|
|
# objects in the tree. If we build all those, we can then
|
|
|
|
|
# redo-ifchange f and it won't have any uncertainty next time.
|
|
|
|
|
return must_build
|
2015-05-06 17:56:14 -04:00
|
|
|
debug('%s-- CLEAN\n' % (depth,))
|
2010-12-19 02:31:40 -08:00
|
|
|
|
|
|
|
|
# if we get here, it's because the target is clean
|
|
|
|
|
if f.is_override:
|
|
|
|
|
state.warn_override(f.name)
|
2010-12-19 03:39:37 -08:00
|
|
|
set_checked(f)
|
2010-12-19 02:31:40 -08:00
|
|
|
return CLEAN
|
|
|
|
|
|
|
|
|
|
|