Rakefile in json_pure-1.5.1 vs Rakefile in json_pure-1.5.2

- old
+ new

@@ -1,24 +1,18 @@ begin - require 'rake/gempackagetask' + require 'rubygems/package_task' rescue LoadError end -begin - require 'rake/extensiontask' -rescue LoadError - warn "WARNING: rake-compiler is not installed. You will not be able to build the json gem until you install it." -end - require 'rbconfig' include Config require 'rake/clean' -CLOBBER.include Dir['benchmarks/data/*.{dat,log}'] +CLOBBER.include Dir['benchmarks/data/*.{dat,log}'], 'doc' CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp', FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'], - FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class}"], + FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class,dSYM}"], FileList['java/src/**/*.class'] MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') } PKG_NAME = 'json' PKG_TITLE = 'JSON Implementation for Ruby' @@ -71,53 +65,59 @@ end end end desc "Installing library (extension)" -task :install_ext => [ :compile_ext, :install_pure, :install_ext_really ] +task :install_ext => [ :compile, :install_pure, :install_ext_really ] desc "Installing library (extension)" if RUBY_PLATFORM =~ /java/ task :install => :install_pure else task :install => :install_ext end -if defined?(Gem) and defined?(Rake::GemPackageTask) +if defined?(Gem) and defined?(Gem::PackageTask) spec_pure = Gem::Specification.new do |s| s.name = 'json_pure' s.version = PKG_VERSION s.summary = PKG_TITLE s.description = "This is a JSON implementation in pure Ruby." s.files = PKG_FILES s.require_path = 'lib' + s.add_development_dependency 'permutation' + s.add_development_dependency 'bullshit' + s.add_development_dependency 'sdoc' s.bindir = "bin" s.executables = [ "edit_json.rb", "prettify_json.rb" ] - s.default_executable = "edit_json.rb" - s.has_rdoc = true - s.extra_rdoc_files << 'README' + s.extra_rdoc_files << 'README.rdoc' s.rdoc_options << - '--title' << 'JSON implemention for ruby' << '--main' << 'README' + '--title' << 'JSON implemention for ruby' << '--main' << 'README.rdoc' s.test_files.concat Dir['./tests/test_*.rb'] s.author = "Florian Frank" s.email = "flori@ping.de" s.homepage = "http://flori.github.com/#{PKG_NAME}" s.rubyforge_project = "json" end - Rake::GemPackageTask.new(spec_pure) do |pkg| + desc 'Creates a json_pure.gemspec file' + task :gemspec_pure => :version do + File.open('json_pure.gemspec', 'w') do |gemspec| + gemspec.write spec_pure.to_ruby + end + end + + Gem::PackageTask.new(spec_pure) do |pkg| pkg.need_tar = true pkg.package_files = PKG_FILES end -end -if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask) spec_ext = Gem::Specification.new do |s| s.name = 'json' s.version = PKG_VERSION s.summary = PKG_TITLE s.description = "This is a JSON implementation as a Ruby extension in C." @@ -127,49 +127,43 @@ s.extensions = FileList['ext/**/extconf.rb'] s.require_path = EXT_ROOT_DIR s.require_paths << 'ext' s.require_paths << 'lib' + s.add_development_dependency 'permutation' + s.add_development_dependency 'bullshit' + s.add_development_dependency 'sdoc' s.bindir = "bin" s.executables = [ "edit_json.rb", "prettify_json.rb" ] - s.default_executable = "edit_json.rb" - s.has_rdoc = true - s.extra_rdoc_files << 'README' + s.extra_rdoc_files << 'README.rdoc' s.rdoc_options << - '--title' << 'JSON implemention for Ruby' << '--main' << 'README' + '--title' << 'JSON implemention for Ruby' << '--main' << 'README.rdoc' s.test_files.concat Dir['./tests/test_*.rb'] s.author = "Florian Frank" s.email = "flori@ping.de" s.homepage = "http://flori.github.com/#{PKG_NAME}" s.rubyforge_project = "json" end - Rake::GemPackageTask.new(spec_ext) do |pkg| + desc 'Creates a json.gemspec file' + task :gemspec_ext => :version do + File.open('json.gemspec', 'w') do |gemspec| + gemspec.write spec_ext.to_ruby + end + end + + Gem::PackageTask.new(spec_ext) do |pkg| pkg.need_tar = true pkg.package_files = PKG_FILES end - Rake::ExtensionTask.new do |ext| - ext.name = 'parser' - ext.gem_spec = spec_ext - ext.cross_compile = true - ext.cross_platform = %w[i386-mswin32 i386-mingw32] - ext.ext_dir = 'ext/json/ext/parser' - ext.lib_dir = 'lib/json/ext' - end - Rake::ExtensionTask.new do |ext| - ext.name = 'generator' - ext.gem_spec = spec_ext - ext.cross_compile = true - ext.cross_platform = %w[i386-mswin32 i386-mingw32] - ext.ext_dir = 'ext/json/ext/generator' - ext.lib_dir = 'lib/json/ext' - end + desc 'Create all gemspec files' + task :gemspec => [ :gemspec_pure, :gemspec_ext ] end desc m = "Writing version information for #{PKG_VERSION}" task :version do puts m @@ -195,11 +189,10 @@ end desc "Testing library (pure ruby and extension)" task :test => [ :test_pure, :test_ext ] - if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby' file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do cd JAVA_DIR do if RAGEL_CODEGEN == 'ragel' sh "ragel Parser.rl -J -o Parser.java" @@ -230,11 +223,11 @@ else warn "WARNING: Cannot find jruby in path => Cannot build jruby extension!" end desc "Compiling jruby extension" - task :compile_ext => JAVA_CLASSES + task :compile => JAVA_CLASSES desc "Package the jruby gem" task :jruby_gem => :create_jar do sh 'gem build json-java.gemspec' mkdir_p 'pkg' @@ -245,11 +238,11 @@ task :test_ext => :create_jar do ENV['JSON'] = 'ext' myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb'] end - file JRUBY_PARSER_JAR => :compile_ext do + file JRUBY_PARSER_JAR => :compile do cd 'java/src' do parser_classes = FileList[ "json/ext/ByteListTranscoder*.class", "json/ext/OptionsReader*.class", "json/ext/Parser*.class", @@ -263,11 +256,11 @@ end desc "Create parser jar" task :create_parser_jar => JRUBY_PARSER_JAR - file JRUBY_GENERATOR_JAR => :compile_ext do + file JRUBY_GENERATOR_JAR => :compile do cd 'java/src' do generator_classes = FileList[ "json/ext/ByteListTranscoder*.class", "json/ext/OptionsReader*.class", "json/ext/Generator*.class", @@ -288,11 +281,11 @@ desc "Build all gems and archives for a new release of the jruby extension." task :release => [ :clean, :version, :jruby_gem ] else desc "Compiling extension" - task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ] + task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ] file EXT_PARSER_DL => EXT_PARSER_SRC do cd EXT_PARSER_DIR do myruby 'extconf.rb' sh MAKE @@ -307,11 +300,11 @@ end cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR end desc "Testing library (extension)" - task :test_ext => :compile_ext do + task :test_ext => :compile do ENV['JSON'] = 'ext' ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}" myruby '-S', 'testrb', *Dir['./tests/test_*.rb'] end @@ -332,11 +325,11 @@ desc "Benchmarking library" task :benchmark => [ :benchmark_parser, :benchmark_generator ] desc "Create RDOC documentation" task :doc => [ :version, EXT_PARSER_SRC ] do - sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}" + sh "sdoc -o doc -t '#{PKG_TITLE}' -m README.rdoc README.rdoc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}" end desc "Generate parser with ragel" task :ragel => EXT_PARSER_SRC @@ -384,18 +377,11 @@ end desc "Generate diagrams of ragel parser" task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ] - task :environment do - ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2' - end - desc "Build all gems and archives for a new release of json and json_pure." - task :release => [ :clean, :version, :environment, :cross, :native, :gem, ] do - sh "#$0 clean native gem" - sh "#$0 clean package" - end + task :release => [ :clean, :gemspec, :package ] end desc "Compile in the the source directory" -task :default => [ :version ] +task :default => [ :clean, :gemspec, :compile ]