Permalink
Browse files

remove the prelude crap

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4074 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 171f9c2 commit 58460dd16b3cdb124dd0c917987f8899735a1f33 @lrz lrz committed May 11, 2010
Showing with 7 additions and 154 deletions.
  1. +0 −35 prelude.rb
  2. +5 −24 rakelib/builder.rake
  3. +2 −3 rakelib/builder/builder.rb
  4. +0 −92 tool/compile_prelude.rb
View
35 prelude.rb
@@ -1,35 +0,0 @@
-
-# Mutex
-
-class Mutex
- def synchronize
- self.lock
- begin
- yield
- ensure
- self.unlock rescue nil
- end
- end
-end
-
-# Thread
-
-class Thread
- MUTEX_FOR_THREAD_EXCLUSIVE = Mutex.new
- def self.exclusive
- MUTEX_FOR_THREAD_EXCLUSIVE.synchronize{
- yield
- }
- end
-end
-
-def require_relative(relative_feature)
- c = caller.first
- e = c.rindex(/:\d+:in /)
- file = $`
- if /\A\((.*)\)/ =~ file # eval, etc.
- raise LoadError, "require_relative is called in #{$1}"
- end
- absolute_feature = File.expand_path(File.join(File.dirname(file), relative_feature))
- require absolute_feature
-end
View
29 rakelib/builder.rake
@@ -9,15 +9,6 @@ end
desc "Build known objects"
task :objects => [:config_h, :dtrace_h, :revision_h, :mark_gc] do
- sh "/usr/bin/ruby tool/compile_prelude.rb prelude.rb miniprelude.c.new"
- if !File.exist?('miniprelude.c') or File.read('miniprelude.c') != File.read('miniprelude.c.new')
- mv('miniprelude.c.new', 'miniprelude.c')
- else
- rm('miniprelude.c.new')
- end
- if !File.exist?('prelude.c')
- touch('prelude.c') # create empty file nevertheless
- end
if !File.exist?('parse.c') or File.mtime('parse.y') > File.mtime('parse.c')
sh("/usr/bin/bison -o y.tab.c parse.y")
sh("/usr/bin/sed -f ./tool/ytab.sed -e \"/^#/s!y\.tab\.c!parse.c!\" y.tab.c > parse.c.new")
@@ -38,15 +29,15 @@ task :objects => [:config_h, :dtrace_h, :revision_h, :mark_gc] do
$builder.build
if t == nil or File.mtime('dispatcher.o') > t
# dispatcher.o must be marked as GC compliant to avoid a linker problem.
- # We do not build it using -fobjc-gc because gcc generates unnecessary (and slow) write
- # barriers.
+ # We do not build it using -fobjc-gc because gcc generates unnecessary (and slow)
+ # write barriers.
sh "./markgc ./dispatcher.o"
end
end
desc "Create miniruby"
task :miniruby => :objects do
- $builder.link_executable('miniruby', OBJS - ['prelude'])
+ $builder.link_executable('miniruby', OBJS)
end
desc "Create config file"
@@ -58,18 +49,8 @@ end
namespace :macruby do
desc "Build dynamic libraries for MacRuby"
task :dylib => [:rbconfig, :miniruby] do
-=begin
- sh("./miniruby -I. -I./lib -rrbconfig tool/compile_prelude.rb prelude.rb gem_prelude.rb gcd_prelude prelude.c.new")
- if !File.exist?('prelude.c') or File.read('prelude.c') != File.read('prelude.c.new')
- mv('prelude.c.new', 'prelude.c')
- $builder.build(['prelude'])
- else
- rm('prelude.c.new')
- end
-=end
- cp('miniprelude.c', 'prelude.c')
dylib = "lib#{RUBY_SO_NAME}.#{NEW_RUBY_VERSION}.dylib"
- $builder.link_dylib(dylib, $builder.objs - ['main', 'gc-stub', 'miniprelude'])
+ $builder.link_dylib(dylib, $builder.objs - ['main', 'gc-stub'])
major, minor, teeny = NEW_RUBY_VERSION.scan(/\d+/)
["lib#{RUBY_SO_NAME}.#{major}.#{minor}.dylib", "lib#{RUBY_SO_NAME}.dylib"].each do |dylib_alias|
if !File.exist?(dylib_alias) or File.readlink(dylib_alias) != dylib
@@ -81,7 +62,7 @@ namespace :macruby do
desc "Build static libraries for MacRuby"
task :static => :dylib do
- $builder.link_archive("lib#{RUBY_SO_NAME}-static.a", $builder.objs - ['main', 'gc-stub', 'miniprelude'])
+ $builder.link_archive("lib#{RUBY_SO_NAME}-static.a", $builder.objs - ['main', 'gc-stub'])
end
desc "Build MacRuby"
View
5 rakelib/builder/builder.rb
@@ -5,9 +5,8 @@
gc hash env inits io math numeric object pack parse prec dir process
random range rational re ruby signal sprintf st string struct time
util variable version thread id objc bs ucnv encoding main dln dmyext marshal
- gcd vm_eval prelude miniprelude gc-stub bridgesupport compiler dispatcher vm
- symbol debugger MacRuby MacRubyDebuggerConnector NSArray NSDictionary
- NSString
+ gcd vm_eval gc-stub bridgesupport compiler dispatcher vm symbol debugger MacRuby
+ MacRubyDebuggerConnector NSArray NSDictionary NSString
}
EXTENSIONS = %w{
View
92 tool/compile_prelude.rb
@@ -1,92 +0,0 @@
-# This file is interpreted by $(BASERUBY) and miniruby.
-# $(BASERUBY) is used for miniprelude.c.
-# miniruby is used for prelude.c.
-# Since $(BASERUBY) may be older than Ruby 1.9,
-# Ruby 1.9 feature should not be used.
-
-$:.unshift(File.expand_path("../..", __FILE__))
-
-preludes = ARGV.dup
-outfile = preludes.pop
-init_name = outfile[/\w+(?=_prelude.c\b)/] || 'prelude'
-
-C_ESC = {
- "\\" => "\\\\",
- '"' => '\"',
- "\n" => '\n',
-}
-
-0x00.upto(0x1f) {|ch| C_ESC[[ch].pack("C")] ||= "\\%03o" % ch }
-0x7f.upto(0xff) {|ch| C_ESC[[ch].pack("C")] = "\\%03o" % ch }
-C_ESC_PAT = Regexp.union(*C_ESC.keys)
-
-def c_esc(str)
- '"' + str.gsub(C_ESC_PAT) { C_ESC[$&] } + '"'
-end
-
-mkconf = nil
-setup_ruby_prefix = nil
-teardown_ruby_prefix = nil
-lines_list = preludes.map {|filename|
- lines = []
- need_ruby_prefix = false
- File.readlines(filename).each {|line|
- line.gsub!(/RbConfig::CONFIG\["(\w+)"\]/) {
- key = $1
- unless mkconf
- require 'rbconfig'
- mkconf = RbConfig::MAKEFILE_CONFIG.merge('prefix'=>'#{TMP_RUBY_PREFIX}')
- setup_ruby_prefix = "TMP_RUBY_PREFIX = $:.reverse.find{|e|e!=\".\"}.sub(%r{(.*)/lib/.*}m, \"\\\\1\")\n"
- teardown_ruby_prefix = 'Object.class_eval { remove_const "TMP_RUBY_PREFIX" }'
- end
- if RbConfig::MAKEFILE_CONFIG.has_key? key
- val = RbConfig.expand("$(#{key})", mkconf)
- need_ruby_prefix = true if /\A\#\{TMP_RUBY_PREFIX\}/ =~ val
- c_esc(val)
- else
- "nil"
- end
- }
- lines << c_esc(line)
- }
- setup_lines = []
- if need_ruby_prefix
- setup_lines << c_esc(setup_ruby_prefix)
- lines << c_esc(teardown_ruby_prefix)
- end
- [setup_lines, lines]
-}
-
-require 'erb'
-
-tmp = ERB.new(<<'EOS', nil, '%').result(binding)
-#include "ruby/ruby.h"
-#include "ruby/node.h"
-#include "vm.h"
-
-% preludes.zip(lines_list).each_with_index {|(prelude, (setup_lines, lines)), i|
-static const char prelude_name<%=i%>[] = <%=c_esc(File.basename(prelude))%>;
-static const char prelude_code<%=i%>[] =
-% (setup_lines+lines).each {|line|
-<%=line%>
-% }
-;
-% }
-
-void
-Init_<%=init_name%>(void)
-{
-% lines_list.each_with_index {|(setup_lines, lines), i|
- rb_vm_run(prelude_name<%=i%>, rb_compile_string(
- prelude_name<%=i%>,
- rb_str_new(prelude_code<%=i%>, sizeof(prelude_code<%=i%>) - 1),
- 1), NULL, false);
-
-% }
-}
-EOS
-
-open(outfile, 'w'){|f|
- f << tmp
-}
-

0 comments on commit 58460dd

Please sign in to comment.