-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
81 lines (68 loc) · 2.59 KB
/
Rakefile
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
require 'rake/clean'
require 'rake/testtask'
require 'rake/rdoctask'
$:.unshift File.expand_path(File.dirname(__FILE__))
$:.unshift File.expand_path(File.dirname(__FILE__), 'lib')
$:.unshift File.expand_path(File.dirname(__FILE__), 'ext')
CLEAN.include '**/*.o'
CLEAN.include "**/*.#{Config::MAKEFILE_CONFIG['DLEXT']}"
CLOBBER.include 'doc'
CLOBBER.include '**/*.log'
CLOBBER.include '**/Makefile'
CLOBBER.include '**/extconf.h'
# Make tasks -----------------------------------------------------
make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make'
MAKECMD = ENV['MAKE_CMD'] || make_program
MAKEOPTS = ENV['MAKE_OPTS'] || ''
RULE_SO = "ext/rule_tagger/rule_tagger.#{Config::MAKEFILE_CONFIG['DLEXT']}"
WORD_SO = "ext/word_tagger/word_tagger.#{Config::MAKEFILE_CONFIG['DLEXT']}"
def make(mod,target = '')
Dir.chdir("ext/#{mod}_tagger") do
pid = system("#{MAKECMD} #{MAKEOPTS} #{target}")
$?.exitstatus
end
end
file 'ext/word_tagger/Makefile' => 'ext/word_tagger/extconf.rb' do
Dir.chdir('ext/word_tagger') { ruby "extconf.rb #{ENV['EXTCONF_OPTS']}" }
end
file 'ext/rule_tagger/Makefile' => 'ext/rule_tagger/extconf.rb' do
Dir.chdir('ext/rule_tagger') { ruby "extconf.rb #{ENV['EXTCONF_OPTS']}" }
end
# Let make handle dependencies between c/o/so - we'll just run it.
file RULE_SO => (['ext/rule_tagger/Makefile','ext/rule_tagger/extconf.rb'] + Dir['ext/rule_tagger/*.cc'] + Dir['ext/rule_tagger/*.h']) do
m = make('rule')
fail "Make failed (status #{m})" unless m == 0
end
file WORD_SO => (['ext/word_tagger/Makefile','ext/rule_tagger/extconf.rb'] + Dir['ext/word_tagger/*.cc'] + Dir['ext/word_tagger/*.h']) do
m = make('word')
fail "Make failed (status #{m})" unless m == 0
end
desc "Compile the shared object"
task :compile => [RULE_SO, WORD_SO]
Rake::TestTask.new(:inttest) do |t|
t.test_files = FileList['test/test_*.rb']
t.verbose = false
end
desc "Test taggers"
task :test => [:compile, :inttest]
task :default => :test
desc 'Generate gem specification'
task :gemspec do
require 'erb'
tspec = ERB.new(File.read(File.join(File.dirname(__FILE__),'lib','rbtagger.gemspec.erb')))
File.open(File.join(File.dirname(__FILE__),'rbtagger.gemspec'),'wb') do|f|
f << tspec.result
end
end
require 'lib/rbtagger/version'
CURRENT_VERSION = RbTagger::VERSION::STRING
desc 'Build gem'
task :package => :gemspec do
require 'rubygems/specification'
spec_source = File.read File.join(File.dirname(__FILE__),'rbtagger.gemspec')
spec = nil
# see: http://gist.github.com/16215
Thread.new { spec = eval("$SAFE = 3\n#{spec_source}") }.join
spec.validate
Gem::Builder.new(spec).build
end