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