Rakefile in json_pure-1.0.2 vs Rakefile in json_pure-1.0.3

- old
+ new

@@ -1,12 +1,14 @@ # vim: set et sw=2 ts=2: + require 'rake/gempackagetask' 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']})$/) EXT_ROOT_DIR = 'ext/json/ext' EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser" @@ -17,48 +19,60 @@ EXT_GENERATOR_DL = "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}" EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c" RAGEL_CODEGEN = %w[rlcodegen rlgen-cd].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}"], + FileList["ext/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def}"], FileList["ext/**/Makefile"] desc "Installing library (pure)" task :install_pure => :version do ruby 'install.rb' end -desc "Installing library (extension)" -task :install_ext => [ :compile, :install_pure ] do +task :install_ext_really do sitearchdir = CONFIG["sitearchdir"] cd 'ext' do for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"] d = File.join(sitearchdir, file) mkdir_p File.dirname(d) install(file, d) end end end +desc "Installing library (extension)" +task :install_ext => [ :compile, :install_pure, :install_ext_really ] + task :install => :install_ext desc "Compiling extension" task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ] file EXT_PARSER_DL => EXT_PARSER_SRC do cd EXT_PARSER_DIR do ruby 'extconf.rb' - sh 'make' + if ON_WINDOWS + sh 'nmake' + sh "mt -manifest parser.#{CONFIG['DLEXT']}.manifest -outputresource:parser.#{CONFIG['DLEXT']};2" + else + sh 'make' + end 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' - sh 'make' + if ON_WINDOWS + sh 'nmake' + sh "mt -manifest generator.#{CONFIG['DLEXT']}.manifest -outputresource:generator.#{CONFIG['DLEXT']};2" + else + sh 'make' + end end cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR end desc "Generate parser with ragel" @@ -218,10 +232,48 @@ Rake::GemPackageTask.new(spec_ext) do |pkg| 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"] + 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 << 'tests/runner.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' +end + task :mrproper => [ :ragel_clean, :clean ] do for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ] cd(dir) { rm_f 'Makefile' } end end @@ -241,8 +293,12 @@ end EOT end end -task :release => [ :version, :clean, :ragel_clean, :ragel, :package ] +if ON_WINDOWS + task :release => [ :version, :clean, :compile, :package_win ] +else + task :release => [ :version, :mrproper, :package ] +end task :default => [ :version, :compile ]