Skip to content
Newer
Older
100644 161 lines (134 sloc) 4.82 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
cfc1419 @tenderlove removing valgrind tasks in favor of a hoe plugin
tenderlove authored
14 # Make sure hoe-debugging is installed
15 Hoe.plugin :debugging
e77c7ff @flavorjones hoe plugin :git
flavorjones authored
16 Hoe.plugin :git
0830357 @tenderlove use the gemspec hoe plugin rather than the rake tasks
tenderlove authored
17 Hoe.plugin :gemspec
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
18
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
19 HOE = Hoe.spec 'nokogiri' do
20 developer('Aaron Patterson', 'aaronp@rubyforge.org')
21 developer('Mike Dalessio', 'mike.dalessio@gmail.com')
22 self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
23 self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
ab5c665 @flavorjones fixing rdoc generation for ext files.
flavorjones authored
24 self.extra_rdoc_files = FileList['*.rdoc','ext/nokogiri/*.c']
18a5f56 @tenderlove refactoring and upgrading us to hoe 2.1.0
tenderlove authored
25 self.clean_globs = [
db2b3db @tenderlove cleaning up some warnings, moving dylib under lib
tenderlove authored
26 'lib/nokogiri/*.{o,so,bundle,a,log,dll}',
5648c6b @tenderlove clean up fat binary cross compile stuff
tenderlove authored
27 'lib/nokogiri/nokogiri.rb',
28 'lib/nokogiri/1.{8,9}',
06f7a60 @tenderlove vendoring hoe
tenderlove authored
29 GENERATED_PARSER,
30 GENERATED_TOKENIZER,
31 'cross',
32 ]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
33
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
34 %w{ racc rexical rake-compiler }.each do |dep|
9ced212 @tenderlove add `check_extra_deps` as a prerequisite to `test`. Deveopment depend…
tenderlove authored
35 extra_dev_deps << [dep, '>= 0']
2c3f433 @tenderlove more rakefile cleanup
tenderlove authored
36 end
9ced212 @tenderlove add `check_extra_deps` as a prerequisite to `test`. Deveopment depend…
tenderlove authored
37 extra_dev_deps << ["minitest", ">= 1.6.0"]
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
38
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
39 if java
40 self.spec_extras = { :platform => 'java' }
fe678a1 @drbrain Work around rake not understanding platforms, allows Nokogiri to buil…
drbrain authored
41 self.need_tar = false # these will be built broken
42 self.need_zip = false
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
43 else
c3736e3 @tenderlove requiring ruby >= 1.8.7
tenderlove authored
44 self.spec_extras = {
45 :extensions => ["ext/nokogiri/extconf.rb"],
46 :required_ruby_version => '>= 1.8.7'
47 }
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
48 end
d9d1d90 @flavorjones telling hoe we're using minitest
flavorjones authored
49
50 self.testlib = :minitest
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
51 end
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
52
31ebd5d @tenderlove adding . to the load path for ruby 1.9.2
tenderlove authored
53 Hoe.add_include_dirs '.'
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
54
94e09cf @tenderlove adding a task for generating the website documentation
tenderlove authored
55 task :ws_docs do
56 title = "#{HOE.name}-#{HOE.version} Documentation"
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
57
94e09cf @tenderlove adding a task for generating the website documentation
tenderlove authored
58 options = []
59 options << "--main=#{HOE.readme_file}"
60 options << '--format=activerecord'
61 options << '--threads=1'
62 options << "--title=#{title.inspect}"
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
63
94e09cf @tenderlove adding a task for generating the website documentation
tenderlove authored
64 options += HOE.spec.require_paths
65 options += HOE.spec.extra_rdoc_files
66 require 'rdoc/rdoc'
67 ENV['RAILS_ROOT'] ||= File.expand_path(File.join('..', 'nokogiri_ws'))
68 RDoc::RDoc.new.document options
541cbeb @tenderlove making NodeSet more consistent with Set, adding NodeSet#| closes #119
tenderlove authored
69 end
70
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
71 gem 'rake-compiler', '>= 0.4.1'
72 if java
73 require "rake/javaextensiontask"
74 Rake::JavaExtensionTask.new("nokogiri", HOE.spec) do |ext|
46513f9 @tenderlove removing unused codes
tenderlove authored
75 jruby_home = RbConfig::CONFIG['prefix']
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
76 ext.ext_dir = 'ext/java'
e1423a0 @tenderlove specify the lib_dir
tenderlove authored
77 ext.lib_dir = 'lib/nokogiri'
e7e6948 @drbrain Shorten long lines
drbrain authored
78 jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
79 ext.classpath = jars.map { |x| File.expand_path x }.join ':'
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
80 end
fe678a1 @drbrain Work around rake not understanding platforms, allows Nokogiri to buil…
drbrain authored
81
82 gem_build_path = File.join 'pkg', HOE.spec.full_name
83 # references to tgz_build_path are to work around a rake bug
84 tgz_build_path = File.join 'pkg', "#{HOE.spec.name}-#{HOE.spec.version}"
85
86 task gem_build_path => [:compile, tgz_build_path] do
87 cp_r tgz_build_path, gem_build_path, :verbose => true
e7e6948 @drbrain Shorten long lines
drbrain authored
88 cp 'lib/nokogiri/nokogiri.jar',
89 File.join(gem_build_path, 'lib', 'nokogiri'),
90 :verbose => true
449619d @tenderlove making sure nokogiri jar is in the packaged gem. THANKS ERIC!!
tenderlove authored
91 HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
92 end
93 else
94 require "rake/extensiontask"
95 Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
96 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
97
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
98 ext.config_options << ENV['EXTOPTS']
99 ext.cross_compile = true
30d4db7 @tenderlove terrorist version bump
tenderlove authored
100 ext.cross_platform = 'i386-mingw32'
2bdd7e0 @flavorjones i'm sure we'll need to build mswin32 again someday.
flavorjones authored
101 # ext.cross_platform = 'i386-mswin32'
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
102 ext.cross_config_options <<
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
103 "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
104 ext.cross_config_options <<
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
105 "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
bc89663 @tenderlove updating with cross compiling tasks
tenderlove authored
106 ext.cross_config_options << "--with-iconv-dir=#{CROSS_DIR}"
107 ext.cross_config_options << "--with-xslt-dir=#{CROSS_DIR}"
108 ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
109 end
5643860 @jbarnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
110 end
111
0830357 @tenderlove use the gemspec hoe plugin rather than the rake tasks
tenderlove authored
112 task 'gem:spec' => [ GENERATED_PARSER, GENERATED_TOKENIZER ]
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
113
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
114 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
0710803 @tenderlove switch to RbConfig
tenderlove authored
115 racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
116 racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
0066601 @tenderlove check_deps ensures that these gems are installed
tenderlove authored
117 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
118 end
119
120 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
0066601 @tenderlove check_deps ensures that these gems are installed
tenderlove authored
121 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
85b1f6d @tenderlove starting the move to C
tenderlove authored
122 end
123
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
124 require 'tasks/test'
1b2d8e5 @flavorjones let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
125 begin
8560a7a @tenderlove no needto check for java
tenderlove authored
126 require 'tasks/cross_compile'
1b2d8e5 @flavorjones let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
127 rescue RuntimeError => e
128 warn "WARNING: Could not perform some cross-compiling: #{e}"
129 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
130
4f61ace @flavorjones putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
131 desc "set environment variables to build and/or test with debug options"
132 task :debug do
133 ENV['NOKOGIRI_DEBUG'] = "true"
134 ENV['CFLAGS'] ||= ""
135 ENV['CFLAGS'] += " -DDEBUG"
136 end
137
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
138 # required_ruby_version
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
139
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
140 # Only do this on unix, since we can't build on windows
8d2ec9c @tenderlove remove some checks for java
tenderlove authored
141 unless windows
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove 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
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
145 end
c6cea3c @tenderlove fixing up rdoc and adding an rdoc test
tenderlove authored
146
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
147 Rake::Task[:test].prerequisites << :compile
6429027 @tenderlove jruby -S rake test will compile and run the tests
tenderlove authored
148 Rake::Task[:test].prerequisites << :check_extra_deps unless java
68967c7 @flavorjones better check for hoe-debugging
flavorjones authored
149 if Hoe.plugins.include?(:debugging)
7a43e2e @flavorjones ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
150 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
151 Rake::Task["test:#{task_name}"].prerequisites << :compile
152 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
153 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
154 end
155
05d2538 @jmhodges generating the tokenizer and parser for rip on install
jmhodges authored
156 namespace :rip do
157 task :install => [GENERATED_TOKENIZER, GENERATED_PARSER]
158 end
159
e7f98b6 @tenderlove initial checkin
tenderlove authored
160 # vim: syntax=Ruby
Something went wrong with that request. Please try again.