Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 214 lines (175 sloc) 7.401 kb
e7f98b6 Aaron Patterson initial checkin
tenderlove authored
1 # -*- ruby -*-
cde87f2 Aaron Patterson Revert "fixing segfaults. no more weakrefs"
tenderlove authored
2 require 'rubygems'
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
3
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
4 gem 'hoe'
5 require 'hoe'
6 Hoe.plugin :debugging
7 Hoe.plugin :git
8 Hoe.plugin :gemspec
9 Hoe.plugin :bundler
10 Hoe.add_include_dirs '.' # for ruby 1.9.2
06f7a60 Aaron Patterson vendoring hoe
tenderlove authored
11
702affb Aaron Patterson parser has-a tokenizer
tenderlove authored
12 GENERATED_PARSER = "lib/nokogiri/css/parser.rb"
13 GENERATED_TOKENIZER = "lib/nokogiri/css/tokenizer.rb"
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
14 CROSS_DIR = File.join(File.dirname(__FILE__), 'ports')
e7f98b6 Aaron Patterson initial checkin
tenderlove authored
15
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
16 def java?
17 !! (RUBY_PLATFORM =~ /java/)
18 end
19
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
20 require 'tasks/nokogiri.org'
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
21
18a5f56 Aaron Patterson refactoring and upgrading us to hoe 2.1.0
tenderlove authored
22 HOE = Hoe.spec 'nokogiri' do
8cdda05 Mike Dalessio Rakefile cleanup. Add Yoko to the gemspec's developer list.
flavorjones authored
23 developer 'Aaron Patterson', 'aaronp@rubyforge.org'
24 developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
25 developer 'Yoko Harada', 'yokolet@gmail.com'
b292bbf Mike Dalessio Tim Elliott is a nokogiri-code member!
flavorjones authored
26 developer 'Tim Elliott', 'tle@holymonkey.com'
8cdda05 Mike Dalessio Rakefile cleanup. Add Yoko to the gemspec's developer list.
flavorjones authored
27
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
28 self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
29 self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
30
31 self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
32
33 self.clean_globs += [
fb54cef Mike Dalessio Adding gemspec to clean_globs
flavorjones authored
34 'nokogiri.gemspec',
f329157 Mike Dalessio Ignore build artifacts and de-dupe Hoe.clean_globs
flavorjones authored
35 'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
5648c6b Aaron Patterson clean up fat binary cross compile stuff
tenderlove authored
36 'lib/nokogiri/1.{8,9}',
5c5e1b5 Mike Dalessio Temporarily, let's commit the generated parser and tokenizer code, so th...
flavorjones authored
37 # GENERATED_PARSER,
38 # GENERATED_TOKENIZER
06f7a60 Aaron Patterson vendoring hoe
tenderlove authored
39 ]
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
40
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
41 self.extra_dev_deps += [
7ef23cb Mike Dalessio Updating dev dependencies to include rdoc.
flavorjones authored
42 ["hoe-bundler", ">= 1.1"],
c73b256 Mike Dalessio Updating hoe-debugging version.
flavorjones authored
43 ["hoe-debugging", ">= 1.0.3"],
7ef23cb Mike Dalessio Updating dev dependencies to include rdoc.
flavorjones authored
44 ["hoe-gemspec", ">= 1.0"],
45 ["hoe-git", ">= 1.4"],
46 ["mini_portile", ">= 0.2.2"],
47 ["minitest", "~> 2.2.2"],
4e64e0f Mike Dalessio Include rake as a dev dependency, so we can use bundler with travis-ci.
flavorjones authored
48 ["rake", ">= 0.9"],
68ee05f John Shahid we don't need the if guard for jruby anymore, since the Gemfile constrai...
jvshahid authored
49 ["rake-compiler", "= 0.8.0"],
50 ["racc", ">= 1.4.6"],
51 ["rexical", ">= 1.0.5"]
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
52 ]
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
53
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
54 if java?
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
55 self.spec_extras = { :platform => 'java' }
56 else
c3736e3 Aaron Patterson requiring ruby >= 1.8.7
tenderlove authored
57 self.spec_extras = {
58 :extensions => ["ext/nokogiri/extconf.rb"],
59 :required_ruby_version => '>= 1.8.7'
60 }
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
61 end
d9d1d90 Mike Dalessio telling hoe we're using minitest
flavorjones authored
62
63 self.testlib = :minitest
08450f3 Aaron Patterson auto generating the IDL interface
tenderlove authored
64 end
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
65
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
66 # ----------------------------------------
08450f3 Aaron Patterson auto generating the IDL interface
tenderlove authored
67
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
68 if java?
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
69 # TODO: clean this section up.
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
70 require "rake/javaextensiontask"
71 Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
46513f9 Aaron Patterson removing unused codes
tenderlove authored
72 jruby_home = RbConfig::CONFIG['prefix']
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
73 ext.ext_dir = 'ext/java'
e1423a0 Aaron Patterson specify the lib_dir
tenderlove authored
74 ext.lib_dir = 'lib/nokogiri'
e7e6948 Eric Hodel Shorten long lines
drbrain authored
75 jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
76 ext.classpath = jars.map { |x| File.expand_path x }.join ':'
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
77 end
fe678a1 Eric Hodel Work around rake not understanding platforms, allows Nokogiri to build o...
drbrain authored
78
79 gem_build_path = File.join 'pkg', HOE.spec.full_name
80
89056e7 Mike Dalessio removing code that was working around an old rake bug. (nod to @tmm1)
flavorjones authored
81 task gem_build_path => [:compile] do
8cdda05 Mike Dalessio Rakefile cleanup. Add Yoko to the gemspec's developer list.
flavorjones authored
82 cp 'lib/nokogiri/nokogiri.jar', File.join(gem_build_path, 'lib', 'nokogiri')
449619d Aaron Patterson making sure nokogiri jar is in the packaged gem. THANKS ERIC!!
tenderlove authored
83 HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
84 end
85 else
4338f17 Yoko Harada Tweak for a platform that doesn't have MinGW installed.
yokolet authored
86 mingw_available = true
87 begin
88 require 'tasks/cross_compile'
89 rescue
90 mingw_available = false
91 end
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
92 require "rake/extensiontask"
245c09f Mike Dalessio Omitting java and jar files from the non-jruby gems. Also working around...
flavorjones authored
93
94 HOE.spec.files.reject! { |f| f =~ %r{\.(java|jar)$} }
95
3c11e29 Aaron Patterson partial switch to rake-compiler
tenderlove authored
96 Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 Aaron Patterson making fat binaries easy with nokogiri
tenderlove authored
97 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
98 ext.config_options << ENV['EXTOPTS']
4338f17 Yoko Harada Tweak for a platform that doesn't have MinGW installed.
yokolet authored
99 if mingw_available
100 ext.cross_compile = true
101 ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
102 ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
103 ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes[:libxml2].path, 'lib')}"
104 ext.cross_config_options << "--with-iconv-dir=#{$recipes[:libiconv].path}"
105 ext.cross_config_options << "--with-xslt-dir=#{$recipes[:libxslt].path}"
106 ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
107 end
17aff7b Mike Dalessio tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
108 end
5643860 John Barnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
109 end
110
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
111 # ----------------------------------------
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
112
fb54cef Mike Dalessio Adding gemspec to clean_globs
flavorjones authored
113 desc "Generate css/parser.rb and css/tokenizer.rex"
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
114 task 'generate' => [GENERATED_PARSER, GENERATED_TOKENIZER]
115 task 'gem:spec' => 'generate' if Rake::Task.task_defined?("gem:spec")
08450f3 Aaron Patterson auto generating the IDL interface
tenderlove authored
116
ae80ec1 John Shahid modify the bundler:gemfile task to add the ':platform => :ruby' constrai...
jvshahid authored
117 # This is a big hack to make sure that the racc and rexical
118 # dependencies in the Gemfile are constrainted to ruby platforms
119 # (i.e. MRI and Rubinius). There's no way to do that through hoe,
120 # and any solution will require changing hoe and hoe-bundler.
121 old_gemfile_task = Rake::Task['bundler:gemfile']
122 task 'bundler:gemfile' do
123 old_gemfile_task.invoke
124
125 lines = File.open('Gemfile', 'r') { |f| f.readlines }.map do |line|
126 line =~ /racc|rexical/ ? "#{line.strip}, :platform => :ruby" : line
127 end
128 File.open('Gemfile', 'w') { |f| lines.each { |line| f.puts line } }
129 end
130
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
131 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
0710803 Aaron Patterson switch to RbConfig
tenderlove authored
132 racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
133 racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
753836b Yoko Harada Changes to a better way to find racc command when rvm gemset is used. Th...
yokolet authored
134 racc = %x{command -v racc}.strip if racc.empty?
0066601 Aaron Patterson check_deps ensures that these gems are installed
tenderlove authored
135 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
9246422 Aaron Patterson adding tokenizer and parser
tenderlove authored
136 end
137
138 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
0066601 Aaron Patterson check_deps ensures that these gems are installed
tenderlove authored
139 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
85b1f6d Aaron Patterson starting the move to C
tenderlove authored
140 end
141
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
142 [:compile, :check_manifest].each do |task_name|
143 Rake::Task[task_name].prerequisites << GENERATED_PARSER
144 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
1b2d8e5 Mike Dalessio let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
145 end
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
146
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
147 # ----------------------------------------
148
4f61ace Mike Dalessio putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
149 desc "set environment variables to build and/or test with debug options"
150 task :debug do
151 ENV['NOKOGIRI_DEBUG'] = "true"
152 ENV['CFLAGS'] ||= ""
153 ENV['CFLAGS'] += " -DDEBUG"
154 end
155
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
156 require 'tasks/test'
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
157
7272ba1 John Shahid Turn on remote debugging if we're running the tests in jruby and DEBUG_J...
jvshahid authored
158 task :java_debug do
159 ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
160 end
161
c9fc9c3 John Shahid Add test_18 and test_19 when running in JRuby.
jvshahid authored
162 if java?
163 task :test_18 => :test
164 task :test_19 do
165 ENV['JRUBY_OPTS'] = "--1.9"
166 Rake::Task["test"].invoke
167 end
168 end
169
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
170 Rake::Task[:test].prerequisites << :compile
7272ba1 John Shahid Turn on remote debugging if we're running the tests in jruby and DEBUG_J...
jvshahid authored
171 Rake::Task[:test].prerequisites << :java_debug
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
172 Rake::Task[:test].prerequisites << :check_extra_deps unless java?
c9fc9c3 John Shahid Add test_18 and test_19 when running in JRuby.
jvshahid authored
173
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
174 if Hoe.plugins.include?(:debugging)
175 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
176 Rake::Task["test:#{task_name}"].prerequisites << :compile
1e32e9e Mike Dalessio rake task to run tests with aggressive garbage collection
flavorjones authored
177 end
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
178 end
179
180 # ----------------------------------------
c6cea3c Aaron Patterson fixing up rdoc and adding an rdoc test
tenderlove authored
181
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
182 desc "build a windows gem without all the ceremony."
245c09f Mike Dalessio Omitting java and jar files from the non-jruby gems. Also working around...
flavorjones authored
183 task "gem:windows" => "gem" do
2c9c744 Mike Dalessio build changes and comments
flavorjones authored
184 # TODO: 1.8.7-p358, 1.9.3-p194
d8a7824 Mike Dalessio More tweaking on the windows cross-compilation rake task.
flavorjones authored
185 cross_rubies = ["1.8.7-p330", "1.9.2-p136"]
186 ruby_cc_version = cross_rubies.collect { |_| _.split("-").first }.join(":") # e.g., "1.8.7:1.9.2"
187 rake_compiler_config_path = "#{ENV['HOME']}/.rake-compiler/config.yml"
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
188
d8a7824 Mike Dalessio More tweaking on the windows cross-compilation rake task.
flavorjones authored
189 unless File.exists? rake_compiler_config_path
190 raise "rake-compiler has not installed any cross rubies. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{cross_rubies.first}'"
191 end
192 rake_compiler_config = YAML.load_file(rake_compiler_config_path)
193
194 # check that rake-compiler config contains the right patchlevels. see #279 for background,
195 # and http://blog.mmediasys.com/2011/01/22/rake-compiler-updated-list-of-supported-ruby-versions-for-cross-compilation/
196 # for more up-to-date docs.
197 cross_rubies.each do |version|
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
198 majmin, patchlevel = version.split("-")
199 rbconfig = "rbconfig-#{majmin}"
200 unless rake_compiler_config.key?(rbconfig) && rake_compiler_config[rbconfig] =~ /-#{patchlevel}/
201 raise "rake-compiler '#{rbconfig}' not #{patchlevel}. try running 'env --unset=HOST rake-compiler cross-ruby VERSION=#{version}'"
7a43e2e Mike Dalessio ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
202 end
fd9b773 Aaron Patterson switching nokogiri to rake-compiler
tenderlove authored
203 end
10b09f8 Mike Dalessio added rake task to run test suite in gdb
flavorjones authored
204
d8a7824 Mike Dalessio More tweaking on the windows cross-compilation rake task.
flavorjones authored
205 # verify that --export-all is in the 1.9 rbconfig. see #279,#374,#375.
206 rbconfig_19 = rake_compiler_config["rbconfig-1.9.2"]
207 raise "rbconfig #{rbconfig_19} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_19).split("\n").grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
208
209 pkg_config_path = [:libxslt, :libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
d8a7824 Mike Dalessio More tweaking on the windows cross-compilation rake task.
flavorjones authored
210 sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=#{ruby_cc_version} rake cross native gem") || raise("build failed!")
c7efec6 Mike Dalessio Converted to mini_portile for cross-compiling libraries.
flavorjones authored
211 end
505e91a Mike Dalessio Started cleaning up Rakefile.
flavorjones authored
212
e7f98b6 Aaron Patterson initial checkin
tenderlove authored
213 # vim: syntax=Ruby
Something went wrong with that request. Please try again.