Skip to content
This repository
Newer
Older
100644 91 lines (64 sloc) 2.388 kb
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
1 namespace :debug do
2
3 desc "Create a dot graph of the Rakefile's dependencies. Use :exclude to exclude rules and dependencies."
1ff280a6 »
2008-08-01 Added top 10 node coloring, include filtering, and minimum edge filte…
4 task :graph, :include, :exclude, :minimum do |_, args|
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
5 begin
1ff280a6 »
2008-08-01 Added top 10 node coloring, include filtering, and minimum edge filte…
6 $: << File.expand_path("~/Work/p4/zss/src/ZenHacks/dev/lib/")
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
7 require 'graph'
8 rescue LoadError
9 abort 'install ZenHacks'
10 end
11
1ff280a6 »
2008-08-01 Added top 10 node coloring, include filtering, and minimum edge filte…
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
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
15
16 graph = Graph.new
17
18 Rake::Task.tasks.each do |task|
19 next if task.name =~ /^stats|^vm\/.depends.mf$/ # too many
1ff280a6 »
2008-08-01 Added top 10 node coloring, include filtering, and minimum edge filte…
20 next if include and task.name !~ include
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
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
1ff280a6 »
2008-08-01 Added top 10 node coloring, include filtering, and minimum edge filte…
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
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
44 end
45
97536dac »
2008-08-22 Added all_prereqs to debug.rake
46 def get_task name
47 Rake::Task.tasks.find { |t| t.name == name }
48 end
49
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
50 desc "Display prerequisites for a task"
51 task :prereqs, :task do |_, args|
52 raise "supply task argument" unless args[:task]
53
97536dac »
2008-08-22 Added all_prereqs to debug.rake
54 task = get_task args[:task]
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
55
56 raise "No such task #{args[:task].inspect}" unless task
57
ba84a863 »
2008-08-01 Make prereqs, dependees readable
58 puts task.prerequisites.join("\n")
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
59 end
60
97536dac »
2008-08-22 Added all_prereqs to debug.rake
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
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
76 desc "Display tasks that depend on a task"
77 task :dependees, :task do |_, args|
78 raise "supply task argument" unless args[:task]
79
97536dac »
2008-08-22 Added all_prereqs to debug.rake
80 task = get_task args[:task]
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
81
82 raise "No such task #{args[:task].inspect}" unless task
83
84 tasks = Rake::Task.tasks.select { |t| t.prerequisites.include? task.name }
85
ba84a863 »
2008-08-01 Make prereqs, dependees readable
86 puts tasks.join("\n")
72ad3d41 »
2008-07-31 Hook up more dependencies in vm.rake, especially for generated files.
87 end
88
89 end
90
Something went wrong with that request. Please try again.