mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@13865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
66c127bc6f
commit
040ffb5d79
7 changed files with 103 additions and 14 deletions
16
ruby.c
16
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue