Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 165 lines (134 sloc) 5.656 kb
e7f98b6 @tenderlove initial checkin
tenderlove authored
1 # -*- ruby -*-
cde87f2 @tenderlove Revert "fixing segfaults. no more weakrefs"
tenderlove authored
2 require 'rubygems'
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
3
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
4 gem 'hoe'
5 require 'hoe'
6 Hoe.plugin :debugging
7 Hoe.plugin :git
8 Hoe.plugin :gemspec
9 Hoe.plugin :bundler
10 Hoe.add_include_dirs '.' # for ruby 1.9.2
06f7a60 @tenderlove vendoring hoe
tenderlove authored
11
702affb @tenderlove parser has-a tokenizer
tenderlove authored
12 GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
13 GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
14 CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
e7f98b6 @tenderlove initial checkin
tenderlove authored
15
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
16 def java?
17 !! (RUBY_PLATFORM =~ /java/)
18 end
19
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
20 require 'tasks/nokogiri.org'
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
21
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
22 HOE = Hoe.spec 'nokogiri' do
8cdda05 @flavorjones Rakefile cleanup. Add Yoko to the gemspec's developer list.
flavorjones authored
23 developer 'Aaron Patterson', 'aaronp@rubyforge.org'
24 developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
25 developer 'Yoko Harada', 'yokolet@gmail.com'
26
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
27 self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
28 self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
29
30 self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
31
32 self.clean_globs += [
fb54cef @flavorjones Adding gemspec to clean_globs
flavorjones authored
33 'nokogiri.gemspec',
db2b3db @tenderlove cleaning up some warnings, moving dylib under lib
tenderlove authored
34 'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
35 'lib/nokogiri/nokogiri.{so,dylib,rb,bundle}',
5648c6b @tenderlove clean up fat binary cross compile stuff
tenderlove authored
36 'lib/nokogiri/nokogiri.rb',
37 'lib/nokogiri/1.{8,9}',
06f7a60 @tenderlove vendoring hoe
tenderlove authored
38 GENERATED_PARSER,
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
39 GENERATED_TOKENIZER
06f7a60 @tenderlove vendoring hoe
tenderlove authored
40 ]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
41
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
42 self.extra_dev_deps += [
43 ["racc", ">= 1.4.6"],
44 ["rexical", ">= 1.0.5"],
45 ["rake-compiler", ">= 0.7.9"],
46 ["minitest", "~> 2.2.2"],
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
47 ["mini_portile", ">= 0.2.2"],
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
48 ["hoe-debugging", ">= 0"],
49 ["hoe-git", ">= 0"],
50 ["hoe-gemspec", ">= 0"],
51 ["hoe-bundler", ">= 0"]
52 ]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
53
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
54 if java?
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
55 self.spec_extras = { :platform => 'java' }
56 else
c3736e3 @tenderlove requiring ruby >= 1.8.7
tenderlove authored
57 self.spec_extras = {
58 :extensions => ["ext/nokogiri/extconf.rb"],
59 :required_ruby_version => '>= 1.8.7'
60 }
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
61 end
d9d1d90 @flavorjones telling hoe we're using minitest
flavorjones authored
62
63 self.testlib = :minitest
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
64 end
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
65
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
66 # ----------------------------------------
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
67
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
68 if java?
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
69 # TODO: clean this section up.
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
70 require "rake/javaextensiontask"
71 Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
46513f9 @tenderlove removing unused codes
tenderlove authored
72 jruby_home = RbConfig::CONFIG['prefix']
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
73 ext.ext_dir = 'ext/java'
e1423a0 @tenderlove specify the lib_dir
tenderlove authored
74 ext.lib_dir = 'lib/nokogiri'
e7e6948 @drbrain Shorten long lines
drbrain authored
75 jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
76 ext.classpath = jars.map { |x| File.expand_path x }.join ':'
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
77 end
fe678a1 @drbrain Work around rake not understanding platforms, allows Nokogiri to buil…
drbrain authored
78
79 gem_build_path = File.join 'pkg', HOE.spec.full_name
80
89056e7 @flavorjones removing code that was working around an old rake bug. (nod to @tmm1)
flavorjones authored
81 task gem_build_path => [:compile] do
8cdda05 @flavorjones Rakefile cleanup. Add Yoko to the gemspec's developer list.
flavorjones authored
82 cp 'lib/nokogiri/nokogiri.jar', File.join(gem_build_path, 'lib', 'nokogiri')
449619d @tenderlove making sure nokogiri jar is in the packaged gem. THANKS ERIC!!
tenderlove authored
83 HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
84 end
85 else
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
86 require 'tasks/cross_compile'
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
87 require "rake/extensiontask"
88 Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
89 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
90 ext.config_options << ENV['EXTOPTS']
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
91 ext.cross_compile = true
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
92 ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
93 ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
94 ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes[:libxml2].path, 'lib')}"
95 ext.cross_config_options << "--with-iconv-dir=#{$recipes[:libiconv].path}"
96 ext.cross_config_options << "--with-xslt-dir=#{$recipes[:libxslt].path}"
bc89663 @tenderlove updating with cross compiling tasks
tenderlove authored
97 ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
98 end
5643860 @jbarnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
99 end
100
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
101 # ----------------------------------------
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
102
fb54cef @flavorjones Adding gemspec to clean_globs
flavorjones authored
103 desc "Generate css/parser.rb and css/tokenizer.rex"
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
104 task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
105 task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
106
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
107 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
0710803 @tenderlove switch to RbConfig
tenderlove authored
108 racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
109 racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
0066601 @tenderlove check_deps ensures that these gems are installed
tenderlove authored
110 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
111 end
112
113 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
0066601 @tenderlove check_deps ensures that these gems are installed
tenderlove authored
114 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
85b1f6d @tenderlove starting the move to C
tenderlove authored
115 end
116
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
117 [:compile, :check_manifest].each do |task_name|
118 Rake::Task[task_name].prerequisites << GENERATED_PARSER
119 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
1b2d8e5 @flavorjones let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
120 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
121
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
122 # ----------------------------------------
123
4f61ace @flavorjones putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
124 desc "set environment variables to build and/or test with debug options"
125 task :debug do
126 ENV['NOKOGIRI_DEBUG'] = "true"
127 ENV['CFLAGS'] ||= ""
128 ENV['CFLAGS'] += " -DDEBUG"
129 end
130
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
131 require 'tasks/test'
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
132
133 Rake::Task[:test].prerequisites << :compile
134 Rake::Task[:test].prerequisites << :check_extra_deps unless java?
135 if Hoe.plugins.include?(:debugging)
136 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
137 Rake::Task["test:#{task_name}"].prerequisites << :compile
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
138 end
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
139 end
140
141 # ----------------------------------------
c6cea3c @tenderlove fixing up rdoc and adding an rdoc test
tenderlove authored
142
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
143 desc "build a windows gem without all the ceremony."
144 task "gem:windows" do
145 rake_compiler_config = YAML.load_file("#{ENV['HOME']}/.rake-compiler/config.yml")
146
147 # check that rake-compiler config contains the right patchlevels of 1.8.6 and 1.9.1. see #279.
148 ["1.8.6-p383", "1.9.1-p243"].each do |version|
149 majmin, patchlevel = version.split("-")
150 rbconfig = "rbconfig-#{majmin}"
151 unless rake_compiler_config.key?(rbconfig) && rake_compiler_config[rbconfig] =~ /-#{patchlevel}/
152 raise "rake-compiler '#{rbconfig}' not #{patchlevel}. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{version}'"
7a43e2e @flavorjones ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
153 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
154 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
155
c7efec6 @flavorjones Converted to mini_portile for cross-compiling libraries.
flavorjones authored
156 # verify that --export-all is in the 1.9.1 rbconfig. see #279,#374,#375.
157 rbconfig_191 = rake_compiler_config["rbconfig-1.9.1"]
158 raise "rbconfig #{rbconfig_191} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_191).grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
159
160 pkg_config_path = [:libxslt, :libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
161 sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=1.8.6:1.9.1 rake cross native gem") || raise("build failed!")
162 end
505e91a @flavorjones Started cleaning up Rakefile.
flavorjones authored
163
e7f98b6 @tenderlove initial checkin
tenderlove authored
164 # vim: syntax=Ruby
Something went wrong with that request. Please try again.