summaryrefslogtreecommitdiff
path: root/tool/compile_prelude.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-24 15:26:28 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-08-24 15:26:28 +0000
commit6bf7d3d8c08dbd96ec485bb856cb739139e720bc (patch)
tree25b681e65b65ea04b8748ba31cb8afb6e2f56d32 /tool/compile_prelude.rb
parentb285d26a16c90f8e2d491592e793c3b40545aaf1 (diff)
* 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
Diffstat (limited to 'tool/compile_prelude.rb')
-rw-r--r--tool/compile_prelude.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/tool/compile_prelude.rb b/tool/compile_prelude.rb
new file mode 100644
index 0000000..13ccb8a
--- /dev/null
+++ b/tool/compile_prelude.rb
@@ -0,0 +1,25 @@
+
+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__
+}
+