Rakefile in ffi-1.1.6.pre2 vs Rakefile in ffi-1.2.0.dev

- old
+ new

@@ -1,6 +1,7 @@ require 'rubygems' +require 'rubygems/package_task' require 'rbconfig' USE_RAKE_COMPILER = (RUBY_PLATFORM =~ /java/) ? false : true if USE_RAKE_COMPILER gem 'rake-compiler', '>=0.6.0' @@ -9,11 +10,10 @@ require 'date' require 'fileutils' require 'rbconfig' -load 'tasks/setup.rb' LIBEXT = case RbConfig::CONFIG['host_os'].downcase when /darwin/ "dylib" when /mswin|mingw/ @@ -62,60 +62,26 @@ "win32" else RbConfig::CONFIG['host_os'].downcase end -CC=ENV['CC'] || RbConfig::CONFIG['CC'] || "gcc" +CC = ENV['CC'] || RbConfig::CONFIG['CC'] || "gcc" GMAKE = system('which gmake >/dev/null') && 'gmake' || 'make' LIBTEST = "build/libtest.#{LIBEXT}" BUILD_DIR = "build" BUILD_EXT_DIR = File.join(BUILD_DIR, "#{RbConfig::CONFIG['arch']}", 'ffi_c', RUBY_VERSION) -# Project general information -PROJ.name = 'ffi' -PROJ.authors = 'Wayne Meissner' -PROJ.email = 'wmeissner@gmail.com' -PROJ.url = 'http://wiki.github.com/ffi/ffi' -PROJ.version = '1.1.6.pre2' -PROJ.rubyforge.name = 'ffi' -PROJ.readme_file = 'README.rdoc' +gem_spec = eval(IO.read('ffi.gemspec')) -# Annoucement -PROJ.ann.paragraphs << 'FEATURES' << 'SYNOPSIS' << 'REQUIREMENTS' << 'DOWNLOAD/INSTALL' << 'CREDITS' << 'LICENSE' +Gem::PackageTask.new(gem_spec) do |pkg| + pkg.need_zip = true + pkg.need_tar = true + pkg.package_dir = 'pkg' +end -PROJ.ann.email[:from] = 'andrea.fazzi@alcacoop.it' -PROJ.ann.email[:to] = ['ruby-ffi@googlegroups.com'] -PROJ.ann.email[:server] = 'smtp.gmail.com' - -# Gem specifications -PROJ.gem.need_tar = false -PROJ.gem.files = %w(History.txt LICENSE README.rdoc Rakefile) + Dir.glob("{ext,gen,lib,spec,tasks}/**/*") -PROJ.gem.platform = Gem::Platform::RUBY -#PROJ.gem.required_ruby_version = ">= 1.9.2" - -# Override Mr. Bones autogenerated extensions and force ours in -PROJ.gem.extras['extensions'] = %w(ext/ffi_c/extconf.rb) -#PROJ.gem.extras['required_ruby_version'] = ">= 1.9.2" - -# RDoc -PROJ.rdoc.exclude << '^ext\/' -PROJ.rdoc.opts << '-x' << 'ext' - -# Ruby -PROJ.ruby_opts = [] -PROJ.ruby_opts << '-I' << BUILD_EXT_DIR unless RUBY_PLATFORM == "java" - -# RSpec -PROJ.spec.files.exclude /rbx/ -PROJ.spec.opts << '--color' << '-fs' - -# Dependencies - -#depend_on 'rake', '>=0.8.7' - TEST_DEPS = [ LIBTEST ] if RUBY_PLATFORM == "java" desc "Run all specs" task :specs => TEST_DEPS do sh %{#{Gem.ruby} -w -S rspec #{Dir["spec/ffi/*_spec.rb"].join(" ")} -fs --color} @@ -142,10 +108,15 @@ task :package => 'gem:package' desc "Install the gem locally" task :install => 'gem:install' +namespace :gem do + task :install => :gem do + ruby %{ -S gem install pkg/ffi-#{gem_spec.version}.gem } + end +end desc "Clean all built files" task :distclean => :clobber do FileUtils.rm_rf('build') FileUtils.rm_rf(Dir["lib/**/ffi_c.#{RbConfig::CONFIG['DLEXT']}"]) @@ -156,11 +127,11 @@ FileUtils.rm_rf('pkg') end desc "Build the native test lib" -task "build/libtest.#{LIBEXT}" do +file "build/libtest.#{LIBEXT}" => FileList['libtest/**/*.[ch]'] do sh %{#{GMAKE} -f libtest/GNUmakefile CPU=#{CPU} OS=#{OS} } end desc "Build test helper lib" @@ -191,6 +162,28 @@ task :default => :specs task 'gem:win32' do sh("rake cross native gem RUBY_CC_VERSION='1.8.7:1.9.3'") || raise("win32 build failed!") +end + + +if USE_RAKE_COMPILER + Rake::ExtensionTask.new('ffi_c', gem_spec) do |ext| + ext.name = 'ffi_c' # indicate the name of the extension. + # ext.lib_dir = BUILD_DIR # put binaries into this folder. + ext.tmp_dir = BUILD_DIR # temporary folder used during compilation. + ext.cross_compile = true # enable cross compilation (requires cross compile toolchain) + ext.cross_platform = 'i386-mingw32' # forces the Windows platform instead of the default one + end +end + +begin + require 'yard' + + namespace :doc do + YARD::Rake::YardocTask.new do |yard| + end + end +rescue LoadError + warn "[warn] YARD unavailable" end