Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 217 lines (183 sloc) 6.234 kb
e7f98b6 Aaron Patterson initial checkin
tenderlove authored
1 # -*- ruby -*-
2
cde87f2 Aaron Patterson Revert "fixing segfaults. no more weakrefs"
tenderlove authored
3 require 'rubygems'
18a5f56 Aaron Patterson refactoring and upgrading us to hoe 2.1.0
tenderlove authored
4 gem 'hoe', '>= 2.1.0'
0c12448 Aaron Patterson removing vendored hoe
tenderlove authored
5 require 'hoe'
f2ee3ab Aaron Patterson making sure that rake-compiler is installed
tenderlove authored
6
2c3f433 Aaron Patterson more rakefile cleanup
tenderlove authored
7 windows = RUBY_PLATFORM =~ /(mswin|mingw)/i
8 java = RUBY_PLATFORM =~ /java/
e7f98b6 Aaron Patterson initial checkin
tenderlove authored
9
702affb Aaron Patterson parser has-a tokenizer
tenderlove authored
10 GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
11 GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
7cb54b2 Aaron Patterson updating with cross compiling tasks
tenderlove authored
12 CROSS_DIR = File.join(File.dirname(__FILE__), 'tmp', 'cross')
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
13
cfc1419 Aaron Patterson removing valgrind tasks in favor of a hoe plugin
tenderlove authored
14 # Make sure hoe-debugging is installed
15 Hoe.plugin :debugging
e77c7ff Mike Dalessio hoe plugin :git
flavorjones authored
16 Hoe.plugin :git
cfc1419 Aaron Patterson removing valgrind tasks in favor of a hoe plugin
tenderlove authored
17
18a5f56 Aaron Patterson refactoring and upgrading us to hoe 2.1.0
tenderlove authored
18 HOE = Hoe.spec 'nokogiri' do
19 developer('Aaron Patterson', 'aaronp@rubyforge.org')
20 developer('Mike Dalessio', 'mike.dalessio@gmail.com')
21 self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
22 self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
f777d19 Mike Dalessio fixing rdoc generation for ext files.
flavorjones authored
23 self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
18a5f56 Aaron Patterson refactoring and upgrading us to hoe 2.1.0
tenderlove authored
24 self.clean_globs = [
053bb1c Mike Dalessio gem:jruby builds need to download windows dlls.
flavorjones authored
25 "ext/nokogiri/*.dll",
db2b3db Aaron Patterson cleaning up some warnings, moving dylib under lib
tenderlove authored
26 'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
5648c6b Aaron Patterson clean up fat binary cross compile stuff
tenderlove authored
27 'lib/nokogiri/nokogiri.rb',
28 'lib/nokogiri/1.{8,9}',
06f7a60 Aaron Patterson vendoring hoe
tenderlove authored
29 GENERATED_PARSER,
30 GENERATED_TOKENIZER,
31 'cross',
32 ]
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
33
2c3f433 Aaron Patterson more rakefile cleanup
tenderlove authored
34 %w{ racc rexical rake-compiler }.each do |dep|
6f7b649 Aaron Patterson fixing hoe warnings
tenderlove authored
35 self.extra_dev_deps << [dep, '>= 0']
2c3f433 Aaron Patterson more rakefile cleanup
tenderlove authored
36 end
8430fe0 Mike Dalessio converting from test/unit to minitest.
flavorjones authored
37 self.extra_dev_deps << ["minitest", ">= 1.6.0"]
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
38
18a5f56 Aaron Patterson refactoring and upgrading us to hoe 2.1.0
tenderlove authored
39 self.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
d9d1d90 Mike Dalessio telling hoe we're using minitest
flavorjones authored
40
41 self.testlib = :minitest
08450f3 Aaron Patterson auto generating the IDL interface
tenderlove authored
42 end
31ebd5d Aaron Patterson adding . to the load path for ruby 1.9.2
tenderlove authored
43 Hoe.add_include_dirs '.'
08450f3 Aaron Patterson auto generating the IDL interface
tenderlove authored
44
94e09cf Aaron Patterson adding a task for generating the website documentation
tenderlove authored
45 task :ws_docs do
46 title = "#{HOE.name}-#{HOE.version} Documentation"
47
48 options = []
49 options << "--main=#{HOE.readme_file}"
50 options << '--format=activerecord'
51 options << '--threads=1'
52 options << "--title=#{title.inspect}"
53
54 options += HOE.spec.require_paths
55 options += HOE.spec.extra_rdoc_files
56 require 'rdoc/rdoc'
57 ENV['RAILS_ROOT'] ||= File.expand_path(File.join('..', 'nokogiri_ws'))
58 RDoc::RDoc.new.document options
541cbeb Aaron Patterson making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
59 end
60
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
61 unless java
62 gem 'rake-compiler', '>= 0.4.1'
63 require "rake/extensiontask"
64
fb709d6 Aaron Patterson adding fat binary awesomeness
tenderlove authored
65 RET = Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 Aaron Patterson making fat binaries easy with nokogiri
tenderlove authored
66 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
67
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
68 ext.config_options << ENV['EXTOPTS']
69 ext.cross_compile = true
30d4db7 Aaron Patterson terrorist version bump
tenderlove authored
70 ext.cross_platform = 'i386-mingw32'
2bdd7e0 Mike Dalessio i'm sure we'll need to build mswin32 again someday.
flavorjones authored
71 # ext.cross_platform = 'i386-mswin32'
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
72 ext.cross_config_options <<
7cb54b2 Aaron Patterson updating with cross compiling tasks
tenderlove authored
73 "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
74 ext.cross_config_options <<
7cb54b2 Aaron Patterson updating with cross compiling tasks
tenderlove authored
75 "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
76 ext.cross_config_options << "--with-iconv-dir=#{CROSS_DIR}"
77 ext.cross_config_options << "--with-xslt-dir=#{CROSS_DIR}"
78 ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
79 end
5643860 John Barnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
80 end
81
c40736a Aaron Patterson bumping version and adding a gem spec task
tenderlove authored
82 namespace :gem do
35cace6 Aaron Patterson fixing up win32 build, adding a few methods to dtd
tenderlove authored
83 namespace :dev do
92a3c39 Aaron Patterson making the dev spec depend on the generated parser and tokenizer
tenderlove authored
84 task :spec => [ GENERATED_PARSER, GENERATED_TOKENIZER ] do
35cace6 Aaron Patterson fixing up win32 build, adding a few methods to dtd
tenderlove authored
85 File.open("#{HOE.name}.gemspec", 'w') do |f|
86 HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
87 f.write(HOE.spec.to_ruby)
88 end
89 end
90 end
91
af62dc3 Mike Dalessio added a rake task description for "gem:jruby"
flavorjones authored
92 desc "Build a gem targetted for JRuby"
f7cfa24 Mike Dalessio added rake task "gem:jruby"
flavorjones authored
93 task :jruby => ['gem:jruby:spec'] do
053bb1c Mike Dalessio gem:jruby builds need to download windows dlls.
flavorjones authored
94 raise "ERROR: please run this task under jruby" unless java
f7cfa24 Mike Dalessio added rake task "gem:jruby"
flavorjones authored
95 system "gem build nokogiri.gemspec"
96 FileUtils.mkdir_p "pkg"
97 FileUtils.mv Dir.glob("nokogiri*-java.gem"), "pkg"
98 end
99
66fea0e Aaron Patterson adding a java platform
tenderlove authored
100 namespace :jruby do
053bb1c Mike Dalessio gem:jruby builds need to download windows dlls.
flavorjones authored
101 task :spec => [GENERATED_PARSER, GENERATED_TOKENIZER, :"gem:jruby:dlls"] do
66fea0e Aaron Patterson adding a java platform
tenderlove authored
102 File.open("#{HOE.name}.gemspec", 'w') do |f|
91d2207 Aaron Patterson fixing platform for java nokogiri
tenderlove authored
103 HOE.spec.platform = 'java'
155c236 Aaron Patterson adding generated parser and tokenizer to jruby spec
tenderlove authored
104 HOE.spec.files << GENERATED_PARSER
105 HOE.spec.files << GENERATED_TOKENIZER
70ad006 Aaron Patterson adding DLLs to JRuby gem. closes #112
tenderlove authored
106 HOE.spec.files += Dir["ext/nokogiri/*.dll"]
66fea0e Aaron Patterson adding a java platform
tenderlove authored
107 HOE.spec.extensions = []
64f6e7c Mike Dalessio correcting the addition of weakling as a dependency for jruby gems.
flavorjones authored
108 HOE.spec.add_dependency 'weakling', '>= 0.0.3'
66fea0e Aaron Patterson adding a java platform
tenderlove authored
109 f.write(HOE.spec.to_ruby)
110 end
111 end
053bb1c Mike Dalessio gem:jruby builds need to download windows dlls.
flavorjones authored
112
113 task :dlls do
114 def run cmd
115 puts(cmd) || system(cmd) || raise("command failed")
116 end
117
118 dlldir = "tmp/dlls"
119 FileUtils.mkdir_p dlldir
120 Dir.chdir dlldir do
121 unless File.exists? "nokogiri-1.4.3.1-java.gem"
122 run "wget http://rubygems.org/downloads/nokogiri-1.4.3.1-java.gem"
123 end
124 unless File.exists? "data.tar.gz"
125 run "tar -xf nokogiri-1.4.3.1-java.gem"
126 end
127 FileUtils.rm_rf "unpack"
128 FileUtils.mkdir "unpack"
129 Dir.chdir "unpack" do
130 run "tar -zxf ../data.tar.gz"
131 end
132 end
133
134 Dir["#{dlldir}/unpack/ext/nokogiri/*.dll"].each do |file|
135 cp file, "ext/nokogiri"
136 end
137 end
66fea0e Aaron Patterson adding a java platform
tenderlove authored
138 end
139
35cace6 Aaron Patterson fixing up win32 build, adding a few methods to dtd
tenderlove authored
140 task :spec => ['gem:dev:spec']
c40736a Aaron Patterson bumping version and adding a gem spec task
tenderlove authored
141 end
08450f3 Aaron Patterson auto generating the IDL interface
tenderlove authored
142
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
143 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
66fea0e Aaron Patterson adding a java platform
tenderlove authored
144 begin
ebbd415 Romulo A. Ceccon made extconf.rb and Rakefile Windows friendly; fixed Manifest.txt entrie...
romuloceccon authored
145 racc = Config::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
da6292d John Barnette Make development dependencies easier to install.
jbarnette authored
146 racc = "#{::Config::CONFIG['bindir']}/racc" if racc.empty?
cbe03a9 Aaron Patterson no more module_evals in the generated css parser
tenderlove authored
147 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
66fea0e Aaron Patterson adding a java platform
tenderlove authored
148 rescue
eee9465 Aaron Patterson refactoring valgrind test
tenderlove authored
149 abort "need racc, sudo gem install racc"
e1e9751 Aaron Patterson extconf should not check for frex and racc
tenderlove authored
150 end
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
151 end
152
153 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
66fea0e Aaron Patterson adding a java platform
tenderlove authored
154 begin
c504ee5 Aaron Patterson nokogiri depends on rex instead of frex now o.O!
tenderlove authored
155 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
66fea0e Aaron Patterson adding a java platform
tenderlove authored
156 rescue
b00ee52 Aaron Patterson changing rex to rexical. ugh
tenderlove authored
157 abort "need rexical, sudo gem install rexical"
e1e9751 Aaron Patterson extconf should not check for frex and racc
tenderlove authored
158 end
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
159 end
85b1f6d Aaron Patterson starting the move to C
tenderlove authored
160
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
161 require 'tasks/test'
a4bc5c6 Mike Dalessio let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
162 begin
af30794 Mike Dalessio correcting a bad merge.
flavorjones authored
163 require 'tasks/cross_compile' unless java
a4bc5c6 Mike Dalessio let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
164 rescue RuntimeError => e
165 warn "WARNING: Could not perform some cross-compiling: #{e}"
166 end
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
167
4f61ace Mike Dalessio putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
168 desc "set environment variables to build and/or test with debug options"
169 task :debug do
170 ENV['NOKOGIRI_DEBUG'] = "true"
171 ENV['CFLAGS'] ||= ""
172 ENV['CFLAGS'] += " -DDEBUG"
173 end
174
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
175 # required_ruby_version
176
177 # Only do this on unix, since we can't build on windows
1ce6b42 Mike Dalessio don't compile before tests if NOKOGIRI_FFI is set.
flavorjones authored
178 unless windows || java || ENV['NOKOGIRI_FFI']
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
179 [:compile, :check_manifest].each do |task_name|
180 Rake::Task[task_name].prerequisites << GENERATED_PARSER
181 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
182 end
c5b6dbf Aaron Patterson I made our tests mad
tenderlove authored
183
96253d5 Mike Dalessio compile should always be a prereq for rake test task.
flavorjones authored
184 Rake::Task[:test].prerequisites << :compile
68967c7 Mike Dalessio better check for hoe-debugging
flavorjones authored
185 if Hoe.plugins.include?(:debugging)
7a43e2e Mike Dalessio ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
186 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
187 Rake::Task["test:#{task_name}"].prerequisites << :compile
188 end
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
189 end
19245c5 Mike Dalessio generating parser and tokenizer for jruby builds
flavorjones authored
190 else
191 [:test, :check_manifest].each do |task_name|
192 if Rake::Task[task_name]
193 Rake::Task[task_name].prerequisites << GENERATED_PARSER
194 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
195 end
196 end
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
197 end
10b09f8 Mike Dalessio added rake task to run test suite in gdb
flavorjones authored
198
da6292d John Barnette Make development dependencies easier to install.
jbarnette authored
199 namespace :install do
c504ee5 Aaron Patterson nokogiri depends on rex instead of frex now o.O!
tenderlove authored
200 desc "Install rex and racc for development"
b00ee52 Aaron Patterson changing rex to rexical. ugh
tenderlove authored
201 task :deps => %w(rexical racc)
da6292d John Barnette Make development dependencies easier to install.
jbarnette authored
202
a191ba0 Aaron Patterson cleaning up rakefile
tenderlove authored
203 task :racc do |t|
204 sh "sudo gem install racc"
da6292d John Barnette Make development dependencies easier to install.
jbarnette authored
205 end
206
b00ee52 Aaron Patterson changing rex to rexical. ugh
tenderlove authored
207 task :rexical do
208 sh "sudo gem install rexical"
da6292d John Barnette Make development dependencies easier to install.
jbarnette authored
209 end
210 end
10b09f8 Mike Dalessio added rake task to run test suite in gdb
flavorjones authored
211
05d2538 Jeff Hodges generating the tokenizer and parser for rip on install
jmhodges authored
212 namespace :rip do
213 task :install => [GENERATED_TOKENIZER, GENERATED_PARSER]
214 end
215
e7f98b6 Aaron Patterson initial checkin
tenderlove authored
216 # vim: syntax=Ruby
Something went wrong with that request. Please try again.