mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
2f524481c1
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1002 4e206d99-4929-0410-ac5d-dfc041789085
168 lines
5.0 KiB
Ruby
168 lines
5.0 KiB
Ruby
# Rake doc: http://rake.rubyforge.org/files/doc/rakefile_rdoc.html
|
|
require 'rake'
|
|
require 'net/ftp'
|
|
require 'net/http'
|
|
require 'uri'
|
|
include Rake
|
|
|
|
ENV["RUBYOPT"] = nil
|
|
EXTENSION = "RubySFML"
|
|
RUBY_VER = "ruby-1.8.6-p111"
|
|
GEMS_VER = "rubygems-0.9.4"
|
|
ROOT_DIR = Dir.pwd
|
|
RUBY_DIR = "#{ROOT_DIR}/#{RUBY_VER}"
|
|
GEMS_DIR = "#{ROOT_DIR}/#{GEMS_VER}"
|
|
EXTENSION_DIR = "#{ROOT_DIR}/#{EXTENSION}"
|
|
RUBY_URL = "ftp://ftp.ruby-lang.org/pub/ruby/1.8/#{RUBY_VER}.tar.gz"
|
|
|
|
# These are needed to build Ruby's zlib extension
|
|
raise "You forgot to run vcvars32.bat!" unless ENV['INCLUDE'] and ENV['LIB']
|
|
ENV['INCLUDE'] += ";#{ROOT_DIR}/../extlibs/headers;#{ROOT_DIR}/zlib"
|
|
ENV['LIB'] += ";#{ROOT_DIR}/../extlibs/libs-vc2005;#{ROOT_DIR}/zlib"
|
|
|
|
# Need this for the Unix utils, like gzip.exe and tar.exe, to run
|
|
ENV['PATH'] += ";#{ROOT_DIR}"
|
|
|
|
|
|
desc "Deletes all compiled and installed Ruby files for a clean rebuild"
|
|
task :cleanRuby do |t|
|
|
rm_r "bin" rescue nil
|
|
rm_r "lib" rescue nil
|
|
rm_r "man" rescue nil
|
|
rm_r RUBY_DIR rescue nil
|
|
rm_r GEMS_DIR rescue nil
|
|
rm "#{RUBY_VER}.tar" rescue nil
|
|
rm "#{RUBY_VER}.tar.gz" rescue nil
|
|
end
|
|
|
|
desc "Gets the Ruby source code from the FTP server"
|
|
task :getRuby do |t|
|
|
tar = "#{RUBY_VER}.tar"
|
|
tgz = "#{tar}.gz"
|
|
unless File.exists?(tar) or File.exists?(tgz)
|
|
puts "Downloading #{RUBY_URL}. Please wait..."
|
|
Net::FTP.open("ftp.ruby-lang.org") do |ftp|
|
|
ftp.login
|
|
files = ftp.chdir("pub/ruby/1.8")
|
|
ftp.getbinaryfile(tgz, tgz)
|
|
end
|
|
end
|
|
end
|
|
|
|
desc "Unpacks the Ruby source tarball"
|
|
task :unpackRuby => [:getRuby] do |t|
|
|
unless File.exists?(RUBY_DIR)
|
|
tar = "#{RUBY_VER}.tar"
|
|
tgz = "#{tar}.gz"
|
|
sh "gzip", "-d", tgz if File.exists?(tgz)
|
|
sh "tar", "-xvf", tar
|
|
end
|
|
|
|
unless File.exists?(GEMS_DIR)
|
|
sh "unzip", "#{GEMS_VER}.zip"
|
|
end
|
|
end
|
|
|
|
desc "Builds ruby.exe from the source code"
|
|
task :buildRuby => [:unpackRuby] do |t|
|
|
unless File.exists? "#{RUBY_DIR}/ruby.exe"
|
|
Dir.chdir RUBY_DIR
|
|
sh "win32\\configure.bat", "--target=i686-mswin32"
|
|
sh "nmake"
|
|
Dir.chdir ROOT_DIR
|
|
end
|
|
end
|
|
|
|
desc "Installs #{RUBY_VER} and copies the extlibs into the bin folder"
|
|
task :installRuby => [:buildRuby] do |t|
|
|
unless File.exists? "#{ROOT_DIR}/bin/ruby.exe"
|
|
Dir.chdir RUBY_DIR
|
|
sh "nmake", "DESTDIR=\"#{ROOT_DIR}\"", "install"
|
|
Dir.chdir ROOT_DIR
|
|
end
|
|
|
|
unless File.exists? "bin/zlib1.dll"
|
|
cp Dir["../extlibs/bin/*.dll"], "bin"
|
|
cp Dir["zlib/*.dll"], "bin"
|
|
cp "#{RUBY_DIR}/.ext/i386-mswin32_80/zlib.so", "lib/ruby/1.8/i386-mswin32"
|
|
end
|
|
|
|
unless File.exists? "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/rubygems.rb"
|
|
Dir.chdir GEMS_DIR
|
|
sh "../bin/ruby.exe", "setup.rb"
|
|
rm_r "#{ROOT_DIR}/lib/ruby/gems/1.8/doc/rubygems-0.9.4" rescue nil
|
|
Dir.chdir ROOT_DIR
|
|
end
|
|
end
|
|
|
|
desc "Deletes all compiled and installed RubySFML files for a clean rebuild"
|
|
task :cleanExtension do |t|
|
|
dirs = [EXTENSION_DIR, "#{ROOT_DIR}/RubyOpenGL/gl", "#{ROOT_DIR}/RubyOpenGL/glu"]
|
|
dirs.each {|d|
|
|
rm Dir["#{d}/*.so"]
|
|
rm Dir["#{d}/*.def"]
|
|
rm Dir["#{d}/*.pdb"]
|
|
rm Dir["#{d}/*.lib"]
|
|
rm Dir["#{d}/*.exp"]
|
|
rm Dir["#{d}/*.log"]
|
|
rm Dir["#{d}/*.obj"]
|
|
rm "#{d}/Makefile" rescue nil
|
|
}
|
|
rm "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80/RubySFML.so" rescue nil
|
|
rm "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80/gl.so" rescue nil
|
|
rm "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80/glu.so" rescue nil
|
|
end
|
|
|
|
desc "Builds the SFMLRuby extension"
|
|
task :buildExtension => [:installRuby] do |t|
|
|
unless File.exists? "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80/gl.so" and File.exists? "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80/glu.so"
|
|
Dir.chdir "#{ROOT_DIR}/RubyOpenGL/gl"
|
|
sh "../../bin/ruby.exe", "extconf.rb"
|
|
sh "nmake"
|
|
cp "gl.so", "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80"
|
|
Dir.chdir "#{ROOT_DIR}/RubyOpenGL/glu"
|
|
sh "../../bin/ruby.exe", "extconf.rb"
|
|
sh "nmake"
|
|
cp "glu.so", "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80"
|
|
Dir.chdir ROOT_DIR
|
|
end
|
|
|
|
inc = "../../include"
|
|
lib = "../../lib/vc2005"
|
|
ext = "#{EXTENSION_DIR}/RubySFML.so"
|
|
File.delete(ext) unless uptodate?(ext, Dir["../lib/vc2005/*.lib"]) rescue nil
|
|
|
|
Dir.chdir EXTENSION_DIR
|
|
sh "../bin/ruby.exe", "extconf-win.rb", "--with-SFML-include=#{inc}", "--with-SFML-lib=#{lib}"
|
|
sh "nmake"
|
|
cp "RubySFML.so", "#{ROOT_DIR}/lib/ruby/site_ruby/1.8/i386-msvcr80"
|
|
cp "RubySFML.rb", "#{ROOT_DIR}/lib/ruby/site_ruby/1.8"
|
|
Dir.chdir ROOT_DIR
|
|
end
|
|
|
|
desc "Builds everything and runs test.rb"
|
|
task :test => [:buildExtension] do |t|
|
|
Dir.chdir "#{ROOT_DIR}/test"
|
|
sh "../bin/ruby.exe", "test.rb"
|
|
Dir.chdir ROOT_DIR
|
|
end
|
|
|
|
desc "Zips up the compiled binaries for distribution"
|
|
task :package => [:buildExtension] do |t|
|
|
sh "zip", "-r", "RubySFML.zip", "LICENSE.txt", "bin", "doc", "lib", "test"
|
|
end
|
|
|
|
desc "Deletes all files generated by this build"
|
|
task :clean => [:cleanExtension, :cleanRuby] do |t|
|
|
rm "RubySFML.zip" rescue nil
|
|
end
|
|
|
|
desc "Deletes and rebuilds everything"
|
|
task :rebuild => [:clean, :package] do |t|
|
|
rm "RubySFML.zip" rescue nil
|
|
end
|
|
|
|
desc "(Same as 'rake package')"
|
|
task :default => [:package]
|
|
|