Permalink
Browse files

* Reworked the Rakefile to build the compiler by detection, like boot…

…strap and core.

* Dumped using kernel/hints, the native/bytecode/system_hints.rb file now has the hints as a hash that is required by bytecode/compiler
* A couple of changes to __loader.rb
  • Loading branch information...
1 parent 8ba8409 commit 3751f33173344c4b7052e4db1a06e9060ae4cd65 @evanphx evanphx committed May 16, 2007
View
168 Rakefile
@@ -241,9 +241,9 @@ namespace :build do
raise 'Failed to install rubinius' if $?.exitstatus != 0
end
- FileList['lib/types/*.rb'].each do |src|
- file 'kernel/hints' => src
- end
+ #FileList['lib/types/*.rb'].each do |src|
+ # file 'kernel/hints' => src
+ #end
file 'kernel/hints' do
puts "Building hints and fields..."
@@ -288,38 +288,52 @@ namespace :build do
end
end
- desc "Build the VM bootstrap archive with rubinius."
- task :bootstrap => 'kernel/hints' do
- files = Dir["kernel/bootstrap/*.rb"].sort
- temp_bs = "runtime/bootstrap.rba.old"
- system "cp runtime/bootstrap.rba #{temp_bs}"
- ENV['BOOTSTRAP'] = temp_bs
- changed = []
- files.each do |file|
- cmp = "#{file}c"
- unless newer?(file, cmp)
- changed << cmp
- system "shotgun/rubinius compile #{file}"
- end
- file << "c"
- end
-
- File.open(".load_order.txt","w") do |f|
- f.puts files.join("\n")
+ def update_archive(files, archive, dir=nil, path_truc=false)
+ archive = File.expand_path archive
+
+ changed = []
+ files.each do |file|
+ cmp = "#{file}c"
+ unless newer?(file, cmp)
+ changed << cmp
+ system "shotgun/rubinius compile #{file}"
end
+ file << "c"
+ end
- archive = "runtime/bootstrap.rba"
+ curdir = Dir.getwd
+ if dir
+ Dir.chdir(dir)
+ changed.map! { |f| f.gsub!(%r!^#{dir}/!, "") } if path_truc
+ end
+
+ File.open(".load_order.txt","w") do |f|
+ f.puts files.join("\n")
+ end
- if File.exists? archive
- if changed.empty?
- puts "No kernel/bootstrap files to update."
- else
- system "zip -u #{archive} .load_order.txt #{changed.join(' ')}"
- end
+ if File.exists? archive
+ if changed.empty?
+ puts "No files to update."
else
- system "zip #{archive} .load_order.txt #{files.join(' ')}"
+ system "zip -u #{archive} .load_order.txt #{changed.join(' ')}"
end
+ else
+ system "zip #{archive} .load_order.txt #{files.join(' ')}"
+ end
+
+ Dir.chdir(curdir) if dir
+ end
+ task :rba => [:bootstrap, :core, :compiler]
+
+ desc "Build the VM bootstrap archive with rubinius."
+ task :bootstrap do
+ archive = ENV['OUTPUT'] || "runtime/bootstrap.rba"
+ files = Dir["kernel/bootstrap/*.rb"].sort
+ temp_bs = "runtime/bootstrap.rba.old"
+ system "cp runtime/bootstrap.rba #{temp_bs}"
+ ENV['BOOTSTRAP'] = temp_bs
+ update_archive files, archive # , "kernel"
system "rm #{temp_bs}"
end
@@ -362,7 +376,7 @@ namespace :build do
end
desc "Build the core classes and methods archive."
- task :core => 'kernel/hints' do
+ task :core do
files = nil
files = Dir["kernel/core/*.rb"].sort
files.delete "kernel/core/__loader.rb"
@@ -373,34 +387,10 @@ namespace :build do
system "cp runtime/core.rba #{temp_bs}"
ENV['CORE'] = temp_bs
- changed = []
- files.each do |file|
- cmp = "#{file}c"
- unless newer?(file, cmp)
- changed << cmp
- system "shotgun/rubinius compile #{file}"
-# system "#{COMPILER} #{file}"
-# raise "Failed to compile #{file}" if $?.exitstatus != 0
- end
- file << "c"
- end
-
- File.open(".load_order.txt","w") do |f|
- f.puts files.join("\n")
- end
+ archive = ENV['OUTPUT'] || "runtime/core.rba"
+
+ update_archive files, archive # , "kernel"
- archive = "runtime/core.rba"
-
- if File.exists? archive
- if changed.empty?
- puts "No kernel/core files to update."
- else
- system "zip -u #{archive} .load_order.txt #{changed.join(' ')}"
- end
- else
- system "zip #{archive} .load_order.txt #{files.join(' ')}"
- end
-
system "rm #{temp_bs}"
end
@@ -442,50 +432,32 @@ namespace :build do
puts "\nNow do 'gem install externals/syd-parser/pkg/*.gem' as your gem superuser.\n\n"
end
- namespace :compiler do
- desc "Bootstrap the compiler."
- task :bootstrap do
- files = %w! bytecode/compiler bytecode/assembler bytecode/encoder
- sexp/simple_processor translation/normalize translation/local_scoping
- sexp/composite_processor translation/states sexp/exceptions
- bytecode/primitive_names!
-
- files.each do |name|
- file = "#{name}.rb"
- dir = File.dirname(file)
- dest_dir = File.join("native", dir)
- path = File.expand_path File.join("lib", file)
- dest = File.join("native", file)
- FileUtils.mkdir_p dest_dir
- FileUtils.symlink path, dest rescue nil
- Dir.chdir "native" do
- sh "#{COMPILER} #{file}"
- end
- raise "Failed to compile #{dest}" if $?.exitstatus != 0
- end
+ desc "Package up the compiler"
+ task :compiler do
+ files = %w! bytecode/compiler bytecode/assembler bytecode/encoder
+ sexp/simple_processor translation/normalize translation/local_scoping
+ sexp/composite_processor translation/states sexp/exceptions
+ bytecode/primitive_names !
- extra = %w!bytecode/rubinius!
- extra.each do |name|
- Dir.chdir "native" do
- file = name + '.rb'
- sh "#{COMPILER} #{name}.rb"
- end
- raise "Failed to compile native/#{name}" if $?.exitstatus != 0
- end
- end
-
- desc "Package up the compiler"
- task :package do
- File.unlink "compiler.rba" rescue nil
- Dir.chdir "native" do
- sh "zip ../runtime/compiler.rba **/*.rbc"
- end
+ paths = []
+
+ files.each do |name|
+ file = "#{name}.rb"
+ dir = File.dirname(file)
+ dest_dir = File.join("native", dir)
+ path = File.expand_path File.join("lib", file)
+ dest = File.join("native", file)
+ FileUtils.mkdir_p dest_dir
+ FileUtils.symlink path, dest rescue nil
+
+ paths << dest
end
+
+ paths += %w!native/bytecode/rubinius.rb native/bytecode/system_hints.rb!
+
+ update_archive paths, "runtime/compiler.rba", "native", true
end
-
- desc "Bootstrap and package the compiler"
- task :compiler => ['build:compiler:bootstrap', 'build:compiler:package']
-
+
desc "Builds shotgun, kernel, and bootstraps the compiler"
task :rubinius => ['build:shotgun', 'build:bootstrap', 'build:core', 'build:library', 'build:compiler']
View
@@ -53,6 +53,7 @@
$DEBUG_LOADING = true
puts "[Code loading debugging enabled]"
when '-c'
+ puts "Deprecated. Use 'rbx compile' instead."
file = ARGV.shift
path = compile(file)
puts "Compiled #{file} to #{path}"
@@ -110,7 +111,6 @@
unless ran_something
if Rubinius::Terminal
repr = ENV['RBX_REPR'] || "bin/sirb"
- puts "Loading #{repr} on #{Rubinius::Terminal}..."
require repr
else
Compile.execute "p #{STDIN.read}"
View
@@ -49,7 +49,11 @@ def initialize
@system_hints = nil
def self.load_system_hints(path)
- @system_hints = parse_hints(path)
+ if Hash === path
+ @system_hints = path
+ else
+ @system_hints = parse_hints(path)
+ end
end
def self.system_hints
@@ -1,9 +1,6 @@
require 'bytecode/assembler'
require 'bytecode/primitive_names'
-
-if File.exists?("kernel/hints")
- Bytecode::Compiler.load_system_hints "kernel/hints"
-end
+require 'bytecode/system_hints'
module Bytecode
class MethodDescription
@@ -0,0 +1,21 @@
+hsh = {
+ "MatchData"=>{:@source=>1, :@regexp=>2, :@full=>3, :@region=>4, :@__ivars__=>0},
+ "Regexp"=>{:@source=>1, :@names=>3, :@data=>2, :@__ivars__=>0},
+ "MethodTable"=>{:@entries=>4, :@default=>5, :@default_proc=>6, :@keys=>1, :@values=>2, :@__ivars__=>0, :@bins=>3},
+ "MetaClass"=>{:@methods=>1, :@method_cache=>2, :@constants=>4, :@parent=>5, :@superclass=>6, :@instance_fields=>7, :@attached_instance=>9, :@instance_flags=>8, :@name=>3, :@__ivars__=>0},
+ "Class"=>{:@methods=>1, :@method_cache=>2, :@constants=>4, :@parent=>5, :@superclass=>6, :@instance_fields=>7, :@instance_flags=>8, :@name=>3, :@__ivars__=>0},
+ "BlockContext"=>{:@raiseable=>5, :@env=>6, :@sender=>1, :@ip=>2, :@sp=>3, :@__ivars__=>0, :@block=>4},
+ "Object"=>{:@__ivars__=>0},
+ "Float"=>{:@__ivars__=>0},
+ "Array"=>{:@total=>0, :@tuple=>1},
+ "String"=>{:@bytes=>0, :@characters=>1, :@encoding=>2, :@data=>3},
+ "CompiledMethod"=>{:@file=>6, :@required=>2, :@bytecodes=>4, :@locals=>7, :@path=>13, :@serial=>3, :@arguments=>9, :@scope=>10, :@lines=>12, :@cache=>14, :@name=>5, :@literals=>8, :@exceptions=>11, :@__ivars__=>0, :@primitive=>1},
+ "SymbolTable"=>{:@symbols=>1, :@strings=>2, :@__ivars__=>0},
+ "IO"=>{:@descriptor=>0},
+ "Module"=>{:@methods=>1, :@method_cache=>2, :@constants=>4, :@parent=>5, :@name=>3, :@__ivars__=>0},
+ "MethodContext"=>{:@raiseable=>5, :@bytecodes=>7, :@locals=>10, :@argcount=>11, :@receiver=>9, :@method=>6, :@sender=>1, :@module=>13, :@ip=>2, :@name=>12, :@sp=>3, :@literals=>8, :@__ivars__=>0, :@block=>4},
+ "Hash"=>{:@entries=>4, :@default=>5, :@default_proc=>6, :@keys=>1, :@values=>2, :@__ivars__=>0, :@bins=>3},
+ "BlockEnvironment"=>{:@last_ip=>3, :@post_send=>4, :@home=>1, :@__ivars__=>0, :@initial_ip=>2}
+}
+
+Bytecode::Compiler.load_system_hints hsh
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit 3751f33

Please sign in to comment.