1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/compile_prelude.rb
ko1 6bf7d3d8c0 * prelude.rb: added. run this script on startup.
* tool/compile_prelude.rb: compile prelude.rb to C string.
  (prelude.rb -> prelude.c)
* common.mk: fix to build with prelude.c.
* inits.c (rb_call_inits): ditto.
* thread.c (Init_Thread): move definition of Mutex#synchronize
  to prelude.rb.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 15:26:28 +00:00

25 lines
367 B
Ruby

prelude, outfile = *ARGV
lines = []
File.readlines(prelude).each{|line|
lines << "#{line.dump}"
}
open(outfile, 'w'){|f|
f.puts <<EOS__
#include "ruby/ruby.h"
static const char *prelude_code =
#{lines.join("\n")}
;
void
Init_prelude(void)
{
rb_iseq_eval(rb_iseq_compile(
rb_str_new2(prelude_code),
rb_str_new2("prelude.rb"), INT2FIX(1)));
}
EOS__
}