root / tags / 0.3 / Rakefile

Revision 10, 2.7 kB (checked in by why, 2 years ago)
  • Rakefile: version 0.2, why not?
Line 
1require 'rake'
2require 'rake/clean'
3require 'rake/gempackagetask'
4require 'rake/rdoctask'
5require 'rake/testtask'
6require 'fileutils'
7include FileUtils
8
9NAME = "hpricot"
10VERS = "0.2"
11CLEAN.include ['ext/hpricot_scan/*.{bundle,so,obj,pdb,lib,def,exp}', 'ext/hpricot_scan/Makefile',
12               '**/.*.sw?', '*.gem', '.config']
13
14desc "Does a full compile, test run"
15task :default => [:compile, :test]
16
17desc "Compiles all extensions"
18task :compile => [:hpricot_scan] do
19  if Dir.glob(File.join("lib","hpricot_scan.*")).length == 0
20    STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
21    STDERR.puts "Gem actually failed to build.  Your system is"
22    STDERR.puts "NOT configured properly to build Mongrel."
23    STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
24    exit(1)
25  end
26end
27
28desc "Packages up Hpricot."
29task :package => [:clean]
30
31desc "Run all the tests"
32Rake::TestTask.new do |t|
33    t.libs << "test"
34    t.test_files = FileList['test/test_*.rb']
35    t.verbose = true
36end
37
38spec =
39    Gem::Specification.new do |s|
40        s.name = NAME
41        s.version = VERS
42        s.platform = Gem::Platform::RUBY
43        s.has_rdoc = false
44        s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
45        s.summary = "a swift, liberal HTML parser with a fantastic library"
46        s.description = s.summary
47        s.author = "why the lucky stiff"
48        s.email = 'why@ruby-lang.org'
49        s.homepage = 'http://code.whytheluckystiff.net/hpricot/'
50
51        s.files = %w(COPYING README Rakefile) +
52          Dir.glob("{bin,doc,test,lib,extras}/**/*") +
53          Dir.glob("ext/**/*.{h,c,rb}")
54       
55        s.require_path = "lib"
56        s.autorequire = "hpricot"
57        s.extensions = FileList["ext/**/extconf.rb"].to_a
58        s.bindir = "bin"
59    end
60
61Rake::GemPackageTask.new(spec) do |p|
62    p.need_tar = true
63    p.gem_spec = spec
64end
65
66extension = "hpricot_scan"
67ext = "ext/hpricot_scan"
68ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
69ext_files = FileList[
70  "#{ext}/*.c",
71  "#{ext}/*.h",
72  "#{ext}/extconf.rb",
73  "#{ext}/Makefile",
74  "lib"
75]
76
77task "lib" do
78  directory "lib"
79end
80
81desc "Builds just the #{extension} extension"
82task extension.to_sym => ["#{ext}/Makefile", ext_so ]
83
84file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
85  Dir.chdir(ext) do ruby "extconf.rb" end
86end
87
88file ext_so => ext_files do
89  Dir.chdir(ext) do
90    sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
91  end
92  cp ext_so, "lib"
93end
94
95desc "Generates the scanner code with Ragel."
96task :ragel do
97  sh %{/usr/local/bin/ragel ext/hpricot_scan/hpricot_scan.rl | /usr/local/bin/rlcodegen -G2 -o ext/hpricot_scan/hpricot_scan.c}
98end
99
100task :install do
101  sh %{rake package}
102  sh %{sudo gem install pkg/#{NAME}-#{VERS}}
103end
104
105task :uninstall => [:clean] do
106  sh %{sudo gem uninstall #{NAME}}
107end
Note: See TracBrowser for help on using the browser.