summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/runruby.rb
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-07 07:36:34 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-07 07:36:34 +0000
commit441546edcfbb1b346c87b69c5f578d1a0e522e06 (patch)
tree04f606a008baebc445f38944ad37e87468da29ea /ruby_1_8_6/runruby.rb
parentfa93611c0f9a6db146341c792bfe3b7322ec00e2 (diff)
add tag v1_8_6_269
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_269@17937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/runruby.rb')
-rwxr-xr-xruby_1_8_6/runruby.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/ruby_1_8_6/runruby.rb b/ruby_1_8_6/runruby.rb
new file mode 100755
index 0000000000..f442d90a9c
--- /dev/null
+++ b/ruby_1_8_6/runruby.rb
@@ -0,0 +1,61 @@
+#!./miniruby
+
+while arg = ARGV[0]
+ break ARGV.shift if arg == '--'
+ /\A--([-\w]+)(?:=(.*))?\z/ =~ arg or break
+ arg, value = $1, $2
+ re = Regexp.new('\A'+arg.gsub(/\w+\b/, '\&\\w*')+'\z', "i")
+ case
+ when re =~ "srcdir"
+ srcdir = value
+ when re =~ "archdir"
+ archdir = value
+ when re =~ "extout"
+ extout = value
+ else
+ break
+ end
+ ARGV.shift
+end
+
+srcdir ||= File.dirname(__FILE__)
+archdir ||= '.'
+
+abs_archdir = File.expand_path(archdir)
+$:.unshift(abs_archdir)
+
+require 'rbconfig'
+config = Config::CONFIG
+
+ruby = File.join(archdir, config["RUBY_INSTALL_NAME"]+config['EXEEXT'])
+unless File.exist?(ruby)
+ abort "#{ruby} is not found.\nTry `make' first, then `make test', please.\n"
+end
+
+libs = [abs_archdir]
+if extout
+ abs_extout = File.expand_path(extout)
+ libs << File.expand_path("common", abs_extout) << File.expand_path(RUBY_PLATFORM, abs_extout)
+end
+libs << File.expand_path("lib", srcdir)
+config["bindir"] = abs_archdir
+ENV["RUBY"] = File.expand_path(ruby)
+ENV["PATH"] = [abs_archdir, ENV["PATH"]].compact.join(File::PATH_SEPARATOR)
+
+ libs << File.expand_path("ext", srcdir) << "-"
+ENV["RUBYLIB"] = $:.replace(libs).join(File::PATH_SEPARATOR)
+
+libruby_so = File.join(abs_archdir, config['LIBRUBY_SO'])
+if File.file?(libruby_so)
+ if e = config['LIBPATHENV'] and !e.empty?
+ ENV[e] = [abs_archdir, ENV[e]].compact.join(File::PATH_SEPARATOR)
+ end
+ if /linux/ =~ RUBY_PLATFORM
+ ENV["LD_PRELOAD"] = [libruby_so, ENV["LD_PRELOAD"]].compact.join(' ')
+ end
+end
+
+cmd = [ruby]
+cmd << "-rpurelib.rb"
+cmd.concat(ARGV)
+exec(*cmd)