require 'rake/testtask' require 'rake/rdoctask' require 'rake/contrib/sshpublisher' require 'platform' task :default => :build_all ########################### # Project Managment tasks # ########################### Rake::RDocTask.new do |t| t.main = "README" t.rdoc_files.include("README", "doc_src/**/*.rb") # Exclude for now, not going to delete. We may come back to this. t.rdoc_files.exclude("doc_src/application.rb", "doc_src/application_frame_listener.rb") t.rdoc_files.include("samples/application.rb", "samples/application_frame_listener.rb") end RUBYFORGE_USERNAME = "jameskilton" PROJECT_WEB_PATH = "/var/www/gforge-projects/ogrerb" desc "Update the website" task :upload_web => :rdoc do |t| unless File.directory?("publish") mkdir "publish" mkdir "publish/docs" end sh "svn export --force website publish/" sh "cp -r html/* publish/docs/" Rake::SshDirPublisher.new("#{RUBYFORGE_USERNAME}@rubyforge.org", PROJECT_WEB_PATH, "publish").upload rm_rf "publish" end ############################# # Project compilation tasks # ############################# desc "Rebuild the OGRE and OIS wrappers" task :build_all => ["ogre:build", "ois:build"] desc "Clean everything" task :clean_all => ["ogre:clean", "ois:clean"] namespace :ois do desc "Rebuild all of the OIS wrapper" task :build => [:swig, :compile] desc "Run swig on the interface files" task :swig do includes = %w(-I./src_headers/OIS -I./src_headers/wrappers) sh "swig -ruby -minherit -c++ -autorename #{includes.join(' ')} -o build/ois/ois_wrap.cpp ois/ois.i" if Platform.windows? insert_headers("build/ois/ois_wrap.cpp") do <<-EOF #include "OIS.h" EOF end end end desc "Compile the extension and move the resulting library into lib/" task :compile do resulting_file = "ruby_ois.so" build_file = resulting_file cd "build/ois" do ruby "extconf.rb" if Platform.linux? sh "make all" elsif Platform.windows? sh "nmake" # Create our manifest (see http://www.codeproject.com/cpp/vcredists_x86.asp) sh "mt.exe /manifest #{resulting_file}.manifest /outputresource:#{resulting_file};#2" resulting_file = "ruby_ois.dll" build_file = "ruby_ois.so" else raise "Error: Unsupported platform " + PLATFORM end cp build_file, File.join("..", "..", "lib", resulting_file) end end desc "Clean up the build environment" task :clean do cd "build/ois" do ruby "extconf.rb" sh "make clean" rm "mkmf.log" rescue nil end end end namespace :ogre do desc "Rebuild all of ogre.rb" task :build => [:swig, :compile] desc "Run swig on the interface files" task :swig do includes = %w(-I./src_headers/OGRE -I./src_headers/ExampleApplication -I./src_headers/wrappers -I./src_headers/OIS) sh "swig -ruby -minherit -c++ -autorename #{includes.join(' ')} -o build/ogre/ogre_rb_wrap.cpp ogre/ogre_rb.i" if Platform.windows? # compensate for windows stl. Uses wrong version when ruby is first. insert_headers("build/ogre/ogre_rb_wrap.cpp") do <<-EOF #include "Ogre.h" #{Platform.windows? ? "#include " : ""} EOF end end end desc "Compile the extension and move the resulting library into lib/" task :compile do resulting_file = "ogre.so" cd "build/ogre" do ruby "extconf.rb" if Platform.linux? sh "make clean all" elsif Platform.windows? sh "nmake" # Create our manifest (see http://www.codeproject.com/cpp/vcredists_x86.asp) sh "mt.exe /manifest ogre.so.manifest /outputresource:ogre.so;#2" resulting_file = "ogre.dll" else raise "Error: Unsupported platform " + PLATFORM end cp "ogre.so", File.join("..", "..", "lib", resulting_file) end end desc "Clean up the build environment" task :clean do cd "build/ogre" do ruby "extconf.rb" sh "make clean" rm "mkmf.log" rescue nil end end desc "Copy over the ogre header files from an ogre installation. Expects OGRE_HOME to be set." task :update_headers do raise "Unable to find Ogre headers, please set OGRE_HOME to the distribution path" if ENV['OGRE_HOME'].nil? File.cp_r "#{ENV['OGRE_HOME']}/include/OGRE/", "#{File.dirname(__FILE__)}/src_headers" end desc "Create default interface files for each of the ogre headers" task :create_interfaces do headers_match = File.join("src_headers", "OGRE", "Ogre*.h") ogre_headers = Dir[headers_match] ogre_headers.each do |header| filename = File.basename(header, ".h") interface_file_name = File.join("ogre", File.basename(header, ".h") + ".i") raise "Interface file for #{filename} already exists" if File.exists?(interface_file_name) File.open(interface_file_name, "w+") do |file| file.write < [:swig, :compile] desc "Run swig on the interface files" task :swig do includes = %w(-I./src_headers/navi -I./src_headers/wrappers) sh "swig -autorename -ruby -minherit -c++ #{includes.join(' ')} -o build/navi/navi_rb_wrap.cpp navi/navi_rb.i" if Platform.windows? # compensate for windows stl. Uses wrong version when ruby is first. insert_headers("build/navi/navi_rb_wrap.cpp") do <<-EOF #include "Ogre.h" #{Platform.windows? ? "#include " : ""} EOF end end end desc "Compile the extension and move the resulting library into lib/" task :compile do resulting_file = "navi.dll" cd "build/navi" do ruby "extconf.rb" if Platform.windows? sh "nmake" # Create our manifest (see http://www.codeproject.com/cpp/vcredists_x86.asp) sh "mt.exe /manifest navi.so.manifest /outputresource:navi.so;#2" else raise "Error: Unsupported platform " + PLATFORM end cp "navi.so", File.join("..", "..", "lib", resulting_file) end end desc "Clean up the build environment" task :clean do cd "build" do ruby "extconf.rb" sh "make clean" rm "mkmf.log" rescue nil end end end