forked from nrolland/ruby-audio
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathRakefile
81 lines (72 loc) · 2.37 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 'rubygems'
require 'rake'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
require 'rake/extensiontask'
require 'rake/extensioncompiler'
require 'mini_portile'
desc 'Default: run the specs.'
task :default => :spec
# I don't want to depend on bundler, so we do it the bundler way without it
gemspec_path = 'ruby-audio.gemspec'
spec = begin
eval(File.read(File.join(File.dirname(__FILE__), gemspec_path)), TOPLEVEL_BINDING, gemspec_path)
rescue LoadError => e
original_line = e.backtrace.find { |line| line.include?(gemspec_path) }
msg = "There was a LoadError while evaluating #{gemspec_path}:\n #{e.message}"
msg << " from\n #{original_line}" if original_line
msg << "\n"
puts msg
exit
end
$recipes = {}
LIBSNDFILE_VERSION = '1.0.24'
$recipes[:libsndfile] = MiniPortile.new "libsndfile", LIBSNDFILE_VERSION
$recipes[:libsndfile].files << "http://www.mega-nerd.com/libsndfile/files/libsndfile-#{LIBSNDFILE_VERSION}.tar.gz"
$recipes.each { |_, recipe| recipe.host = Rake::ExtensionCompiler.mingw_host }
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', 'spec/spec.opts']
end
desc 'Generate documentation'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = spec.name
rdoc.options += spec.rdoc_options
rdoc.rdoc_files.include(*spec.extra_rdoc_files)
rdoc.rdoc_files.include("lib")
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = false
pkg.need_tar = false
end
Rake::ExtensionTask.new('rubyaudio_ext', spec) do |ext|
if RUBY_PLATFORM =~ /mswin|mingw/ then
# No cross-compile on win, so compile extension to lib/1.[89]
RUBY_VERSION =~ /(\d+\.\d+)/
ext.lib_dir = "lib/#{$1}"
else
ext.cross_compile = true
ext.cross_platform = 'x86-mingw32'
ext.cross_config_options << "--with-sndfile-dir=#{$recipes[:libsndfile].path}"
ext.cross_compiling do |gem_spec|
gem_spec.post_install_message = "You installed the binary version of this gem!"
end
end
end
namespace :cross do
task :libsndfile do
recipe = $recipes[:libsndfile]
checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
unless File.exist?(checkpoint)
recipe.cook
touch checkpoint
end
recipe.activate
end
end
task :cross => ["cross:libsndfile"]
desc "Build gem packages"
task :gems do
sh "rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2"
end