Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of multiple builds in .ninja_log #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions ninjatracing
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,28 @@ def read_targets(log, show_all):

targets = {}
last_end_seen = 0
# Start of the current (incremental) build.
build_start = 0
for line in log:
if line.startswith('#'):
continue
start, end, _, name, cmdhash = line.strip().split('\t') # Ignore restat.
if not show_all and int(end) < last_end_seen:
start = int(start)
end = int(end)
if end < last_end_seen:
# An earlier time stamp means that this step is the first in a new
# build, possibly an incremental build. Throw away the previous data
# so that this new build will be displayed independently.
targets = {}
last_end_seen = int(end)
targets.setdefault(cmdhash, Target(start, end)).targets.append(name)
# build, possibly an incremental build.
if not show_all:
# Throw away the previous data so that only the last build will
# be displayed.
targets = {}
else:
# Assume that the next build starts directly after the previous one.
build_start += last_end_seen
last_end_seen = end
targets \
.setdefault(cmdhash, Target(build_start + start, build_start + end)) \
.targets.append(name)
return sorted(targets.values(), key=lambda job: job.end, reverse=True)


Expand Down