Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 215 lines (178 sloc) 6.43 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'
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
6
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
7 windows = RUBY_PLATFORM =~ /(mswin|mingw)/i
8 java = RUBY_PLATFORM =~ /java/
06f7a60 @tenderlove vendoring hoe
tenderlove authored
9
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
10 GENERATED_PARSER = "lib/nokogiri/css/generated_parser.rb"
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
11 GENERATED_TOKENIZER = "lib/nokogiri/css/generated_tokenizer.rb"
bc89663 @tenderlove updating with cross compiling tasks
tenderlove authored
12 CROSS_DIR = File.join(File.dirname(__FILE__), 'tmp', 'cross')
e7f98b6 @tenderlove initial checkin
tenderlove authored
13
96df126 @yokolet Switch code from Sergio's version to pmahoney's version. New code doe…
yokolet authored
14 EXTERNAL_JAVA_LIBRARIES = %w{isorelax jing nekohtml nekodtd xercesImpl}.map{|x| "lib/#{x}.jar"}
2cf94af @Serabe Trying to solve the problem with BasicLibraryService
Serabe authored
15 JAVA_EXT = "lib/nokogiri/nokogiri.jar"
38c6028 Add basics for building nokogiri_java.jar extension to Rakefile.
Charles Nutter authored
16 JRUBY_HOME = Config::CONFIG['prefix']
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
17
cfc1419 @tenderlove removing valgrind tasks in favor of a hoe plugin
tenderlove authored
18 # Make sure hoe-debugging is installed
19 Hoe.plugin :debugging
20
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
21 HOE = Hoe.spec 'nokogiri' do
22 developer('Aaron Patterson', 'aaronp@rubyforge.org')
23 developer('Mike Dalessio', 'mike.dalessio@gmail.com')
24 self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
25 self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
ab5c665 @flavorjones fixing rdoc generation for ext files.
flavorjones authored
26 self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
27 self.clean_globs = [
db2b3db @tenderlove cleaning up some warnings, moving dylib under lib
tenderlove authored
28 'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
5648c6b @tenderlove clean up fat binary cross compile stuff
tenderlove authored
29 'lib/nokogiri/nokogiri.rb',
30 'lib/nokogiri/1.{8,9}',
06f7a60 @tenderlove vendoring hoe
tenderlove authored
31 GENERATED_PARSER,
32 GENERATED_TOKENIZER,
33 'cross',
34 ]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
35
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
36 %w{ racc rexical rake-compiler }.each do |dep|
6f7b649 @tenderlove fixing hoe warnings
tenderlove authored
37 self.extra_dev_deps << [dep, '>= 0']
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
38 end
8430fe0 @flavorjones converting from test/unit to minitest.
flavorjones authored
39 self.extra_dev_deps << ["minitest", ">= 1.6.0"]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
40
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
41 self.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
d9d1d90 @flavorjones telling hoe we're using minitest
flavorjones authored
42
43 self.testlib = :minitest
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
44 end
31ebd5d @tenderlove adding . to the load path for ruby 1.9.2
tenderlove authored
45 Hoe.add_include_dirs '.'
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
46
94e09cf @tenderlove adding a task for generating the website documentation
tenderlove authored
47 task :ws_docs do
48 title = "#{HOE.name}-#{HOE.version} Documentation"
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
49
94e09cf @tenderlove adding a task for generating the website documentation
tenderlove authored
50 options = []
51 options << "--main=#{HOE.readme_file}"
52 options << '--format=activerecord'
53 options << '--threads=1'
54 options << "--title=#{title.inspect}"
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
55
94e09cf @tenderlove adding a task for generating the website documentation
tenderlove authored
56 options += HOE.spec.require_paths
57 options += HOE.spec.extra_rdoc_files
58 require 'rdoc/rdoc'
59 ENV['RAILS_ROOT'] ||= File.expand_path(File.join('..', 'nokogiri_ws'))
60 RDoc::RDoc.new.document options
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
61 end
62
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
63 unless java
64 gem 'rake-compiler', '>= 0.4.1'
65 require "rake/extensiontask"
66
fb709d6 @tenderlove adding fat binary awesomeness
tenderlove authored
67 RET = Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
68 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
69
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
70 ext.config_options << ENV['EXTOPTS']
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 <<
bc89663 @tenderlove updating with cross compiling tasks
tenderlove authored
74 "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
75 ext.cross_config_options <<
bc89663 @tenderlove updating with cross compiling tasks
tenderlove authored
76 "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
77 ext.cross_config_options << "--with-iconv-dir=#{CROSS_DIR}"
78 ext.cross_config_options << "--with-xslt-dir=#{CROSS_DIR}"
79 ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
80 end
5643860 @jbarnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
81 end
82
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
83 namespace :java do
84 desc "Removes all generated during compilation .class files."
85 task :clean_classes do
1d31a29 Started to extract methods to XmlNodeMethod class and subclasses.
Sergio Arbeo authored
86 (FileList['ext/java/nokogiri/internals/*.class'] + FileList['ext/java/nokogiri/*.class'] + FileList['ext/java/*.class']).to_a.each do |file|
4297b19 @Serabe NokogiriJavaService compiles. jruby:clean added.
Serabe authored
87 File.delete file
88 end
89 end
6da099f Having problems with native_write_to
Sergio Arbeo authored
90
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
91 desc "Removes the generated .jar"
6da099f Having problems with native_write_to
Sergio Arbeo authored
92 task :clean_jar do
93 FileList['lib/nokogiri/*.jar'].each{|f| File.delete f }
94 end
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
95
96 desc "Same as java:clean_classes and java:clean_jar"
97 task :clean_all => ["java:clean_classes", "java:clean_jar"]
98
99 desc "Build a gem targetted for JRuby"
ba86f04 @flavorjones cleaned up java rake tasks
flavorjones authored
100 task :gem => ['java:spec', GENERATED_PARSER, GENERATED_TOKENIZER, :build] do
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
101 system "gem build nokogiri.gemspec"
102 FileUtils.mkdir_p "pkg"
103 FileUtils.mv Dir.glob("nokogiri*-java.gem"), "pkg"
104 end
105
ba86f04 @flavorjones cleaned up java rake tasks
flavorjones authored
106 task :spec do
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
107 File.open("#{HOE.name}.gemspec", 'w') do |f|
108 HOE.spec.platform = 'java'
109 HOE.spec.files += [GENERATED_PARSER, GENERATED_TOKENIZER, JAVA_EXT] + EXTERNAL_JAVA_LIBRARIES
110 HOE.spec.extensions = []
111 f.write(HOE.spec.to_ruby)
ba86f04 @flavorjones cleaned up java rake tasks
flavorjones authored
112 end
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
113 end
114
115 desc "Build external library"
116 task :build_external do
117 Dir.chdir('ext/java') do
118 LIB_DIR = '../../lib'
96df126 @yokolet Switch code from Sergio's version to pmahoney's version. New code doe…
yokolet authored
119 CLASSPATH = "#{JRUBY_HOME}/lib/jruby.jar:#{LIB_DIR}/nekohtml.jar:#{LIB_DIR}/nekodtd.jar:#{LIB_DIR}/xercesImpl.jar:#{LIB_DIR}/isorelax.jar:#{LIB_DIR}/jing.jar"
df9b64b Add debugging info when making java class files.
William Sargent authored
120 sh "javac -g -cp #{CLASSPATH} nokogiri/*.java nokogiri/internals/*.java"
5f88ee6 @Serabe Modify Rakefile. Pure Java is now under java namespace.
Serabe authored
121 sh "jar cf ../../#{JAVA_EXT} nokogiri/*.class nokogiri/internals/*.class"
122 end
123 end
124
125 task :build => ["java:clean_jar", "java:build_external", "java:clean_classes"]
4297b19 @Serabe NokogiriJavaService compiles. jruby:clean added.
Serabe authored
126 end
127
c40736a @tenderlove bumping version and adding a gem spec task
tenderlove authored
128 namespace :gem do
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
129 namespace :dev do
92a3c39 @tenderlove making the dev spec depend on the generated parser and tokenizer
tenderlove authored
130 task :spec => [ GENERATED_PARSER, GENERATED_TOKENIZER ] do
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
131 File.open("#{HOE.name}.gemspec", 'w') do |f|
132 HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
133 f.write(HOE.spec.to_ruby)
134 end
135 end
136 end
137
138 task :spec => ['gem:dev:spec']
c40736a @tenderlove bumping version and adding a gem spec task
tenderlove authored
139 end
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
140
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
141 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
66fea0e @tenderlove adding a java platform
tenderlove authored
142 begin
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
143 racc = `which racc`.strip
144 racc = "#{::Config::CONFIG['bindir']}/racc" if racc.empty?
cbe03a9 @tenderlove no more module_evals in the generated css parser
tenderlove authored
145 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
66fea0e @tenderlove adding a java platform
tenderlove authored
146 rescue
eee9465 @tenderlove refactoring valgrind test
tenderlove authored
147 abort "need racc, sudo gem install racc"
e1e9751 @tenderlove extconf should not check for frex and racc
tenderlove authored
148 end
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
149 end
150
151 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
66fea0e @tenderlove adding a java platform
tenderlove authored
152 begin
c504ee5 @tenderlove nokogiri depends on rex instead of frex now o.O!
tenderlove authored
153 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
66fea0e @tenderlove adding a java platform
tenderlove authored
154 rescue
b00ee52 @tenderlove changing rex to rexical. ugh
tenderlove authored
155 abort "need rexical, sudo gem install rexical"
85b1f6d @tenderlove starting the move to C
tenderlove authored
156 end
157 end
158
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
159 require 'tasks/test'
1b2d8e5 @flavorjones let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
160 begin
161 require 'tasks/cross_compile' unless RUBY_PLATFORM =~ /java/
162 rescue RuntimeError => e
163 warn "WARNING: Could not perform some cross-compiling: #{e}"
164 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
165
4f61ace @flavorjones putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
166 desc "set environment variables to build and/or test with debug options"
167 task :debug do
168 ENV['NOKOGIRI_DEBUG'] = "true"
169 ENV['CFLAGS'] ||= ""
170 ENV['CFLAGS'] += " -DDEBUG"
171 end
172
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
173 # required_ruby_version
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
174
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
175 # Only do this on unix, since we can't build on windows
849a3cb @flavorjones more FFI removal.
flavorjones authored
176 unless windows || java
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
177 [:compile, :check_manifest].each do |task_name|
178 Rake::Task[task_name].prerequisites << GENERATED_PARSER
179 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
180 end
c6cea3c @tenderlove fixing up rdoc and adding an rdoc test
tenderlove authored
181
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
182 Rake::Task[:test].prerequisites << :compile
68967c7 @flavorjones better check for hoe-debugging
flavorjones authored
183 if Hoe.plugins.include?(:debugging)
7a43e2e @flavorjones ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
184 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
185 Rake::Task["test:#{task_name}"].prerequisites << :compile
186 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
187 end
19245c5 @flavorjones generating parser and tokenizer for jruby builds
flavorjones authored
188 else
189 [:test, :check_manifest].each do |task_name|
190 if Rake::Task[task_name]
191 Rake::Task[task_name].prerequisites << GENERATED_PARSER
192 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
193 end
c6cea3c @tenderlove fixing up rdoc and adding an rdoc test
tenderlove authored
194 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
195 end
196
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
197 namespace :install do
c504ee5 @tenderlove nokogiri depends on rex instead of frex now o.O!
tenderlove authored
198 desc "Install rex and racc for development"
b00ee52 @tenderlove changing rex to rexical. ugh
tenderlove authored
199 task :deps => %w(rexical racc)
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
200
a191ba0 @tenderlove cleaning up rakefile
tenderlove authored
201 task :racc do |t|
202 sh "sudo gem install racc"
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
203 end
204
b00ee52 @tenderlove changing rex to rexical. ugh
tenderlove authored
205 task :rexical do
206 sh "sudo gem install rexical"
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
207 end
208 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
209
05d2538 @jmhodges generating the tokenizer and parser for rip on install
jmhodges authored
210 namespace :rip do
211 task :install => [GENERATED_TOKENIZER, GENERATED_PARSER]
212 end
213
e7f98b6 @tenderlove initial checkin
tenderlove authored
214 # vim: syntax=Ruby
Something went wrong with that request. Please try again.