Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 72 lines (62 sloc) 1.84 kB
511dc44 initial import
Laurent Sansonetti authored
1 #!./miniruby
2
3 pure = true
4 while arg = ARGV[0]
5 break ARGV.shift if arg == '--'
6 /\A--([-\w]+)(?:=(.*))?\z/ =~ arg or break
7 arg, value = $1, $2
8 re = Regexp.new('\A'+arg.gsub(/\w+\b/, '\&\\w*')+'\z', "i")
9 case
10 when re =~ "srcdir"
11 srcdir = value
12 when re =~ "archdir"
13 archdir = value
14 when re =~ "extout"
15 extout = value
16 when re =~ "pure"
17 pure = (value != "no")
18 when re =~ "debugger"
19 debugger = value ? (value.split unless value == "no") : %w"gdb --args"
20 else
21 break
22 end
23 ARGV.shift
24 end
25
26 srcdir ||= File.dirname(__FILE__)
27 archdir ||= '.'
28
29 abs_archdir = File.expand_path(archdir)
30 $:.unshift(abs_archdir)
31
32 require 'rbconfig'
33 config = RbConfig::CONFIG
34
35 ruby = File.join(archdir, config["RUBY_INSTALL_NAME"]+config['EXEEXT'])
36 unless File.exist?(ruby)
37 abort "#{ruby} is not found.\nTry `make' first, then `make test', please.\n"
38 end
39
40 libs = [abs_archdir]
41 if extout
42 abs_extout = File.expand_path(extout)
43 libs << File.expand_path("common", abs_extout) << File.expand_path(RUBY_PLATFORM, abs_extout)
44 end
45 libs << File.expand_path("lib", srcdir)
46 config["bindir"] = abs_archdir
47 ENV["RUBY"] = File.expand_path(ruby)
48 ENV["PATH"] = [abs_archdir, ENV["PATH"]].compact.join(File::PATH_SEPARATOR)
49
50 if pure
51 libs << File.expand_path("ext", srcdir) << "-"
52 elsif e = ENV["RUBYLIB"]
53 libs |= e.split(File::PATH_SEPARATOR)
54 end
55 ENV["RUBYLIB"] = $:.replace(libs).join(File::PATH_SEPARATOR)
56
57 libruby_so = File.join(abs_archdir, config['LIBRUBY_SO'])
58 if File.file?(libruby_so)
59 if e = config['LIBPATHENV'] and !e.empty?
60 ENV[e] = [abs_archdir, ENV[e]].compact.join(File::PATH_SEPARATOR)
61 end
62 if /linux/ =~ RUBY_PLATFORM
63 ENV["LD_PRELOAD"] = [libruby_so, ENV["LD_PRELOAD"]].compact.join(' ')
64 end
65 end
66
67 cmd = [ruby]
68 cmd << "-rpurelib.rb" if pure
69 cmd.concat(ARGV)
70 cmd.unshift(*debugger) if debugger
71 exec(*cmd)
Something went wrong with that request. Please try again.