Rakefile in fjson-0.0.7 vs Rakefile in fjson-0.0.8

- old
+ new

@@ -1,111 +1,53 @@ dir = File.dirname(__FILE__) require File.expand_path("#{dir}/rake_helper") -require 'rake/gempackagetask' -require 'rake/contrib/rubyforgepublisher' -require 'rake/clean' -require 'rake/testtask' -require 'rake/rdoctask' - -task :default => [ :compile ] do -end - -task :compile => [ - :json_ext, - :state_ext, - :object_ext, - :integer_ext, - :float_ext, - :string_ext, - :true_class_ext, - :false_class_ext, - :nil_class_ext, - :array_ext, - :hash_ext -] do -end - -task :spec => [:compile, :install] do - require File.expand_path("#{dir}/spec/spec_suite") -end - -task :lib do - directory "lib" -end - -fjson_extensions = [ - "json_ext", - "state_ext", - "extensions/object_ext", - "extensions/integer_ext", - "extensions/float_ext", - "extensions/string_ext", - "extensions/true_class_ext", - "extensions/false_class_ext", - "extensions/nil_class_ext", - "extensions/array_ext", - "extensions/hash_ext" -] - -fjson_extensions.each do |ext| - setup_mkmf_extension ext -end - -task :install do - fjson_extensions.each do |extension_path| - library_path = library_path(extension_path) - raise "Extension binary for #{extension_path} does not exist. Did you run rake compile?" unless library_path - cp build_path(extension_path), library_path(extension_path) - end -end - -task :cleanup do - fjson_extensions.each do |extension_path| - library_path = library_path(extension_path) - rm library_path if library_path && File.exists?(library_path) - rake_file_path = "#{build_path(extension_path)}/Rakefile" - rm rake_file_path if rake_file_path && File.exists?(rake_file_path) - end -end - -def build_path(relative_extension_path) - basename = "#{File.dirname(__FILE__)}/ext/#{relative_extension_path}/#{File.basename(relative_extension_path)}" - if File.exists?("#{basename}.so") - return "#{basename}.so" - elsif File.exists?("#{basename}.bundle") - return "#{basename}.bundle" - end - return nil -end - -def library_path(relative_extension_path) - build_path = build_path(relative_extension_path) - return nil unless build_path - extname = File.extname(build_path) - library_directory_path = File.dirname(__FILE__) + "/lib/" + File.dirname(relative_extension_path) - binary_name = "#{File.basename(relative_extension_path)}#{extname}" - "#{library_directory_path}/#{binary_name}" -end - def win32? ENV["target_platform"] == "win32" end -if win32? - #Rake::Task[].invoke -end +rake_builder = MkmfRakeBuilder.new +rake_builder.project_dir = File.dirname(__FILE__) +rake_builder.rake_application = Rake.application +rake_builder.rake_tasks = Rake::Task +rake_builder.rake_file_tasks = Rake::FileTask +rake_builder.dir_class = Dir +rake_builder.file_class = File +rake_builder.file_extension = (RUBY_PLATFORM =~ /darwin/) ? "bundle" : "so" +fjson_extensions = rake_builder.extensions_to_build = [ + [:json_ext, "json_ext"], + [:state_ext, "state_ext"], + [:object_ext, "extensions/object_ext"], + [:integer_ext, "extensions/integer_ext"], + [:float_ext, "extensions/float_ext"], + [:string_ext, "extensions/string_ext"], + [:true_class_ext, "extensions/true_class_ext"], + [:false_class_ext, "extensions/false_class_ext"], + [:nil_class_ext, "extensions/nil_class_ext"], + [:array_ext, "extensions/array_ext"], + [:hash_ext, "extensions/hash_ext"] +] +rake_builder.extconf_arguments = "-I /usr/local/lib/ruby-mingw32/lib/ruby/1.8/i386-mingw32" if win32? +rake_builder.build_default_task +rake_builder.build_compile_task +rake_builder.build_spec_task +rake_builder.build_lib_task +rake_builder.build_extension_compile_tasks +rake_builder.build_install_task +rake_builder.build_cleanup_task + PKG_NAME = "fjson" -PKG_VERSION = "0.0.7" +PKG_VERSION = "0.0.8" PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" PKG_FILES = FileList[ '[A-Z]*', '*.rb', 'lib/**/*.rb', - 'ext/**/*.{h,c,rb}', 'spec/**/*.rb' ] +executable_extensions = (win32?) ? 'lib/**/*.so' : 'ext/**/*.{h,c,rb}' +PKG_FILES.include(executable_extensions) spec = Gem::Specification.new do |s| s.name = PKG_NAME s.version = PKG_VERSION s.summary = <<-EOF @@ -113,10 +55,11 @@ This library is a fork of Florian Frank's JSON library with key parts implemented in C for performance improvements. EOF s.test_files = Dir.glob('spec/*_spec.rb') s.description = s.summary + s.platform = (win32?) ? Gem::Platform::WIN32 : Gem::Platform::RUBY s.files = PKG_FILES.to_a s.require_path = 'lib' s.has_rdoc = true @@ -128,16 +71,13 @@ s.author = "Brian Takita" s.email = "brian.takita@gmail.com" s.homepage = "http://fjson.rubyforge.org" s.rubyforge_project = "fjson" - s.extensions = ["Rakefile"] + s.extensions = ["Rakefile"] unless win32? + s.add_dependency "rspec", ">=0.6.4" #s.add_dependency "mkrf", ">=0.1.2" - - if win32? - - end end Rake::GemPackageTask.new(spec) do |pkg| pkg.need_zip = true pkg.need_tar = true