Rakefile in json_pure-1.1.4 vs Rakefile in json_pure-1.1.5
- old
+ new
@@ -1,18 +1,18 @@
begin
require 'rake/gempackagetask'
+ require 'rake/extensiontask'
rescue LoadError
end
require 'rake/clean'
require 'rbconfig'
include Config
-ON_WINDOWS = RUBY_PLATFORM =~ /mswin32/i
PKG_NAME = 'json'
PKG_VERSION = File.read('VERSION').chomp
-PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|coverage|Makefile/).exclude(/\.(so|bundle|o|#{CONFIG['DLEXT']})$/)
+PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile/).exclude(/\.(so|bundle|o|#{CONFIG['DLEXT']})$/)
EXT_ROOT_DIR = 'ext/json/ext'
EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
EXT_PARSER_DL = "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}"
EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
PKG_FILES << EXT_PARSER_SRC
@@ -20,15 +20,14 @@
EXT_GENERATOR_DL = "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
-CLEAN.include 'doc', 'coverage', FileList['diagrams/*.*'],
- FileList["ext/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def}"],
- FileList["ext/**/{Makefile,mkmf.log}"]
+CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
+ FileList["ext/**/{Makefile,mkmf.log}"],
+ FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def}"]
-
desc "Installing library (pure)"
task :install_pure => :version do
ruby 'install.rb'
end
@@ -42,39 +41,30 @@
end
end
end
desc "Installing library (extension)"
-task :install_ext => [ :compile, :install_pure, :install_ext_really ]
+task :install_ext => [ :compile_ext, :install_pure, :install_ext_really ]
+desc "Installing library (extension)"
task :install => :install_ext
desc "Compiling extension"
-task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
+task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
file EXT_PARSER_DL => EXT_PARSER_SRC do
cd EXT_PARSER_DIR do
ruby 'extconf.rb'
- if ON_WINDOWS
- system 'nmake'
- system "mt -manifest parser.#{CONFIG['DLEXT']}.manifest -outputresource:parser.#{CONFIG['DLEXT']};2"
- else
- system 'make'
- end
+ system 'make'
end
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
end
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
cd EXT_GENERATOR_DIR do
ruby 'extconf.rb'
- if ON_WINDOWS
- system 'nmake'
- system "mt -manifest generator.#{CONFIG['DLEXT']}.manifest -outputresource:generator.#{CONFIG['DLEXT']};2"
- else
- system 'make'
- end
+ system 'make'
end
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
end
desc "Generate parser with ragel"
@@ -131,16 +121,19 @@
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
system "testrb #{Dir['tests/*.rb'] * ' '}"
end
desc "Testing library (extension)"
-task :test_ext => :compile do
+task :test_ext => :compile_ext do
ENV['JSON'] = 'ext'
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
system "testrb #{Dir['tests/*.rb'] * ' '}"
end
+desc "Testing library (pure ruby and extension)"
+task :test => [ :test_pure, :test_ext ]
+
desc "Benchmarking parser"
task :benchmark_parser do
ruby 'benchmarks/parser_benchmark.rb'
end
@@ -160,11 +153,11 @@
desc "Create RDOC documentation"
task :doc => [ :version, EXT_PARSER_SRC ] do
system "rdoc -S -o doc -m main.txt doc-templates/main.txt lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
end
-if defined? Gem
+if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask)
spec_pure = Gem::Specification.new do |s|
s.name = 'json_pure'
s.version = PKG_VERSION
s.summary = "A JSON implementation in Ruby"
s.description = ""
@@ -172,11 +165,11 @@
s.files = PKG_FILES
s.require_path = 'lib'
s.bindir = "bin"
- s.executables = ["edit_json.rb"]
+ s.executables = [ "edit_json.rb", "prettify_json.rb" ]
s.default_executable = "edit_json.rb"
s.has_rdoc = true
s.rdoc_options <<
'--title' << 'JSON -- A JSON implemention' <<
@@ -200,20 +193,18 @@
s.summary = "A JSON implementation as a Ruby extension"
s.description = ""
s.files = PKG_FILES
- s.extensions <<
- "#{EXT_PARSER_DIR}/extconf.rb" <<
- "#{EXT_GENERATOR_DIR}/extconf.rb"
+ s.extensions = FileList['ext/**/extconf.rb']
s.require_path = EXT_ROOT_DIR
s.require_paths << 'ext'
s.require_paths << 'lib'
s.bindir = "bin"
- s.executables = ["edit_json.rb"]
+ s.executables = [ "edit_json.rb", "prettify_json.rb" ]
s.default_executable = "edit_json.rb"
s.has_rdoc = true
s.rdoc_options <<
'--title' << 'JSON -- A JSON implemention' <<
@@ -225,56 +216,30 @@
s.homepage = "http://json.rubyforge.org"
s.rubyforge_project = "json"
end
Rake::GemPackageTask.new(spec_ext) do |pkg|
- pkg.need_tar = true
- pkg.package_files += PKG_FILES
+ pkg.need_tar = true
+ pkg.package_files = PKG_FILES
end
- task :package_win => :compile do
- mkdir_p 'pkg'
- spec_win_ext = Gem::Specification.new do |s|
- s.name = 'json'
- s.platform = Gem::Platform::WIN32
- s.version = PKG_VERSION
- s.summary = "A JSON implementation as a Ruby extension"
- s.description = ""
-
- s.files = PKG_FILES.to_a <<
- "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}" <<
- "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
-
- s.require_path = EXT_ROOT_DIR
- s.require_paths << 'ext'
- s.require_paths << 'lib'
-
- s.bindir = "bin"
- s.executables = ["edit_json.rb", "prettify_json.rb"]
- s.default_executable = "edit_json.rb"
-
- s.has_rdoc = true
- s.rdoc_options <<
- '--title' << 'JSON -- A JSON implemention' <<
- '--main' << 'JSON' << '--line-numbers'
- s.test_files.concat Dir['tests/*.rb']
-
- s.author = "Florian Frank"
- s.email = "flori@ping.de"
- s.homepage = "http://json.rubyforge.org"
- s.rubyforge_project = "json"
- end
-
- gem_file = "json-#{spec_win_ext.version}-#{spec_win_ext.platform}.gem"
- Gem::Builder.new(spec_win_ext).build
- mv gem_file, 'pkg'
+ Rake::ExtensionTask.new do |ext|
+ ext.name = 'parser'
+ ext.gem_spec = spec_ext
+ ext.cross_compile = true
+ ext.cross_platform = 'i386-mswin32'
+ ext.ext_dir = 'ext/json/ext/parser'
+ ext.lib_dir = 'lib/json/ext'
end
-end
-
-task :mrproper => [ :ragel_clean, :clean, :clean_benchmark_data ] do
- for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ]
- cd(dir) { rm_f %w[Makefile mkmf.log] }
+
+ Rake::ExtensionTask.new do |ext|
+ ext.name = 'generator'
+ ext.gem_spec = spec_ext
+ ext.cross_compile = true
+ ext.cross_platform = 'i386-mswin32'
+ ext.ext_dir = 'ext/json/ext/generator'
+ ext.lib_dir = 'lib/json/ext'
end
end
desc m = "Writing version information for #{PKG_VERSION}"
task :version do
@@ -286,18 +251,18 @@
VERSION = '#{PKG_VERSION}'
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
- VARIANT_BINARY = #{!!ON_WINDOWS}
end
EOT
end
end
-if ON_WINDOWS
- task :release => [ :version, :clean, :package_win ]
-else
- task :release => [ :version, :mrproper, :package ]
+# TODO task :release => [ :version, :clean, :package_win ]
+desc "Build all gems and archives for a new release."
+task :release => [ :clean, :version, :cross, :native, :gem ] do
+ system "#$0 clean native gem"
+ system "#$0 clean package"
end
-task :default => [ :version, :compile ]
+task :default => [ :version, :compile_ext ]