Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 199 lines (166 sloc) 5.592 kB
e7f98b6 @tenderlove initial checkin
tenderlove authored
1 # -*- ruby -*-
2
cde87f2 @tenderlove Revert "fixing segfaults. no more weakrefs"
tenderlove authored
3 require 'rubygems'
66fea0e @tenderlove adding a java platform
tenderlove authored
4 require 'rake'
0c12448 @tenderlove removing vendored hoe
tenderlove authored
5 require 'hoe'
f2ee3ab @tenderlove making sure that rake-compiler is installed
tenderlove authored
6
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
7 LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
8 $LOAD_PATH << LIB_DIR
9
454c543 @tenderlove adding fat binary codes
tenderlove authored
10 windows = RUBY_PLATFORM =~ /(mswin|mingw)/i ? true : false
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
11 java = RUBY_PLATFORM =~ /java/ ? true : false
e7f98b6 @tenderlove initial checkin
tenderlove authored
12
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
13 GENERATED_PARSER = "lib/nokogiri/css/generated_parser.rb"
14 GENERATED_TOKENIZER = "lib/nokogiri/css/generated_tokenizer.rb"
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
15
16 require 'nokogiri/version'
85b1f6d @tenderlove starting the move to C
tenderlove authored
17
06f7a60 @tenderlove vendoring hoe
tenderlove authored
18 HOE = Hoe.new('nokogiri', Nokogiri::VERSION) do |p|
19 p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
059769d @flavorjones Update gem authors per Aaron's request.
flavorjones authored
20 p.developer('Mike Dalessio', 'mike.dalessio@gmail.com')
bdbd49b @tenderlove moving file names
tenderlove authored
21 p.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
22 p.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
c90955f @tenderlove fixing extra rdoc files
tenderlove authored
23 p.extra_rdoc_files = FileList['*.rdoc']
06f7a60 @tenderlove vendoring hoe
tenderlove authored
24 p.clean_globs = [
25 'ext/nokogiri/Makefile',
26 'ext/nokogiri/*.{o,so,bundle,a,log,dll}',
27 'ext/nokogiri/conftest.dSYM',
28 GENERATED_PARSER,
29 GENERATED_TOKENIZER,
30 'cross',
31 ]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
32
33 p.extra_dev_deps << "racc"
34 p.extra_dev_deps << "tenderlove-frex"
35 p.extra_dev_deps << "rake-compiler"
36
d26ee98 @tenderlove building with extconf.rb fixes #11
tenderlove authored
37 p.spec_extras = { :extensions => ["ext/nokogiri/extconf.rb"] }
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
38 end
39
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
40 unless java
41
42 gem 'rake-compiler', '>= 0.4.1'
43 require "rake/extensiontask"
44
fb709d6 @tenderlove adding fat binary awesomeness
tenderlove authored
45 RET = Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
46 ext.lib_dir = "ext/nokogiri"
47 ext.gem_spec.required_ruby_version = "~> #{RUBY_VERSION.sub(/\.\d+$/, '.0')}"
48 ext.config_options << ENV['EXTOPTS']
49 cross_dir = File.join(File.dirname(__FILE__), 'tmp', 'cross')
50 ext.cross_compile = true
51 ext.cross_platform = 'i386-mswin32'
52 ext.cross_config_options <<
53 "--with-iconv-dir=#{File.join(cross_dir, 'iconv')}"
54 ext.cross_config_options <<
55 "--with-xml2-dir=#{File.join(cross_dir, 'libxml2')}"
56 ext.cross_config_options <<
57 "--with-xslt-dir=#{File.join(cross_dir, 'libxslt')}"
58 end
59
fb709d6 @tenderlove adding fat binary awesomeness
tenderlove authored
60 task :muck_with_lib_dir do
61 RET.lib_dir += "/#{RUBY_VERSION.sub(/\.\d$/, '')}"
62 FileUtils.mkdir_p(RET.lib_dir)
63 end
64 if Rake::Task.task_defined?(:cross)
65 Rake::Task[:cross].prerequisites << "muck_with_lib_dir"
66 end
67
5643860 @jbarnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
68 end
69
c40736a @tenderlove bumping version and adding a gem spec task
tenderlove authored
70 namespace :gem do
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
71 namespace :dev do
72 task :spec do
73 File.open("#{HOE.name}.gemspec", 'w') do |f|
74 HOE.spec.version = "#{HOE.version}.#{Time.now.strftime("%Y%m%d%H%M%S")}"
75 f.write(HOE.spec.to_ruby)
76 end
77 end
78 end
79
66fea0e @tenderlove adding a java platform
tenderlove authored
80 namespace :jruby do
3475e5b @tenderlove bumping version
tenderlove authored
81 task :spec => ['compile'] do
66fea0e @tenderlove adding a java platform
tenderlove authored
82 File.open("#{HOE.name}.gemspec", 'w') do |f|
91d2207 @tenderlove fixing platform for java nokogiri
tenderlove authored
83 HOE.spec.platform = 'java'
155c236 @tenderlove adding generated parser and tokenizer to jruby spec
tenderlove authored
84 HOE.spec.files << GENERATED_PARSER
85 HOE.spec.files << GENERATED_TOKENIZER
66fea0e @tenderlove adding a java platform
tenderlove authored
86 HOE.spec.extensions = []
87 f.write(HOE.spec.to_ruby)
88 end
89 end
90 end
91
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
92 task :spec => ['gem:dev:spec']
c40736a @tenderlove bumping version and adding a gem spec task
tenderlove authored
93 end
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
94
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
95 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
66fea0e @tenderlove adding a java platform
tenderlove authored
96 begin
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
97 racc = `which racc`.strip
98 racc = "#{::Config::CONFIG['bindir']}/racc" if racc.empty?
99 sh "#{racc} -o #{t.name} #{t.prerequisites.first}"
66fea0e @tenderlove adding a java platform
tenderlove authored
100 rescue
eee9465 @tenderlove refactoring valgrind test
tenderlove authored
101 abort "need racc, sudo gem install racc"
e1e9751 @tenderlove extconf should not check for frex and racc
tenderlove authored
102 end
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
103 end
104
105 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
66fea0e @tenderlove adding a java platform
tenderlove authored
106 begin
018644f @tenderlove making a case sensitive parser
tenderlove authored
107 sh "frex --independent -o #{t.name} #{t.prerequisites.first}"
66fea0e @tenderlove adding a java platform
tenderlove authored
108 rescue
acddc4a @tenderlove adding an rdoc test and adding lots of rdoc. closes #21
tenderlove authored
109 abort "need frex, sudo gem install tenderlove-frex -s http://gems.github.com"
e1e9751 @tenderlove extconf should not check for frex and racc
tenderlove authored
110 end
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
111 end
85b1f6d @tenderlove starting the move to C
tenderlove authored
112
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
113 libs = %w{
114 iconv-1.9.2.win32
115 zlib-1.2.3.win32
116 libxml2-2.7.3.win32
117 libxslt-1.1.24.win32
118 }
119
120 libs.each do |lib|
121 file "tmp/stash/#{lib}.zip" do |t|
122 puts "downloading #{lib}"
123 FileUtils.mkdir_p('tmp/stash')
acddc4a @tenderlove adding an rdoc test and adding lots of rdoc. closes #21
tenderlove authored
124 Dir.chdir('tmp/stash') do
1760fc4 @tenderlove get the windows cross compile files from xmlsoft
tenderlove authored
125 url = "ftp://ftp.xmlsoft.org/libxml2/win32/#{lib}.zip"
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
126 system("wget #{url} || curl -O #{url}")
94cd698 @flavorjones using a separate 'stash' directory for storing .zip and .tar.gz files…
flavorjones authored
127 end
128 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
129 file "tmp/cross/#{lib.split('-').first}" => ["tmp/stash/#{lib}.zip"] do |t|
130 puts "unzipping #{lib}.zip"
131 FileUtils.mkdir_p('tmp/cross')
132 Dir.chdir('tmp/cross') do
133 sh "unzip ../stash/#{lib}.zip"
134 sh "cp #{lib}/bin/* #{lib}/lib" # put DLL in lib, so dirconfig works
135 sh "cp #{lib}/bin/*.dll ../../ext/nokogiri/"
136 sh "mv #{lib} #{lib.split('-').first}"
137 sh "touch #{lib.split('-').first}"
131df0d @tenderlove adding tasks to build cross compiled nokogiri
tenderlove authored
138 end
139 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
140 if Rake::Task.task_defined?(:cross)
141 Rake::Task[:cross].prerequisites << "tmp/cross/#{lib.split('-').first}"
142 end
131df0d @tenderlove adding tasks to build cross compiled nokogiri
tenderlove authored
143 end
144
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
145 require 'tasks/test'
146
4f61ace @flavorjones putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
147 desc "set environment variables to build and/or test with debug options"
148 task :debug do
149 ENV['NOKOGIRI_DEBUG'] = "true"
150 ENV['CFLAGS'] ||= ""
151 ENV['CFLAGS'] += " -DDEBUG"
152 end
153
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
154 if Rake::Task.task_defined?(:cross)
155 task :add_dll_to_manifest do
156 HOE.spec.files += Dir['ext/nokogiri/**.{dll,so}']
454c543 @tenderlove adding fat binary codes
tenderlove authored
157 HOE.spec.files += Dir['ext/nokogiri/{1.8,1.9}/**.{dll,so}']
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
158 end
159
160 Rake::Task[:cross].prerequisites << :add_dll_to_manifest
161 end
162
163 # required_ruby_version
164
165 # Only do this on unix, since we can't build on windows
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
166 unless windows || java
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
167 [:compile, :check_manifest].each do |task_name|
168 Rake::Task[task_name].prerequisites << GENERATED_PARSER
169 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
170 end
c5b6dbf @tenderlove I made our tests mad
tenderlove authored
171
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
172 Rake::Task[:test].prerequisites << :compile
173 ['valgrind', 'valgrind_mem', 'valgrind_mem0', 'coverage'].each do |task_name|
174 Rake::Task["test:#{task_name}"].prerequisites << :compile
175 end
176 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
177
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
178 namespace :install do
179 desc "Install frex and racc for development"
180 task :deps => %w(frex racc)
181
a191ba0 @tenderlove cleaning up rakefile
tenderlove authored
182 task :racc do |t|
183 sh "sudo gem install racc"
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
184 end
185
186 task :frex do
9d4a78e @tenderlove adding some documentation, updating frex requirement
tenderlove authored
187 sh "sudo gem install tenderlove-frex -s http://gems.github.com"
da6292d @jbarnette Make development dependencies easier to install.
jbarnette authored
188 end
189 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
190
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
191 namespace :libxml do
192 desc "What version of LibXML are we building against?"
193 task :version => :compile do
194 sh "#{RUBY} -Ilib:ext -rnokogiri -e 'puts Nokogiri::LIBXML_VERSION'"
195 end
35cace6 @tenderlove fixing up win32 build, adding a few methods to dtd
tenderlove authored
196 end
43686d6 @tenderlove updating rakefile to build before testing
tenderlove authored
197
e7f98b6 @tenderlove initial checkin
tenderlove authored
198 # vim: syntax=Ruby
Something went wrong with that request. Please try again.