require 'ftools' require 'rake/gempackagetask' GOSU_VERSION = ENV['GOSU_RELEASE_VERSION'] throw "GOSU_RELEASE_VERSION must be set" if GOSU_VERSION.nil? COMMON_FILES = FileList[ 'COPYING.txt', 'README.txt', ] COMMON_CPP_FILES = COMMON_FILES + FileList[ 'examples/*.cpp', 'examples/media/*', 'reference/**/*', ] COMMON_RUBY_FILES = COMMON_FILES + FileList[ 'examples/*.rb', 'examples/media/*', ] SOURCE_FILES = COMMON_CPP_FILES + COMMON_RUBY_FILES + FileList[ 'Rakefile', 'Gosu/**/*', 'GosuImpl/**/*', 'linux/configure', 'linux/configure.ac', 'linux/Makefile.in', 'mac/Gosu.xcodeproj/**/*', 'mac/*.a', 'mac/English.lproj/**/*', 'mac/Gosu-Info.plist', 'mac/RubyGosu Template-Info.plist', 'windows/**/*', ] # Sets everything except 'platform' and 'files'. def apply_gemspec_defaults s #### Basic information. s.name = 'gosu' s.version = GOSU_VERSION s.summary = '2D game development library.' s.description = <= 1.8.2') s.summary = '2D game development library.' end desc "Build C++ reference with doxygen" task :cpp_docs do sh "cd reference && doxygen" end Rake.application.in_namespace :mac do desc "Build Gosu.framework" task :cpp => :cpp_docs do sh "cd mac && xcodebuild -project Gosu.xcodeproj -target Gosu -configuration Release" end desc "Build lib/gosu.bundle and RubyGosu Deployment Template.app" task :ruby do sh "cd mac && xcodebuild -project Gosu.xcodeproj -target 'RubyGosu Core' -configuration Release" sh "cd mac && xcodebuild -project Gosu.xcodeproj -target 'RubyGosu Deployment Template' -configuration Release" end MAC_ARCHIVE_FILENAME = "public/gosu-mac-#{GOSU_VERSION}.tar.gz" desc "Build the archive #{MAC_ARCHIVE_FILENAME}" task :archive => [:cpp, :ruby] do files = COMMON_CPP_FILES + COMMON_RUBY_FILES + ['lib/gosu.bundle'] + FileList['Gosu.framework/**/*', 'RubyGosu Deployment Template.app/**/*'] sh "tar -czf #{MAC_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}" end desc "Releases the archive #{MAC_ARCHIVE_FILENAME} on GoogleCode" task :release => :archive do sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION} precompiled for Mac OS X (C++ & Ruby)\"" + " --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-OSX\" #{MAC_ARCHIVE_FILENAME}" end task :gem => :ruby MAC_SPEC = Gem::Specification.new do |s| apply_gemspec_defaults s s.platform = 'universal-darwin' s.files = COMMON_RUBY_FILES + ['lib/gosu.bundle'] end Rake::GemPackageTask.new(MAC_SPEC) { |t| t.package_dir = 'public/mac_gem' } end Rake.application.in_namespace :win do WINDOWS_CPP_ARCHIVE_FILENAME = "public/gosu-windows-cpp-#{GOSU_VERSION}.zip" desc "Build the archive #{WINDOWS_CPP_ARCHIVE_FILENAME}" task :cpp_archive do #=> [:cpp] do files = COMMON_CPP_FILES + ['lib/Gosu.lib', 'lib/GosuDebug.lib', 'lib/fmod.dll'] sh "zip #{WINDOWS_CPP_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}" end desc "Releases the archive #{WINDOWS_CPP_ARCHIVE_FILENAME} on GoogleCode" task :cpp_release => :cpp_archive do sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION} precompiled for 32-bit Windows (C++)\"" + " --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-Windows\" #{WINDOWS_CPP_ARCHIVE_FILENAME}" end WINDOWS_RUBY_ARCHIVE_FILENAME = "public/gosu-windows-ruby-#{GOSU_VERSION}.zip" desc "Build the archive #{WINDOWS_RUBY_ARCHIVE_FILENAME}" task :ruby_archive do #=> [:ruby] do files = COMMON_RUBY_FILES + ['lib/gosu.so', 'lib/fmod.dll'] sh "zip #{WINDOWS_RUBY_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}" end desc "Releases the archive #{WINDOWS_RUBY_ARCHIVE_FILENAME} on GoogleCode" task :ruby_release => :ruby_archive do sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION} precompiled for 32-bit Windows (Ruby)\"" + " --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-Windows\" #{WINDOWS_RUBY_ARCHIVE_FILENAME}" end desc "Release both #{WINDOWS_CPP_ARCHIVE_FILENAME} and #{WINDOWS_RUBY_ARCHIVE_FILENAME}" task :release => [:cpp_release, :ruby_release] WINDOWS_SPEC = Gem::Specification.new do |s| apply_gemspec_defaults s s.platform = 'x86-mswin32-60' s.files = COMMON_RUBY_FILES + ['lib/gosu.so', 'lib/fmod.dll'] end Rake::GemPackageTask.new(WINDOWS_SPEC) { |t| t.package_dir = 'public/windows_gem' } end Rake.application.in_namespace :linux do LINUX_ARCHIVE_FILENAME = "public/gosu-source-#{GOSU_VERSION}.tar.gz" desc "Build the archive #{LINUX_ARCHIVE_FILENAME}" task :archive => [:build, :cpp_reference] do files = SOURCE_FILES sh "tar -czf #{LINUX_ARCHIVE_FILENAME} #{files.map { |filename| "'#{filename}'" }.join(' ')}" end desc "Releases the archive #{LINUX_ARCHIVE_FILENAME} on GoogleCode" task :release => :archive do sh "./googlecode_upload.py --summary=\"Gosu #{GOSU_VERSION} source package (to compile on Linux)\"" + " --project=gosu --user=julianraschke --labels=\"Featured,Type-Archive,OpSys-All\" #{LINUX_ARCHIVE_FILENAME}" end LINUX_SPEC = Gem::Specification.new do |s| apply_gemspec_defaults s s.platform = 'ruby' s.files = COMMON_RUBY_FILES + ['linux/configure.ac', 'linux/Makefile.in', 'linux/extconf.rb', "Ruby Source TODO"] s.extensions = [ 'linux/extconf.rb' ] s.require_path = 'lib' s.requirements = ['g++', 'pkg-config', 'libgl', 'X11 includes and libraries', 'pangoft2', 'fmod or SDL_mixer', "(Packages for Debian/Ubuntu:\n" + ' g++ pkg-config ruby-dev xorg-dev' + ' libsdl-mixer1.2-dev libgl1-mesa-dev libglu1-mesa-dev' + ' libpango1.0-dev' + "\n)"] end Rake::GemPackageTask.new(LINUX_SPEC) { |t| t.package_dir = 'public/linux_gem' } end # TODO? Gem upload to RubyForge: http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe