geoffgarside / oniguruma

Re-implementation of the oniguruma gem in pure C. Also aims to be compatible with more versions of Oniguruma

This URL has Read+Write access

oniguruma / Rakefile
100644 102 lines (86 sloc) 2.675 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require 'rake'
require 'rake/testtask'
 
begin
  require 'hanna/rdoctask'
rescue LoadError
  require 'rake/rdoctask'
end
 
begin
  require 'spec/rake/spectask'
rescue LoadError
  puts 'To use rspec for testing you must install rspec gem:'
  puts '$ sudo gem install rspec'
  exit
end
 
begin
  require 'jeweler'
  Jeweler::Tasks.new do |s|
    s.name = 'oniguruma'
    s.summary = 'Oniguruma Regular Expressions bindings'
    s.email = 'geoff-rubygems@geoffgarside.co.uk'
    s.homepage = 'http://github.com/geoffgarside/ruby-oniguruma'
    s.description = "TODO"
    s.authors = ['Geoff Garside']
    s.files = FileList["[A-Z]*.*", "ext/depend", "ext/*.{rb,c,h}",
                      'ext/rb_oniguruma_version.h', "spec/*"]
    s.extensions << 'ext/extconf.rb'
    s.require_paths = ['ext']
  end
rescue LoadError
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
 
desc "Runs the specs in spec/"
Spec::Rake::SpecTask.new do |t|
  t.spec_opts = ['--options', "spec/spec.opts"]
  t.spec_files = FileList['spec/*_spec.rb']
end
 
Rake::RDocTask.new do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title = 'Ruby Oniguruma Bindings'
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files.include('[A-Z]*.txt')
  rdoc.rdoc_files.include('ext/*.[ch]')
end
 
## File build rules
GENERATED_FILES = ['ext/rb_oniguruma_version.h', 'ext/Makefile']
desc "Builds the Makefile for compiling the extension"
file 'ext/Makefile' => 'ext/extconf.rb' do
  Dir.chdir('ext') do
    sh 'ruby extconf.rb'
  end
end
 
desc "Generates the rb_oniguruma_version.h from VERSION.yml file"
file 'ext/rb_oniguruma_version.h' => 'VERSION.yml' do
  version_info = YAML.load_file('VERSION.yml')
  File.open('ext/rb_oniguruma_version.h', 'w') do |f|
    f.write <<-EOF
#ifndef _RB_ONIGURUMA_VERSION_H_
#define _RB_ONIGURUMA_VERSION_H_
 
#define OG_VERSION_MAJOR #{version_info[:major]}
#define OG_VERSION_MINOR #{version_info[:minor]}
#define OG_VERSION_TEENY #{version_info[:patch]}
 
#endif /* _RB_ONIGURUMA_VERSION_H_ */
EOF
  end
end
 
desc "Builds the extension shared library file"
file 'ext/oniguruma.so' => FileList['ext/*.[ch]'].include(GENERATED_FILES) do
  Dir.chdir('ext') do
    sh 'make'
  end
end
 
desc "Rebuilds the extension"
task :recompile => [:clean, :compile]
 
desc "Builds the extension"
task :compile => 'ext/oniguruma.so'
 
desc "Cleans the extension"
task :clean do
  Dir.chdir('ext') do
    sh 'make clean'
    sh 'rm mkmf.log Makefile'
  end
end
 
task :spec => :compile
task :default => :spec
 
## Jeweler Overrides
task 'gemspec:generate' => 'ext/rb_oniguruma_version.h'