Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 158 lines (131 sloc) 4.722 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 dependen...
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 dependen...
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 build o...
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 build o...
drbrain authored
81
82 gem_build_path = File.join 'pkg', HOE.spec.full_name
83
89056e7 @flavorjones removing code that was working around an old rake bug. (nod to @tmm1)
flavorjones authored
84 task gem_build_path => [:compile] do
e7e6948 @drbrain Shorten long lines
drbrain authored
85 cp 'lib/nokogiri/nokogiri.jar',
86 File.join(gem_build_path, 'lib', 'nokogiri'),
87 :verbose => true
449619d @tenderlove making sure nokogiri jar is in the packaged gem. THANKS ERIC!!
tenderlove authored
88 HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
89 end
90 else
91 require "rake/extensiontask"
92 Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
2dd1852 @tenderlove making fat binaries easy with nokogiri
tenderlove authored
93 ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
94
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
95 ext.config_options << ENV['EXTOPTS']
96 ext.cross_compile = true
30d4db7 @tenderlove terrorist version bump
tenderlove authored
97 ext.cross_platform = 'i386-mingw32'
2bdd7e0 @flavorjones i'm sure we'll need to build mswin32 again someday.
flavorjones authored
98 # ext.cross_platform = 'i386-mswin32'
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
99 ext.cross_config_options <<
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
100 "--with-xml2-include=#{File.join(CROSS_DIR, 'include', 'libxml2')}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
101 ext.cross_config_options <<
3c11e29 @tenderlove partial switch to rake-compiler
tenderlove authored
102 "--with-xml2-lib=#{File.join(CROSS_DIR, 'lib')}"
bc89663 @tenderlove updating with cross compiling tasks
tenderlove authored
103 ext.cross_config_options << "--with-iconv-dir=#{CROSS_DIR}"
104 ext.cross_config_options << "--with-xslt-dir=#{CROSS_DIR}"
105 ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
17aff7b @flavorjones tweaking Rakefile to not blow up when running tasks on JRuby
flavorjones authored
106 end
5643860 @jbarnette Add 'rake libxml:version', because I'm lazy.
jbarnette authored
107 end
108
0830357 @tenderlove use the gemspec hoe plugin rather than the rake tasks
tenderlove authored
109 task 'gem:spec' => [ GENERATED_PARSER, GENERATED_TOKENIZER ]
08450f3 @tenderlove auto generating the IDL interface
tenderlove authored
110
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
111 file GENERATED_PARSER => "lib/nokogiri/css/parser.y" do |t|
0710803 @tenderlove switch to RbConfig
tenderlove authored
112 racc = RbConfig::CONFIG['target_os'] =~ /mswin32/ ? '' : `which racc`.strip
113 racc = "#{::RbConfig::CONFIG['bindir']}/racc" if racc.empty?
0066601 @tenderlove check_deps ensures that these gems are installed
tenderlove authored
114 sh "#{racc} -l -o #{t.name} #{t.prerequisites.first}"
9246422 @tenderlove adding tokenizer and parser
tenderlove authored
115 end
116
117 file GENERATED_TOKENIZER => "lib/nokogiri/css/tokenizer.rex" do |t|
0066601 @tenderlove check_deps ensures that these gems are installed
tenderlove authored
118 sh "rex --independent -o #{t.name} #{t.prerequisites.first}"
85b1f6d @tenderlove starting the move to C
tenderlove authored
119 end
120
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
121 require 'tasks/test'
1b2d8e5 @flavorjones let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
122 begin
8560a7a @tenderlove no needto check for java
tenderlove authored
123 require 'tasks/cross_compile'
1b2d8e5 @flavorjones let's be a bit more forgiving of people without the mingw toolchain.
flavorjones authored
124 rescue RuntimeError => e
125 warn "WARNING: Could not perform some cross-compiling: #{e}"
126 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
127
4f61ace @flavorjones putting gdb and valgrind rake tasks under 'test' namespace
flavorjones authored
128 desc "set environment variables to build and/or test with debug options"
129 task :debug do
130 ENV['NOKOGIRI_DEBUG'] = "true"
131 ENV['CFLAGS'] ||= ""
132 ENV['CFLAGS'] += " -DDEBUG"
133 end
134
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
135 # required_ruby_version
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
136
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
137 # Only do this on unix, since we can't build on windows
8d2ec9c @tenderlove remove some checks for java
tenderlove authored
138 unless windows
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
139 [:compile, :check_manifest].each do |task_name|
140 Rake::Task[task_name].prerequisites << GENERATED_PARSER
141 Rake::Task[task_name].prerequisites << GENERATED_TOKENIZER
1e32e9e @flavorjones rake task to run tests with aggressive garbage collection
flavorjones authored
142 end
c6cea3c @tenderlove fixing up rdoc and adding an rdoc test
tenderlove authored
143
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
144 Rake::Task[:test].prerequisites << :compile
6429027 @tenderlove jruby -S rake test will compile and run the tests
tenderlove authored
145 Rake::Task[:test].prerequisites << :check_extra_deps unless java
68967c7 @flavorjones better check for hoe-debugging
flavorjones authored
146 if Hoe.plugins.include?(:debugging)
7a43e2e @flavorjones ensuring rake will run even if hoe-debugging isn't installed
flavorjones authored
147 ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
148 Rake::Task["test:#{task_name}"].prerequisites << :compile
149 end
fd9b773 @tenderlove switching nokogiri to rake-compiler
tenderlove authored
150 end
10b09f8 @flavorjones added rake task to run test suite in gdb
flavorjones authored
151 end
152
05d2538 @jmhodges generating the tokenizer and parser for rip on install
jmhodges authored
153 namespace :rip do
154 task :install => [GENERATED_TOKENIZER, GENERATED_PARSER]
155 end
156
e7f98b6 @tenderlove initial checkin
tenderlove authored
157 # vim: syntax=Ruby
Something went wrong with that request. Please try again.