-
Notifications
You must be signed in to change notification settings - Fork 3
/
Rakefile
66 lines (59 loc) · 2.04 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
require 'date'
require 'pathname'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'rubygems/package_task'
$rootdir = Pathname.new(__FILE__).dirname
$gemspec = Gem::Specification.new do |s|
s.name = 'http-parser-lite'
s.version = '1.0.1'
s.date = Date.today
s.authors = ['Bharanee Rathna']
s.email = ['[email protected]']
s.summary = 'Simple wrapper around Joyent http-parser'
s.description = 'A lite ruby wrapper around Joyent http-parser'
s.homepage = 'http://github.com/deepfryed/http-parser-lite'
s.files = Dir['ext/**/*.{c,h}'] + Dir['{ext,test,lib}/**/*.rb'] + %w(README.md CHANGELOG)
s.extensions = %w(ext/http-parser/extconf.rb)
s.require_paths = %w(lib ext)
s.add_development_dependency('rake')
s.add_development_dependency('rake-compiler')
end
desc 'Generate gemspec'
task :gemspec do
$gemspec.date = Date.today
File.open('http-parser-lite.gemspec', 'w') {|fh| fh.write($gemspec.to_ruby)}
end
Gem::PackageTask.new($gemspec) do |pkg|
end
desc 'compile extension'
if RUBY_PLATFORM =~ /java/
require 'rake/javaextensiontask'
Rake::JavaExtensionTask.new('http-parser', $gemspec) do |ext|
jruby_home = RbConfig::CONFIG['prefix']
ext.ext_dir = 'ext/http-parser'
ext.lib_dir = 'lib'
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['ext/vendor/*.jar']
ext.classpath = jars.map {|x| File.expand_path x}.join ':'
end
else
task :compile do
Dir.chdir('ext/http-parser') do
system('ruby extconf.rb && make -j2') or raise 'unable to compile http-parser'
end
end
end
Rake::TestTask.new(:test) do |test|
test.libs << 'ext' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
task default: :test
task :test => [:compile]
desc 'tag release and build gem'
task :release => [:test, :gemspec] do
system("git tag -m 'version #{$gemspec.version}' v#{$gemspec.version}") or raise "failed to tag release"
system("rake package")
system("rake java package")
end