Show dependencies as a tree rather than a list

This commit is contained in:
Eelco Dolstra 2013-02-14 15:53:34 +01:00
parent 4e67665b7f
commit 82daf4f8ca
4 changed files with 74 additions and 41 deletions

View file

@ -306,6 +306,39 @@ sub contents : Chained('build') PathPart Args(1) {
} }
sub getDependencyGraph {
my ($self, $c, $runtime, $done, $path) = @_;
my $node = $$done{$path};
if (!defined $node) {
$path =~ /\/[a-z0-9]+-(.*)$/;
my $name = $1 // $path;
$name =~ s/\.drv$//;
$node =
{ path => $path
, name => $name
, buildStep => $runtime
? findBuildStepByOutPath($self, $c, $path, 0)
: findBuildStepByDrvPath($self, $c, $path, 0)
};
$$done{$path} = $node;
my @refs;
foreach my $ref (queryReferences($path)) {
next if $ref eq $path;
next unless $runtime || $ref =~ /\.drv$/;
getDependencyGraph($self, $c, $runtime, $done, $ref);
push @refs, $ref;
}
# Show in reverse topological order to flatten the graph.
# Should probably do a proper BFS.
my @sorted = reverse topoSortPaths(@refs);
$node->{refs} = [map { $$done{$_} } @sorted];
}
return $node;
}
sub deps : Chained('build') PathPart('deps') { sub deps : Chained('build') PathPart('deps') {
my ($self, $c) = @_; my ($self, $c) = @_;
@ -316,28 +349,16 @@ sub deps : Chained('build') PathPart('deps') {
$c->stash->{available} = all { isValidPath($_) } @outPaths; $c->stash->{available} = all { isValidPath($_) } @outPaths;
$c->stash->{drvAvailable} = isValidPath $drvPath; $c->stash->{drvAvailable} = isValidPath $drvPath;
my @buildtimepaths = $c->stash->{drvAvailable} ? computeFSClosure(0, 0, $drvPath) : (); if ($c->stash->{available}) {
my @buildtimedeps = (); my $done = {};
$c->stash->{runtimeGraph} = [ map { getDependencyGraph($self, $c, 1, $done, $_) } @outPaths ];
my @runtimepaths = $c->stash->{available} ? computeFSClosure(0, 0, @outPaths) : ();
my @runtimedeps = ();
foreach my $p (@buildtimepaths) {
next unless $p =~ /\.drv$/;
my ($buildStep) = findBuildStepByDrvPath($self, $c, $p, 0);
my %dep = ( buildstep => $buildStep, path => $p );
push(@buildtimedeps, \%dep);
} }
foreach my $p (@runtimepaths) { if ($c->stash->{drvAvailable}) {
my ($buildStep) = findBuildStepByOutPath($self, $c, $p, 0); my $done = {};
my %dep = ( buildstep => $buildStep, path => $p ); $c->stash->{buildTimeGraph} = getDependencyGraph($self, $c, 0, $done, $drvPath);
push(@runtimedeps, \%dep);
} }
$c->stash->{buildtimedeps} = \@buildtimedeps;
$c->stash->{runtimedeps} = \@runtimedeps;
$c->stash->{template} = 'deps.tt'; $c->stash->{template} = 'deps.tt';
} }

View file

@ -53,9 +53,7 @@
[% ELSE %] [% ELSE %]
<span class="error">Failed: [% HTML.escape(step.errormsg) %]</span> <span class="error">Failed: [% HTML.escape(step.errormsg) %]</span>
[% END %] [% END %]
[% IF has_log %] [%%] [%+ IF has_log; INCLUDE renderLogLinks url=log; END %]
(<a href="[% log %]">log</a>, <a href="[% "$log/raw" %]">raw</a>, <a href="[% "$log/tail-reload" %]">tail</a>)
[% END %]
</td> </td>
</tr> </tr>
[% END %] [% END %]

View file

@ -475,3 +475,8 @@
</tbody> </tbody>
</table> </table>
[% END %] [% END %]
[% BLOCK renderLogLinks %]
(<a href="[% url %]">log</a>, <a href="[% "$url/raw" %]">raw</a>, <a href="[% "$url/tail-reload" %]">tail</a>)
[% END %]

View file

@ -6,40 +6,49 @@
[% jobset = build.jobset %] [% jobset = build.jobset %]
[% job = build.job %] [% job = build.job %]
<a name="runtime"></a> [% BLOCK renderNode %]
[% IF available %]
<h1>Runtime dependencies</h1>
<ul>
[% FOREACH dep IN runtimedeps -%]
<li> <li>
[% IF dep.buildstep %] [% IF done.${node.path} %]
<a href="[% c.uri_for('/build' dep.buildstep.get_column('build') 'nixlog' dep.buildstep.stepnr) %]">[% dep.path %]</a> <p><tt>[% node.name %]</tt> (<em>repeated</em>)</p>
[% ELSE %] [% ELSE %]
[% dep.path %] [% done.${node.path} = 1 %]
<p>
[% IF node.buildStep %]
<a href="[% c.uri_for('/build' node.buildStep.get_column('build')) %]"><tt>[% node.name %]</tt></a> [%
IF log_exists(node.buildStep.drvpath);
INCLUDE renderLogLinks url=c.uri_for('/build' node.buildStep.get_column('build') 'nixlog' node.buildStep.stepnr);
END %]
[% ELSE %]
<tt>[% node.name %]</tt>
[% END %]
</p>
[% IF node.refs.size > 0 %]
<ul>
[% FOREACH ref IN node.refs; INCLUDE renderNode node=ref; END %]
</ul>
[% END %]
[% END %] [% END %]
</li> </li>
[% END %] [% END %]
<a name="runtime"></a>
<h2>Runtime dependency graph</h2>
[% IF available %]
<ul>
[% done={}; FOREACH node IN runtimeGraph; INCLUDE renderNode; END %]
</ul> </ul>
[% ELSE %] [% ELSE %]
Path not available anymore!<br /> <p><em>No longer available.</em></p>
[% END %] [% END %]
<a name="buildtime"></a> <a name="buildtime"></a>
<h2>Build-time dependency graph</h2>
[% IF drvAvailable %] [% IF drvAvailable %]
<h1>Build time dependencies</h1>
<ul> <ul>
[% FOREACH dep IN buildtimedeps -%] [% INCLUDE renderNode node=buildTimeGraph %]
<li>
[% IF dep.buildstep %]
<a href="[% c.uri_for('/build' dep.buildstep.get_column('build') 'nixlog' dep.buildstep.stepnr) %]">[% dep.path %]</a>
[% ELSE %]
[% dep.path %]
[% END %]
</li>
[% END %]
</ul> </ul>
[% ELSE %] [% ELSE %]
Derivation not available anymore!<br /> <p><em>No longer available.</em></p>
[% END %] [% END %]
[% END %] [% END %]