Skip to content

Instantly share code, notes, and snippets.

@yhara
Created Oct 6, 2009
Embed
What would you like to do?
# configurations
BIN_DIR = File.expand_path("~/bin/")
INSTALL_DIR = File.expand_path("~/bin/rubys/")
P185 = "p231"
P186 = "p369"
P187 = "p174"
P191 = "p243"
P192 = "preview1"
JRUBY_VER = "1.3.0"
TOP_DIR = File.dirname(__FILE__)
def cd(dir=TOP_DIR)
Dir.chdir(File.expand_path(dir, TOP_DIR))
end
def make_install(name, dir=nil)
cd(dir || name)
sh "./configure " +
"--prefix='#{INSTALL_DIR}/#{name}' " +
"--program-suffix='#{name.sub(/ruby/, '')}' "+
"--disable-install-doc "
sh "make"
sh "make install"
end
def symlink(name)
cd BIN_DIR
# sh "ln -s " +
# "'#{INSTALL_DIR}/#{name}/bin/#{name}' " +
# "'#{BIN_DIR}/#{name.sub(/-p\d+$/, '')}' "
sh "ln -s " +
"'#{INSTALL_DIR}/#{name}/bin/#{name}' " +
"'#{BIN_DIR}/#{name}' "
end
task :cruby => [:ruby186, :ruby187, :ruby191]
desc "install ruby-1.8.5 #{P185}"
task :ruby185 => ["#{BIN_DIR}/ruby-1.8.5-#{P185}"]
desc "install ruby-1.8.6 #{P186}"
task :ruby186 => ["#{BIN_DIR}/ruby-1.8.6-#{P186}"]
desc "install ruby-1.8.7 #{P187}"
task :ruby187 => ["#{BIN_DIR}/ruby-1.8.7-#{P187}"]
desc "install ruby-1.9.1 #{P191}"
task :ruby191 => ["#{BIN_DIR}/ruby-1.9.1-#{P191}"]
desc "install ruby-1.9.2 #{P192}"
task :ruby192 => ["#{BIN_DIR}/ruby-1.9.2-#{P192}"]
# install
rule /\// => [lambda{|s| File.basename(s)}] do |t|
make_install t.source
symlink t.source
end
# unpack
rule /ruby-.*-p([^.]*)$/ => [lambda{|s| "#{s}.tar.bz2"}] do |t|
cd
sh "tar xvf #{t.source}"
end
# download
rule ".bz2" do |t|
sh "wget ftp://core.ring.gr.jp/pub/lang/ruby/#{t.name}"
end
# Ruby trunk ----------------------------------------------------------------------
desc "install ruby trunk"
task :rubytrunk => ["#{BIN_DIR}/#{ENV['AS'] || 'ruby-trunk'}"] do
unless File.exist?("ruby-trunk")
cd
sh "git clone --depth 1 git://github.com/shyouhei/ruby.git ruby-trunk"
end
cd "ruby-trunk"
sh "git pull"
sh "make distclean" if File.exist?("Makefile")
sh "autoconf"
name = ENV["AS"] || "ruby-trunk"
make_install(name, "ruby-trunk")
symlink(name)
end
# Rubinius ----------------------------------------------------------------------
desc "install rubinius"
task :rubinius => "#{BIN_DIR}/rubinius"
file "#{BIN_DIR}/rubinius" => "rubinius-git" do
cd "rubinius-git"
sh "git pull"
sh "rake"
sh "ln -s #{TOP_DIR}/bin/rbx #{BIN_DIR}/rubinius"
end
file "rubinius-git" do
cd
sh "git clone --depth 1 git://github.com/evanphx/rubinius.git rubinius-git"
end
# MacRuby ----------------------------------------------------------------------
#
#desc "install macruby"
#task :macruby => "#{BIN_DIR}/macruby"
#
#file "#{BIN_DIR}/macruby" => "macruby-git" do
# cd "macruby-git"
# sh "git pull"
# sh "RUBYOPT='' DESTDIR='#{INSTALL_DIR}/macruby' rake"
# sh "RUBYOPT='' DESTDIR='#{INSTALL_DIR}/macruby' rake install"
# #sh "ln -s #{TOP_DIR}/bin/rbx #{BIN_DIR}/macruby"
#end
#
#file "macruby-git" do
# cd
# sh "git clone --depth 1 git://github.com/masterkain/macruby.git macruby-git"
#end
# JRuby ----------------------------------------------------------------------
desc "install jruby"
task :jruby => "#{BIN_DIR}/jruby"
file "#{BIN_DIR}/jruby" => "jruby-#{JRUBY_VER}" do
sh "ln -s #{TOP_DIR}/jruby-#{JRUBY_VER}/bin/jruby #{BIN_DIR}/jruby"
end
file "jruby-#{JRUBY_VER}" do
cd
sh "wget http://dist.codehaus.org/jruby/#{JRUBY_VER}/jruby-bin-#{JRUBY_VER}.tar.gz"
sh "tar xvf jruby-bin-#{JRUBY_VER}.tar.gz"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment