Permalink
Browse files

Started cleaning up Rakefile.

  • Loading branch information...
flavorjones committed Jun 21, 2011
1 parent f7588ac commit 505e91acaa54ae0065f1d5bb9c4765da8e86cd46
Showing with 44 additions and 34 deletions.
  1. +44 −34 Rakefile
View
@@ -1,29 +1,37 @@
# -*- ruby -*-
-
require 'rubygems'
-gem 'hoe', '>= 2.1.0'
-require 'hoe'
-windows = RUBY_PLATFORM =~ /(mswin|mingw)/i
-java = RUBY_PLATFORM =~ /java/
+gem 'hoe'
+require 'hoe'
+Hoe.plugin :debugging
+Hoe.plugin :git
+Hoe.plugin :gemspec
+Hoe.plugin :bundler
+Hoe.add_include_dirs '.' # for ruby 1.9.2
GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
-CROSS_DIR = File.join(File.dirname(__FILE__), 'tmp', 'cross')
+CROSS_DIR = File.join(File.dirname(__FILE__), 'tmp', 'cross')
-Hoe.plugin :debugging
-Hoe.plugin :git
-Hoe.plugin :gemspec
+def java?
+ !! (RUBY_PLATFORM =~ /java/)
+end
+
+def windows?
+ !! (RUBY_PLATFORM =~ /(mswin|mingw)/i)
+end
HOE = Hoe.spec 'nokogiri' do
developer 'Aaron Patterson', 'aaronp@rubyforge.org'
developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
developer 'Yoko Harada', 'yokolet@gmail.com'
- self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
- self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
- self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
- self.clean_globs = [
+ self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
+ self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
+
+ self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
+
+ self.clean_globs += [
'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
'lib/nokogiri/nokogiri.rb',
'lib/nokogiri/1.{8,9}',
@@ -32,12 +40,18 @@ HOE = Hoe.spec 'nokogiri' do
CROSS_DIR
]
- extra_dev_deps << ["racc", '>= 0']
- extra_dev_deps << ["rexical", '>= 0']
- extra_dev_deps << ["rake-compiler", '>= 0']
- extra_dev_deps << ["minitest", "~> 2.2.2"]
+ self.extra_dev_deps += [
+ ["racc", ">= 1.4.6"],
+ ["rexical", ">= 1.0.5"],
+ ["rake-compiler", ">= 0.7.9"],
+ ["minitest", "~> 2.2.2"],
+ ["hoe-debugging", ">= 0"],
+ ["hoe-git", ">= 0"],
+ ["hoe-gemspec", ">= 0"],
+ ["hoe-bundler", ">= 0"]
+ ]
- if java
+ if java?
self.spec_extras = { :platform => 'java' }
self.need_tar = false # these will be built broken
self.need_zip = false
@@ -51,12 +65,8 @@ HOE = Hoe.spec 'nokogiri' do
self.testlib = :minitest
end
-Hoe.add_include_dirs '.'
-require 'tasks/nokogiri.org'
-
-gem 'rake-compiler', '>= 0.4.1'
-if java
+if java?
require "rake/javaextensiontask"
Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
jruby_home = RbConfig::CONFIG['prefix']
@@ -78,20 +88,20 @@ else
ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
ext.config_options << ENV['EXTOPTS']
- ext.cross_compile = true
+ ext.cross_compile = true
ext.cross_platform = ["x86-mingw32", "x86-mswin32-60"]
- ext.cross_config_options <<
- "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
- ext.cross_config_options <<
- "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
+ ext.cross_config_options << "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
+ ext.cross_config_options << "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
ext.cross_config_options << "--with-iconv-dir=#{CROSS_DIR}"
ext.cross_config_options << "--with-xslt-dir=#{CROSS_DIR}"
ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
end
end
+
desc "Generate css/parser.y and css/tokenizer.rex"
-task 'generate' => [ GENERATED_PARSER, GENERATED_TOKENIZER ]
+task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
+task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
@@ -103,9 +113,7 @@ file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
end
-task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
-require 'tasks/test'
begin
require 'tasks/cross_compile'
rescue RuntimeError => e
@@ -119,20 +127,22 @@ task :debug do
ENV['CFLAGS'] += " -DDEBUG"
end
-# Only do this on unix, since we can't build on windows
-unless windows
+require 'tasks/test'
+unless windows?
[:compile, :check_manifest].each do |task_name|
Rake::Task[task_name].prerequisites << GENERATED_PARSER
Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
end
Rake::Task[:test].prerequisites << :compile
- Rake::Task[:test].prerequisites << :check_extra_deps unless java
+ Rake::Task[:test].prerequisites << :check_extra_deps unless java?
if Hoe.plugins.include?(:debugging)
['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
Rake::Task["test:#{task_name}"].prerequisites << :compile
end
end
end
+require 'tasks/nokogiri.org'
+
# vim: syntax=Ruby

0 comments on commit 505e91a

Please sign in to comment.