2007-08-24 11:26:28 -04:00
|
|
|
|
|
|
|
prelude, outfile = *ARGV
|
|
|
|
lines = []
|
|
|
|
|
2007-08-24 19:49:19 -04:00
|
|
|
lines = File.readlines(prelude).map{|line|
|
|
|
|
line.dump
|
2007-08-24 11:26:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
open(outfile, 'w'){|f|
|
|
|
|
f.puts <<EOS__
|
|
|
|
|
|
|
|
#include "ruby/ruby.h"
|
2007-08-24 19:49:19 -04:00
|
|
|
#include "vm_core.h"
|
|
|
|
|
2007-08-24 11:26:28 -04:00
|
|
|
static const char *prelude_code =
|
|
|
|
#{lines.join("\n")}
|
|
|
|
;
|
|
|
|
void
|
|
|
|
Init_prelude(void)
|
|
|
|
{
|
|
|
|
rb_iseq_eval(rb_iseq_compile(
|
|
|
|
rb_str_new2(prelude_code),
|
2007-08-24 19:49:19 -04:00
|
|
|
rb_str_new2("#{File.basename(prelude)}"), INT2FIX(1)));
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
printf("%s\n", prelude_code);
|
|
|
|
#endif
|
2007-08-24 11:26:28 -04:00
|
|
|
}
|
|
|
|
EOS__
|
|
|
|
}
|
|
|
|
|