Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 253 lines (212 sloc) 7.175 kB
e7f98b6 @tenderlove initial checkin
tenderlove authored
1 # -*- ruby -*-
2
cde87f2 @tenderlove Revert "fixing segfaults. no more weakrefs"
tenderlove authored
3 require 'rubygems'
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
4 gem 'hoe', '>= 2.1.0'
0c12448 @tenderlove removing vendored hoe
tenderlove authored
5 require 'hoe'
f2ee3ab @tenderlove making sure that rake-compiler is installed
tenderlove authored
6
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
7 windows = RUBY_PLATFORM =~ /(mswin|mingw)/i
8 java = RUBY_PLATFORM =~ /java/
e7f98b6 @tenderlove initial checkin
tenderlove authored
9
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
10 GENERATED_PARSER = "lib/nokogiri/css/generated_parser.rb"
11 GENERATED_TOKENIZER = "lib/nokogiri/css/generated_tokenizer.rb"
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
12
cfc1419 @tenderlove removing valgrind tasks in favor of a hoe plugin
tenderlove authored
13 # Make sure hoe-debugging is installed
14 Hoe.plugin :debugging
15
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
16 HOE = Hoe.spec 'nokogiri' do
17 developer('Aaron Patterson', 'aaronp@rubyforge.org')
18 developer('Mike Dalessio', 'mike.dalessio@gmail.com')
19 self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
20 self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
21 self.extra_rdoc_files = FileList['*.rdoc']
22 self.clean_globs = [
db2b3db @tenderlove cleaning up some warnings, moving dylib under lib
tenderlove authored
23 'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
5648c6b @tenderlove clean up fat binary cross compile stuff
tenderlove authored
24 'lib/nokogiri/nokogiri.rb',
25 'lib/nokogiri/1.{8,9}',
06f7a60 @tenderlove vendoring hoe
tenderlove authored
26 GENERATED_PARSER,
27 GENERATED_TOKENIZER,
28 'cross',
29 ]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
30
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
31 %w{ racc rexical rake-compiler }.each do |dep|
6f7b649 @tenderlove fixing hoe warnings
tenderlove authored
32 self.extra_dev_deps << [dep, '>= 0']
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
33 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
34
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
35 self.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
36 end
37
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
38 Rake::RDocTask.new('AWESOME') do |rd|
39 rd.main = HOE.readme_file
40 rd.options << '-d' if (`which dot` =~ /\/dot/) unless
41 rd.rdoc_dir = 'doc'
42
43 rd.rdoc_files += HOE.spec.require_paths
44 rd.rdoc_files += HOE.spec.extra_rdoc_files
45
46 title = HOE.spec.rdoc_options.grep(/^(-t|--title)=?$/).first
47
48 if title then
49 rd.options << title
50
51 unless title =~ /=/ then # for ['-t', 'title here']
52 title_index = HOE.spec.rdoc_options.index(title)
53 rd.options << HOE.spec.rdoc_options[title_index + 1]
54 end
55 else
56 title = "#{HOE.name}-#{HOE.version} Documentation"
57 title = "#{HOE.rubyforge_name}'s " + title if HOE.rubyforge_name != HOE.name
58 rd.options << '--title' << title
59 end
60 end
61
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
62 unless java
63 gem 'rake-compiler', '>= 0.4.1'
64 require "rake/extensiontask"
65
fb709d6 @tenderlove adding fat binary awesomeness
tenderlove authored
66 RET = Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
67 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
68
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
69 ext.config_options << ENV['EXTOPTS']
70 cross_dir = File.join(File.dirname(__FILE__), 'tmp', 'cross')
71 ext.cross_compile = true
30d4db7 @tenderlove terrorist version bump
tenderlove authored
72 ext.cross_platform = 'i386-mingw32'
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
73 ext.cross_config_options <<
74 "--with-iconv-dir=#{File.join(cross_dir, 'iconv')}"
75 ext.cross_config_options <<
76 "--with-xml2-dir=#{File.join(cross_dir, 'libxml2')}"
77 ext.cross_config_options <<
78 "--with-xslt-dir=#{File.join(cross_dir, 'libxslt')}"
79 end
80
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
81 file 'lib/nokogiri/nokogiri.rb' do
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
82 File.open("lib/#{HOE.name}/#{HOE.name}.rb", 'wb') do |f|
83 f.write <<-eoruby
93200a3 @tenderlove fixing generated file and adding dlls to the spec
tenderlove authored
84 require "#{HOE.name}/\#{RUBY_VERSION.sub(/\\.\\d+$/, '')}/#{HOE.name}"
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
85 eoruby
86 end
fb709d6 @tenderlove adding fat binary awesomeness
tenderlove authored
87 end
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
88
89 namespace :cross do
90 task :file_list do
0fe204b @tenderlove updating spef files to include so file
tenderlove authored
91 HOE.spec.platform = 'x86-mingw32'
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
92 HOE.spec.extensions = []
93 HOE.spec.files += Dir["lib/#{HOE.name}/#{HOE.name}.rb"]
0fe204b @tenderlove updating spef files to include so file
tenderlove authored
94 HOE.spec.files += Dir["lib/#{HOE.name}/1.{8,9}/#{HOE.name}.so"]
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
95 HOE.spec.files += Dir["ext/nokogiri/*.dll"]
96 end
97 end
98
30d4db7 @tenderlove terrorist version bump
tenderlove authored
99 CLOBBER.include("lib/nokogiri/nokogiri.{so,dylib,rb,bundle}")
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
100 CLOBBER.include("lib/nokogiri/1.{8,9}")
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
101 CLOBBER.include("ext/nokogiri/*.dll")
5643860 @jbarnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
102 end
103
c40736a @tenderlove bumping version and adding a gem spec task
tenderlove authored
104 namespace :gem do
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
105 namespace :dev do
106 task :spec do
107 File.open("#{HOE.name}.gemspec", 'w') do |f|
108 HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
109 f.write(HOE.spec.to_ruby)
110 end
111 end
112 end
113
af62dc3 @flavorjones added a rake task description for "gem:jruby"
flavorjones authored
114 desc "Build a gem targetted for JRuby"
f7cfa24 @flavorjones added rake task "gem:jruby"
flavorjones authored
115 task :jruby => ['gem:jruby:spec'] do
116 system "gem build nokogiri.gemspec"
117 FileUtils.mkdir_p "pkg"
118 FileUtils.mv Dir.glob("nokogiri*-java.gem"), "pkg"
119 end
120
66fea0e @tenderlove adding a java platform
tenderlove authored
121 namespace :jruby do
7934580 @flavorjones narrowing what's necessary to build a jruby gemspec.
flavorjones authored
122 task :spec => [GENERATED_PARSER, GENERATED_TOKENIZER] do
66fea0e @tenderlove adding a java platform
tenderlove authored
123 File.open("#{HOE.name}.gemspec", 'w') do |f|
91d2207 @tenderlove fixing platform for java nokogiri
tenderlove authored
124 HOE.spec.platform = 'java'
155c236 @tenderlove adding generated parser and tokenizer to jruby spec
tenderlove authored
125 HOE.spec.files << GENERATED_PARSER
126 HOE.spec.files << GENERATED_TOKENIZER
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
127 HOE.spec.files += Dir["ext/nokogiri/*.dll"]
66fea0e @tenderlove adding a java platform
tenderlove authored
128 HOE.spec.extensions = []
129 f.write(HOE.spec.to_ruby)
130 end
131 end
132 end
133
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
134 task :spec => ['gem:dev:spec']
c40736a @tenderlove bumping version and adding a gem spec task
tenderlove authored
135 end
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
136
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
137 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
66fea0e @tenderlove adding a java platform
tenderlove authored
138 begin
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
139 racc = `which racc`.strip
140 racc = "#{::Config::CONFIG['bindir']}/racc" if racc.empty?
cbe03a9 @tenderlove no more module_evals in the generated css parser
tenderlove authored
141 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
66fea0e @tenderlove adding a java platform
tenderlove authored
142 rescue
eee9465 @tenderlove refactoring valgrind test
tenderlove authored
143 abort "need racc, sudo gem install racc"
e1e9751 @tenderlove extconf should not check for frex and racc
tenderlove authored
144 end
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
145 end
146
147 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
66fea0e @tenderlove adding a java platform
tenderlove authored
148 begin
c504ee5 @tenderlove nokogiri depends on rex instead of frex now o.O!
tenderlove authored
149 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
66fea0e @tenderlove adding a java platform
tenderlove authored
150 rescue
b00ee52 @tenderlove changing rex to rexical. ugh
tenderlove authored
151 abort "need rexical, sudo gem install rexical"
e1e9751 @tenderlove extconf should not check for frex and racc
tenderlove authored
152 end
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
153 end
85b1f6d @tenderlove starting the move to C
tenderlove authored
154
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
155 libs = %w{
156 iconv-1.9.2.win32
157 zlib-1.2.3.win32
158 libxml2-2.7.3.win32
159 libxslt-1.1.24.win32
160 }
161
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
162 lib_dlls = {
163 'iconv-1.9.2.win32' => 'iconv.dll',
164 'zlib-1.2.3.win32' => 'zlib1.dll',
165 'libxml2-2.7.3.win32' => 'libxml2.dll',
166 'libxslt-1.1.24.win32' => 'libxslt.dll',
167 }
168
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
169 libs.each do |lib|
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
170 libname = lib.split('-').first
171
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
172 file "tmp/stash/#{lib}.zip" do |t|
173 puts "downloading #{lib}"
174 FileUtils.mkdir_p('tmp/stash')
acddc4a @tenderlove adding an rdoc test and adding lots of rdoc. closes #21
tenderlove authored
175 Dir.chdir('tmp/stash') do
1760fc4 @tenderlove get the windows cross compile files from xmlsoft
tenderlove authored
176 url = "ftp://ftp.xmlsoft.org/libxml2/win32/#{lib}.zip"
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
177 system("wget #{url} || curl -O #{url}")
94cd698 @flavorjones using a separate 'stash' directory for storing .zip and .tar.gz files…
flavorjones authored
178 end
179 end
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
180
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
181 file "tmp/cross/#{libname}" => ["tmp/stash/#{lib}.zip"] do |t|
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
182 puts "unzipping #{lib}.zip"
183 FileUtils.mkdir_p('tmp/cross')
184 Dir.chdir('tmp/cross') do
185 sh "unzip ../stash/#{lib}.zip"
186 sh "cp #{lib}/bin/* #{lib}/lib" # put DLL in lib, so dirconfig works
187 sh "mv #{lib} #{lib.split('-').first}"
188 sh "touch #{lib.split('-').first}"
131df0d @tenderlove adding tasks to build cross compiled nokogiri
tenderlove authored
189 end
190 end
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
191
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
192 file "ext/nokogiri/#{lib_dlls[lib]}" => "tmp/cross/#{libname}" do |t|
193 Dir.chdir('tmp/cross') do
194 sh "cp #{libname}/bin/*.dll ../../ext/nokogiri/"
195 end
196 end
197
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
198 if Rake::Task.task_defined?(:cross)
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
199 Rake::Task[:cross].prerequisites << "ext/nokogiri/#{lib_dlls[lib]}"
ced0a56 @tenderlove cleaning up fat binary stuff
tenderlove authored
200 Rake::Task[:cross].prerequisites << "lib/nokogiri/nokogiri.rb"
201 Rake::Task[:cross].prerequisites << "cross:file_list"
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
202 end
70ad006 @tenderlove adding DLLs to JRuby gem. closes #112
tenderlove authored
203 Rake::Task['gem:jruby:spec'].prerequisites << "ext/nokogiri/#{lib_dlls[lib]}"
131df0d @tenderlove adding tasks to build cross compiled nokogiri
tenderlove authored
204 end
205
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
206 require 'tasks/test'
207
4f61ace @flavorjones putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
208 desc "set environment variables to build and/or test with debug options"
209 task :debug do
210 ENV['NOKOGIRI_DEBUG'] = "true"
211 ENV['CFLAGS'] ||= ""
212 ENV['CFLAGS'] += " -DDEBUG"
213 end
214
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
215 # required_ruby_version
216
217 # Only do this on unix, since we can't build on windows
1ce6b42 @flavorjones don't compile before tests if NOKOGIRI_FFI is set.
flavorjones authored
218 unless windows || java || ENV['NOKOGIRI_FFI']
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
219 [:compile, :check_manifest].each do |task_name|
220 Rake::Task[task_name].prerequisites << GENERATED_PARSER
221 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
222 end
c5b6dbf @tenderlove I made our tests mad
tenderlove authored
223
96253d5 @flavorjones compile should always be a prereq for rake test task.
flavorjones authored
224 Rake::Task[:test].prerequisites << :compile
68967c7 @flavorjones better check for hoe-debugging
flavorjones authored
225 if Hoe.plugins.include?(:debugging)
7a43e2e @flavorjones ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
226 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
227 Rake::Task["test:#{task_name}"].prerequisites << :compile
228 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
229 end
19245c5 @flavorjones generating parser and tokenizer for jruby builds
flavorjones authored
230 else
231 [:test, :check_manifest].each do |task_name|
232 if Rake::Task[task_name]
233 Rake::Task[task_name].prerequisites << GENERATED_PARSER
234 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
235 end
236 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
237 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
238
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
239 namespace :install do
c504ee5 @tenderlove nokogiri depends on rex instead of frex now o.O!
tenderlove authored
240 desc "Install rex and racc for development"
b00ee52 @tenderlove changing rex to rexical. ugh
tenderlove authored
241 task :deps => %w(rexical racc)
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
242
a191ba0 @tenderlove cleaning up rakefile
tenderlove authored
243 task :racc do |t|
244 sh "sudo gem install racc"
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
245 end
246
b00ee52 @tenderlove changing rex to rexical. ugh
tenderlove authored
247 task :rexical do
248 sh "sudo gem install rexical"
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
249 end
250 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
251
e7f98b6 @tenderlove initial checkin
tenderlove authored
252 # vim: syntax=Ruby
Something went wrong with that request. Please try again.