Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 72 lines (51 sloc) 2.004 kB
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
1 namespace :debug do
2
3 desc "Create a dot graph of the Rakefile's dependencies. Use :exclude to exclude rules and dependencies."
1ff280a Added top 10 node coloring, include filtering, and minimum edge filte…
Ryan Davis authored
4 task :graph, :include, :exclude, :minimum do |_, args|
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
5 begin
1ff280a Added top 10 node coloring, include filtering, and minimum edge filte…
Ryan Davis authored
6 $: << File.expand_path("~/Work/p4/zss/src/ZenHacks/dev/lib/")
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
7 require 'graph'
8 rescue LoadError
9 abort 'install ZenHacks'
10 end
11
1ff280a Added top 10 node coloring, include filtering, and minimum edge filte…
Ryan Davis authored
12 exclude = Regexp.new(args[:exclude]) if args[:exclude]
13 include = Regexp.new(args[:include]) if args[:exclude]
14 minimum = (args[:minimum] || 0).to_i
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
15
16 graph = Graph.new
17
18 Rake::Task.tasks.each do |task|
19 next if task.name =~ /^stats|^vm\/.depends.mf$/ # too many
1ff280a Added top 10 node coloring, include filtering, and minimum edge filte…
Ryan Davis authored
20 next if include and task.name !~ include
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
21 next if exclude and task.name =~ exclude
22
23 prereqs = task.prerequisites
24 prereqs = prereqs.reject do |prereq|
25 prereq =~ exclude
26 end if exclude
27
28 graph[task.name] = prereqs
29 end
30
1ff280a Added top 10 node coloring, include filtering, and minimum edge filte…
Ryan Davis authored
31 invert_graph = graph.invert
32 invert_graph.filter_size minimum if minimum > 0
33 invert_graph.prefix << 'rankdir="LR"'
34
35 invert_graph.keys_by_count.first(10).each_with_index do |key, i|
36 if i < 5 then
37 invert_graph.attribs[key] << "color = red"
38 else
39 invert_graph.attribs[key] << "color = orange"
40 end
41 end
42
43 open 'rubinius_tasks.dot', 'w' do |io| io << invert_graph end
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
44 end
45
46 desc "Display prerequisites for a task"
47 task :prereqs, :task do |_, args|
48 raise "supply task argument" unless args[:task]
49
50 task = Rake::Task.tasks.find { |t| t.name == args[:task] }
51
52 raise "No such task #{args[:task].inspect}" unless task
53
54 puts task.prerequisites.join(', ')
55 end
56
57 desc "Display tasks that depend on a task"
58 task :dependees, :task do |_, args|
59 raise "supply task argument" unless args[:task]
60
61 task = Rake::Task.tasks.find { |t| t.name == args[:task] }
62
63 raise "No such task #{args[:task].inspect}" unless task
64
65 tasks = Rake::Task.tasks.select { |t| t.prerequisites.include? task.name }
66
67 puts tasks.join(', ')
68 end
69
70 end
71
Something went wrong with that request. Please try again.