Temporary tag for this failure. Updated CI spec coming.
[rbx.git] / shotgun / rubinius
blob5166fb12b24b9761d78bc6f7f750bc1b6defa201
1 #!/usr/bin/env ruby
3 PR = %r!(.*?)[/]?shotgun/rubinius!
5 m = PR.match($0)
7 if m
8 # Good to go.
9 elsif File.symlink?($0)
10 path = File.readlink($0)
11 m = PR.match(path)
12 end
14 my_name = File.basename($0)
16 prefix = m[1]
17 prefix = "" if prefix == "./"
19 unless prefix[0] == ?/
20 prefix = File.expand_path File.join(Dir.getwd, prefix)
21 end
23 real = File.join(prefix, 'shotgun/rubinius.local.bin')
25 # Setup all the crazy library path stuff so that librubinus is picked
26 # up properly.
28 @prefix = prefix
30 def set_env(name)
31 addition = "#{@prefix}/shotgun/lib"
33 if cur = ENV[name]
34 ENV[name] = "#{addition}:#{cur}"
35 else
36 ENV[name] = addition
37 end
38 end
40 set_env 'LD_LIBRARY_PATH'
41 set_env 'LD_LIBRARY_PATH_64'
42 set_env 'SHLIB'
43 set_env 'LIBPATH'
44 set_env 'PATH'
45 set_env 'DYLD_LIBRARY_PATH'
46 set_env 'DYLD_FALLBACK_LIBRARY_PATH'
48 ENV['RBX_IN_BUILDDIR'] = "1"
50 ENV['RBX_PREFIX'] = "#{prefix}/"
52 unless ENV['RBX_BOOTSTRAP']
53 ENV['RBX_BOOTSTRAP'] = "#{prefix}/runtime/bootstrap"
54 end
56 unless ENV['RBX_CORE']
57 ENV['RBX_CORE'] = "#{prefix}/runtime/core"
58 end
60 unless ENV['RBX_PLATFORM']
61 ENV['RBX_PLATFORM'] = "#{prefix}/runtime/platform"
62 end
64 unless ENV['RBX_LOADER']
65 ENV['RBX_LOADER'] = "#{prefix}/runtime/loader.rbc"
66 end
68 unless ENV['RBX_PLATFORM_CONF']
69 ENV['RBX_PLATFORM_CONF'] = "#{prefix}/runtime/platform.conf"
70 end
72 ENV['RUBYLIB'] = %w(lib stdlib).map { |dir| File.join(prefix, dir) }.join(":")
74 if ARGV[0] == "--gdb"
75 ARGV.shift
77 ENV['PATH'] = "#{prefix}/shotgun:#{ENV['PATH']}"
78 args = ['-x', "#{prefix}/shotgun/gdbcommands"]
79 if `uname -s` == "Darwin" and `uname -r`.split(".")[0].to_i < 9
80 args << '-x' << "#{prefix}/shotgun/gdbenvironment"
81 end
82 args << '--args' << "/dev/null"
84 exec "gdb", *(args + ARGV)
85 elsif ARGV[0] == "--valgrind"
86 ARGV.shift
87 args = ['-v', real]
88 exec 'valgrind', *(args + ARGV)
89 elsif ARGV[0] == "--shark"
90 ARGV.shift
91 puts "Starting up rubinius, then pausing for shark to start"
92 pid = fork { sleep 5; exec real, *ARGV }
93 exec "shark -o rbxshark -i -1 -a #{pid}"
94 elsif ARGV[0] == "--dtrace"
95 ARGV.shift
96 puts "Starting up rubinius, then pausing for dtrace to start"
97 pid = fork { sleep 5; exec real, *ARGV }
98 exec "dtrace -s #{ENV['SCRIPT']} -p #{pid}"
99 else
100 exec [real, my_name], *ARGV