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