Permalink
Browse files

Hook up more dependencies in vm.rake, especially for generated files.

Fix .depend.mf generation.
  • Loading branch information...
1 parent e3e1abb commit 72ad3d418b0453ca191227f59e1f794dc2991044 @drbrain drbrain committed Aug 1, 2008
Showing with 94 additions and 41 deletions.
  1. +1 −0 .gitignore
  2. +56 −0 rakelib/debug.rake
  3. +0 −19 rakelib/graph.rake
  4. +35 −20 rakelib/vm.rake
  5. +2 −0 vm/drivers/cli.cpp
  6. +0 −2 vm/instructions.rb
View
@@ -46,6 +46,7 @@ tmp
tmtags
/vm/log
+/vm/.instructions.cpp
attic/externals/syd-parser/pkg
View
@@ -0,0 +1,56 @@
+namespace :debug do
+
+ desc "Create a dot graph of the Rakefile's dependencies. Use :exclude to exclude rules and dependencies."
+ task :graph, :exclude, :filter do |_, args|
+ begin
+ require 'graph'
+ rescue LoadError
+ abort 'install ZenHacks'
+ end
+
+ exclude = /#{args[:exclude]}/ if args[:exclude]
+
+ graph = Graph.new
+ graph.prefix << 'rankdir="LR"'
+
+ Rake::Task.tasks.each do |task|
+ next if task.name =~ /^stats|^vm\/.depends.mf$/ # too many
+ next if exclude and task.name =~ exclude
+
+ prereqs = task.prerequisites
+ prereqs = prereqs.reject do |prereq|
+ prereq =~ exclude
+ end if exclude
+
+ graph[task.name] = prereqs
+ end
+
+ open 'rubinius_tasks.dot', 'w' do |io| io << graph end
+ end
+
+ desc "Display prerequisites for a task"
+ task :prereqs, :task do |_, args|
+ raise "supply task argument" unless args[:task]
+
+ task = Rake::Task.tasks.find { |t| t.name == args[:task] }
+
+ raise "No such task #{args[:task].inspect}" unless task
+
+ puts task.prerequisites.join(', ')
+ end
+
+ desc "Display tasks that depend on a task"
+ task :dependees, :task do |_, args|
+ raise "supply task argument" unless args[:task]
+
+ task = Rake::Task.tasks.find { |t| t.name == args[:task] }
+
+ raise "No such task #{args[:task].inspect}" unless task
+
+ tasks = Rake::Task.tasks.select { |t| t.prerequisites.include? task.name }
+
+ puts tasks.join(', ')
+ end
+
+end
+
View
@@ -1,19 +0,0 @@
-task :graph, :exclude do |_, args|
- begin
- require 'graph'
- rescue LoadError
- abort 'install ZenHacks'
- end
-
- exclude = /#{args[:exclude]}/ if args[:exclude]
-
- graph = Graph.new
-
- Rake::Task.tasks.each do |task|
- next if exclude and task.name =~ exclude
- graph[task.name] = task.prerequisites
- end
-
- open 'rubinius_tasks.dot', 'w' do |io| io << graph end
-end
-
View
@@ -17,6 +17,7 @@ EX_INC = %w[ libtommath onig libffi/include
].map { |f| "vm/external_libs/#{f}" }
INSN_GEN = %w[ vm/gen/iseq_instruction_names.cpp
vm/gen/iseq_instruction_names.hpp
+ vm/gen/iseq_instruction_size.gen
vm/test/test_instructions.hpp ]
TYPE_GEN = %w[ vm/gen/simple_field.rb
vm/gen/typechecks.gen.cpp
@@ -76,7 +77,6 @@ directory "vm/gen"
file "vm/type_info.o" => "vm/gen/typechecks.gen.cpp"
file "vm/primitives.hpp" => "vm/gen/primitives_declare.hpp"
files Dir["vm/builtin/*.hpp"], INSN_GEN
-files objs, EXTERNALS
files vm_objs, vm_srcs
objs.zip(srcs).each do |obj, src|
@@ -96,13 +96,16 @@ files EXTERNALS do |t|
end
end
-file 'vm/instructions.rb' => 'vm/instructions_gen.rb'
+file 'vm/instructions_gen.rb' => 'kernel/core/iseq.rb'
+file 'vm/instructions.rb' => %w[vm/gen vm/instructions_gen.rb]
-files INSN_GEN, %w[vm/gen vm/instructions.rb] do
+files INSN_GEN, %w[vm/instructions.rb] do
ruby 'vm/instructions.rb', :verbose => $verbose
end
-files TYPE_GEN, %w[vm/gen vm/instructions.rb vm/field_extract.rb] do
+file 'vm/field_extract.rb' => %w[vm/gen vm/builtin/object.hpp vm/objects.hpp]
+
+files TYPE_GEN, %w[vm/field_extract.rb] do
field_extract
end
@@ -124,16 +127,16 @@ file 'vm/test/runner' => EXTERNALS + objs + %w[vm/test/runner.o] do |t|
link t
end
-file "vm/instructions.o" => %w[vm/llvm/instructions.cpp vm/instructions.rb] do
- ruby "vm/rubypp.rb vm/llvm/instructions.cpp vm/llvm/.instructions.cpp"
- compile "vm/instructions.o", "vm/llvm/.instructions.cpp"
- rm_f "vm/llvm/.instructions.cpp", :verbose => $verbose
+file 'vm/.instructions.cpp' => %w[vm/llvm/instructions.cpp vm/rubypp.rb] do
+ ruby 'vm/rubypp.rb vm/llvm/instructions.cpp vm/.instructions.cpp'
+end
+
+file "vm/instructions.o" => 'vm/.instructions.cpp' do
+ compile "vm/instructions.o", "vm/.instructions.cpp"
end
-file "vm/instructions.bc" => "vm/llvm/instructions.cpp" do
- ruby "vm/rubypp.rb vm/llvm/instructions.cpp vm/llvm/.instructions.cpp"
- sh "llvm-g++ -emit-llvm -Ivm -Ivm/external_libs/libffi/include -c -o vm/instructions.bc vm/llvm/.instructions.cpp", :verbose => true
- rm_f "llvm/.instructions.cpp", :verbose => $verbose
+file "vm/instructions.bc" => 'vm/.instructions.cpp' do
+ sh "llvm-g++ -emit-llvm -Ivm -Ivm/external_libs/libffi/include -c -o vm/instructions.bc vm/.instructions.cpp", :verbose => true
end
namespace :vm do
@@ -147,7 +150,9 @@ namespace :vm do
task :clean do
files = [
objs, dep_file,
- 'vm/test/runner', 'vm/test/runner.cpp',
+ 'vm/test/runner',
+ 'vm/test/runner.cpp',
+ 'vm/test/test_instructions.cpp',
'vm/gen',
'vm/vm'
]
@@ -185,14 +190,22 @@ end
require 'rake/loaders/makefile'
-file dep_file => srcs + hdrs + vm_srcs do |t|
- flags = (INCLUDES + FLAGS).join(' ')
+generated = (TYPE_GEN + INSN_GEN).select { |f| f =~ /pp$/ }
+
+file dep_file => srcs + hdrs + vm_srcs + generated do |t|
+ includes = INCLUDES.join ' '
+
+ flags = FLAGS.join ' '
flags << " -D__STDC_LIMIT_MACROS"
- dep = nil
- Dir.chdir 'vm' do
- dep = `makedepend -f- -- #{flags} -- #{t.prerequisites} 2>/dev/null`
+ cmd = "makedepend -f- #{includes} -- #{flags} -- #{t.prerequisites}"
+ if $verbose then
+ puts cmd
+ else
+ cmd << ' 2>/dev/null'
end
+
+ dep = `#{cmd}`
dep.gsub!(%r% /usr/include\S+%, '') # speeds up rake a lot
dep.gsub!(%r%^\S+:[^ ]%, '')
@@ -220,9 +233,11 @@ end
def field_extract
order = %w[vm/builtin/object.hpp vm/objects.hpp]
- order += File.read("vm/objects.hpp").scan(/builtin[^"]+/).map { |f| "vm/#{f}" }
+ objects = File.read("vm/objects.hpp").scan(/builtin\/[^"]+/)
+
+ order += objects.map { |f| File.join 'vm', f }
order << { :verbose => $verbose}
-p order
+
ruby('vm/field_extract.rb', *order)
end
View
@@ -1,4 +1,6 @@
+#include <iostream>
#include "environment.hpp"
+#include "objects.hpp"
using namespace rubinius;
View
@@ -3529,8 +3529,6 @@ def check_serial(index, serial)
if $0 == __FILE__
si = Instructions.new
- Dir.mkdir "vm/gen" unless File.directory?("vm/gen")
-
File.open("vm/gen/iseq_instruction_names.cpp","w") do |f|
f.puts si.generate_names
end

0 comments on commit 72ad3d4

Please sign in to comment.