Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 99 lines (72 sloc) 2.566 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]
bfd65dd Added recursive dependency reporting
Ryan Davis authored
14 minimum = (args[:minimum] || 10).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|
bfd65dd Added recursive dependency reporting
Ryan Davis authored
19 next unless task.name =~ /^vm/
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
bfd65dd Added recursive dependency reporting
Ryan Davis authored
42
1ff280a Added top 10 node coloring, include filtering, and minimum edge filte…
Ryan Davis authored
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
97536da Added all_prereqs to debug.rake
Ryan Davis authored
46 def get_task name
47 Rake::Task.tasks.find { |t| t.name == name }
48 end
49
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
50 desc "Display prerequisites for a task"
51 task :prereqs, :task do |_, args|
52 raise "supply task argument" unless args[:task]
53
97536da Added all_prereqs to debug.rake
Ryan Davis authored
54 task = get_task args[:task]
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
55
56 raise "No such task #{args[:task].inspect}" unless task
57
ba84a86 @drbrain Make prereqs, dependees readable
drbrain authored
58 puts task.prerequisites.join("\n")
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
59 end
60
97536da Added all_prereqs to debug.rake
Ryan Davis authored
61 desc "Display prerequisites for a task"
62 task :all_prereqs, :task do |_, args|
63 raise "supply task argument" unless args[:task]
64
65 task = get_task args[:task]
66
67 raise "No such task #{args[:task].inspect}" unless task
68
69 all = task.prerequisites
70 all += all.map { |n| get_task(n).prerequisites }
71 all = all.flatten.uniq
72
73 puts all.join("\n")
74 end
75
bfd65dd Added recursive dependency reporting
Ryan Davis authored
76 def print_deps(task, depth = 0, done = {})
77 deps = Rake::Task.tasks.select { |t| t.prerequisites.include? task.name }
78 deps.each do |dep|
79 next if done[dep.name]
80 done[dep.name] = true
81 puts "#{' ' * depth}#{dep.name}"
82 print_deps(dep, depth+1, done)
83 end
84 end
85
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
86 desc "Display tasks that depend on a task"
87 task :dependees, :task do |_, args|
88 raise "supply task argument" unless args[:task]
89
97536da Added all_prereqs to debug.rake
Ryan Davis authored
90 task = get_task args[:task]
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
91
92 raise "No such task #{args[:task].inspect}" unless task
93
bfd65dd Added recursive dependency reporting
Ryan Davis authored
94 print_deps task
72ad3d4 @drbrain Hook up more dependencies in vm.rake, especially for generated files.
drbrain authored
95 end
96
97 end
98
Something went wrong with that request. Please try again.