summaryrefslogtreecommitdiff
path: root/Rakefile
blob: 122d470ff9836bdff27a2c8e386377fad5d0c457 (plain)
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
require 'rspec/core/rake_task'
require 'rubygems/package_task'
require 'rake/extensiontask'

Dir[File.expand_path("../*gemspec", __FILE__)].reverse.each do |gemspec_path|
  gemspec = eval(IO.read(gemspec_path))
  Gem::PackageTask.new(gemspec).define
end

require 'ffi_yajl/version'

desc "Run all specs in spec directory"
RSpec::Core::RakeTask.new(:spec) do |t|
  t.pattern = FileList['spec/**/*_spec.rb']
end

desc "Build it and ship it"
task :ship => [:clean, :gem] do
  sh("git tag #{Mixlib::ShellOut::VERSION}")
  sh("git push --tags")
  Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse.each do |built_gem|
    sh("gem push #{built_gem}")
  end
end

unix_gemspec = eval(File.read("ffi-yajl.gemspec"))

task :clean do
  sh "rm -rf pkg/* lib/ffi_yajl/ext/*"
end

desc "install the gem locally"
task :install => [:package] do
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
    sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}-universal-java.gem}
  else
    sh %{gem install pkg/#{unix_gemspec.name}-#{unix_gemspec.version}.gem}
  end
end

spec = Gem::Specification.load('ffi-yajl.gemspec')

Rake::ExtensionTask.new do |ext|
  ext.name = 'libyajl'
  ext.lib_dir = 'lib'
  ext.ext_dir = 'ext/libyajl2'
  ext.gem_spec = spec
end

Rake::ExtensionTask.new do |ext|
  ext.name = 'encoder'
  ext.lib_dir = 'lib/ffi_yajl/ext'
  ext.ext_dir = 'ext/ffi_yajl/ext/encoder'
  ext.gem_spec = spec
end

Rake::ExtensionTask.new do |ext|
  ext.name = 'parser'
  ext.lib_dir = 'lib/ffi_yajl/ext'
  ext.ext_dir = 'ext/ffi_yajl/ext/parser'
  ext.gem_spec = spec
end