From 6dfca4d3511700b0659b867496beca1b4f8fb383 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 10 Nov 2007 09:22:59 +0000 Subject: * gem_prelude.rb: new file for gem libraries. currently empty. * common.mk: generate ext_prelude.c by prelude.rb and gem_prelude.rb. ruby (not miniruby) is linked with ext_prelude.o instead of prelude.o. * inits.c (rb_call_inits): don't call Init_prelude. * ruby.c: support --disable-gems option. (ruby_init_gems): new function to define Gem::Enable and invoke Init_prelude. (process_options): call ruby_init_gems just after ruby_init_loadpath. * tool/compile_prelude.rb: support multiple files. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 6dc411eaa..428524700 100644 --- a/ruby.c +++ b/ruby.c @@ -75,6 +75,7 @@ struct cmdline_options { int usage; int version; int copyright; + int disable_gems; int verbose; int yydebug; char *script; @@ -121,6 +122,7 @@ usage(const char *name) "-w turn warnings on for your script", "-W[level] set warning level; 0=silence, 1=medium, 2=verbose (default)", "-x[directory] strip off text before #!ruby line and perhaps cd to directory", + "--disable_gems disable gem libraries", "--copyright print the copyright", "--version print the version", NULL @@ -813,6 +815,8 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) ruby_debug = Qtrue; ruby_verbose = Qtrue; } + else if (strcmp("disable-gems", s) == 0) + opt->disable_gems = 1; else if (strcmp("encoding", s) == 0) { if (!--argc || !(s = *++argv)) { noencoding: @@ -873,6 +877,17 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) return argc0 - argc; } +void Init_prelude(void); + +static void +ruby_init_gems(struct cmdline_options *opt) +{ + VALUE gem; + gem = rb_define_module("Gem"); + rb_const_set(gem, rb_intern("Enable"), opt->disable_gems ? Qfalse : Qtrue); + Init_prelude(); +} + static VALUE process_options(VALUE arg) { @@ -976,6 +991,7 @@ process_options(VALUE arg) process_sflag(opt); ruby_init_loadpath(); + ruby_init_gems(opt); parser = rb_parser_new(); if (opt->e_script) { if (opt->enc_index >= 0) -- cgit