Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 176 lines (147 sloc) 5.016 kb
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
1 require 'rake'
2 require 'rake/clean'
3 require 'rake/gempackagetask'
4 require 'rake/rdoctask'
55eff8c * test: yeah, some tests.
why authored
5 require 'rake/testtask'
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
6 require 'fileutils'
7 include FileUtils
8
9 NAME = "hpricot"
069bf7a * Rakefile: generate RDoc with the README at front.
why authored
10 REV = `svn info`[/Revision: (\d+)/, 1] rescue nil
dcdc171 * ext/hpricot_scan/hpricot_scan.rl: strip trailing quote from the unquo...
why authored
11 VERS = ENV['VERSION'] || "0.4" + (REV ? ".#{REV}" : "")
55eff8c * test: yeah, some tests.
why authored
12 CLEAN.include ['ext/hpricot_scan/*.{bundle,so,obj,pdb,lib,def,exp}', 'ext/hpricot_scan/Makefile',
13 '**/.*.sw?', '*.gem', '.config']
069bf7a * Rakefile: generate RDoc with the README at front.
why authored
14 RDOC_OPTS = ['--quiet', '--title', 'The Hpricot Reference', '--main', 'README', '--inline-source']
55eff8c * test: yeah, some tests.
why authored
15
16 desc "Does a full compile, test run"
17 task :default => [:compile, :test]
18
19 desc "Compiles all extensions"
20 task :compile => [:hpricot_scan] do
21 if Dir.glob(File.join("lib","hpricot_scan.*")).length == 0
22 STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
23 STDERR.puts "Gem actually failed to build. Your system is"
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
24 STDERR.puts "NOT configured properly to build hpricot."
55eff8c * test: yeah, some tests.
why authored
25 STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
26 exit(1)
27 end
28 end
4478963 * Rakefile: the extension depends on :ragel. updated to 0.3.
why authored
29 task :hpricot_scan => [:ragel]
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
30
31 desc "Packages up Hpricot."
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
32 task :package => [:clean, :ragel]
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
33
484185e * Rakefile: hpricot release goes `VERSION=0.4 rake release`.
why authored
34 desc "Releases packages for all Hpricot packages and platforms."
35 task :release => [:package, :rubygems_win32]
36
55eff8c * test: yeah, some tests.
why authored
37 desc "Run all the tests"
38 Rake::TestTask.new do |t|
39 t.libs << "test"
40 t.test_files = FileList['test/test_*.rb']
41 t.verbose = true
42 end
43
fd482b3 * README: adding docs from the showcase.
why authored
44 Rake::RDocTask.new do |rdoc|
45 rdoc.rdoc_dir = 'doc/rdoc'
069bf7a * Rakefile: generate RDoc with the README at front.
why authored
46 rdoc.options += RDOC_OPTS
fd482b3 * README: adding docs from the showcase.
why authored
47 rdoc.main = "README"
48 rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/**/*.rb']
49 end
50
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
51 spec =
52 Gem::Specification.new do |s|
53 s.name = NAME
ca13188 * Rakefile: make gems off the REVISION number by default.
why authored
54 s.version = VERS
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
55 s.platform = Gem::Platform::RUBY
fd482b3 * README: adding docs from the showcase.
why authored
56 s.has_rdoc = true
069bf7a * Rakefile: generate RDoc with the README at front.
why authored
57 s.rdoc_options += RDOC_OPTS
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
58 s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
59 s.summary = "a swift, liberal HTML parser with a fantastic library"
60 s.description = s.summary
61 s.author = "why the lucky stiff"
62 s.email = 'why@ruby-lang.org'
63 s.homepage = 'http://code.whytheluckystiff.net/hpricot/'
64
6f78f2e * Rakefile: moved mingw-rbconfig.rb to extras subdir.
why authored
65 s.files = %w(COPYING README Rakefile) +
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
66 Dir.glob("{bin,doc,test,lib,extras}/**/*") +
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
67 Dir.glob("ext/**/*.{h,c,rb,rl}") +
68 %w[ext/hpricot_scan/hpricot_scan.c] # needed because it's generated later
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
69
70 s.require_path = "lib"
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
71 #s.autorequire = "hpricot" # no no no this is tHe 3v1l
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
72 s.extensions = FileList["ext/**/extconf.rb"].to_a
73 s.bindir = "bin"
74 end
75
76 Rake::GemPackageTask.new(spec) do |p|
77 p.need_tar = true
78 p.gem_spec = spec
79 end
80
55eff8c * test: yeah, some tests.
why authored
81 extension = "hpricot_scan"
82 ext = "ext/hpricot_scan"
83 ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
84 ext_files = FileList[
85 "#{ext}/*.c",
86 "#{ext}/*.h",
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
87 "#{ext}/*.rl",
55eff8c * test: yeah, some tests.
why authored
88 "#{ext}/extconf.rb",
89 "#{ext}/Makefile",
90 "lib"
91 ]
92
93 task "lib" do
94 directory "lib"
95 end
96
97 desc "Builds just the #{extension} extension"
98 task extension.to_sym => ["#{ext}/Makefile", ext_so ]
99
100 file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
101 Dir.chdir(ext) do ruby "extconf.rb" end
102 end
103
104 file ext_so => ext_files do
105 Dir.chdir(ext) do
106 sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
107 end
108 cp ext_so, "lib"
109 end
110
9628992 * Rakefile: a note on the task which uses Ragel.
why authored
111 desc "Generates the scanner code with Ragel."
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
112 task :ragel do
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
113 sh %{ragel ext/hpricot_scan/hpricot_scan.rl | rlcodegen -G2 -o ext/hpricot_scan/hpricot_scan.c}
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
114 end
115
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
116 PKG_FILES = FileList[
117 "test/**/*.{rb,html,xhtml}",
118 "lib/**/*.rb",
119 "ext/**/*.{c,rb,h,rl}",
120 "CHANGELOG", "README", "Rakefile", "COPYING",
6f78f2e * Rakefile: moved mingw-rbconfig.rb to extras subdir.
why authored
121 "extras/**/*", "lib/hpricot_scan.so"]
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
122
123 Win32Spec = Gem::Specification.new do |s|
124 s.name = NAME
ca13188 * Rakefile: make gems off the REVISION number by default.
why authored
125 s.version = VERS
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
126 s.platform = Gem::Platform::WIN32
127 s.has_rdoc = false
128 s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
129 s.summary = "a swift, liberal HTML parser with a fantastic library"
130 s.description = s.summary
131 s.author = "why the lucky stiff"
132 s.email = 'why@ruby-lang.org'
133 s.homepage = 'http://code.whytheluckystiff.net/hpricot/'
134
135 s.files = PKG_FILES
136
137 s.require_path = "lib"
138 #s.autorequire = "hpricot" # no no no this is tHe 3v1l
139 s.extensions = []
140 s.bindir = "bin"
141 end
142
ca13188 * Rakefile: make gems off the REVISION number by default.
why authored
143 WIN32_PKG_DIR = "hpricot-" + VERS
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
144
145 file WIN32_PKG_DIR => [:package] do
146 sh "tar zxf pkg/#{WIN32_PKG_DIR}.tgz"
147 end
148
149 desc "Cross-compile the hpricot_scan extension for win32"
150 file "hpricot_scan_win32" => [WIN32_PKG_DIR] do
6f78f2e * Rakefile: moved mingw-rbconfig.rb to extras subdir.
why authored
151 cp "extras/mingw-rbconfig.rb", "#{WIN32_PKG_DIR}/ext/hpricot_scan/rbconfig.rb"
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
152 sh "cd #{WIN32_PKG_DIR}/ext/hpricot_scan/ && ruby -I. extconf.rb && make"
153 mv "#{WIN32_PKG_DIR}/ext/hpricot_scan/hpricot_scan.so", "#{WIN32_PKG_DIR}/lib"
154 end
155
156 desc "Build the binary RubyGems package for win32"
157 task :rubygems_win32 => ["hpricot_scan_win32"] do
158 Dir.chdir("#{WIN32_PKG_DIR}") do
159 Gem::Builder.new(Win32Spec).build
160 verbose(true) {
ca13188 * Rakefile: make gems off the REVISION number by default.
why authored
161 mv Dir["*.gem"].first, "../pkg/hpricot-#{VERS}-mswin32.gem"
6bc412c Added rubygems_win32 and related targets. Cross-compiles with MinGW.
batsman authored
162 }
163 end
164 end
165
166 CLEAN.include WIN32_PKG_DIR
167
2668f39 * ext/hpricot_scan: yeay, i got an html scanner written.
why authored
168 task :install do
169 sh %{rake package}
170 sh %{sudo gem install pkg/#{NAME}-#{VERS}}
171 end
172
173 task :uninstall => [:clean] do
174 sh %{sudo gem uninstall #{NAME}}
175 end
Something went wrong with that request. Please try again.