ext/mkrf_conf_xapian.rb (1177B) - raw
1 require 'rubygems'
2 require 'rubygems/command.rb'
3 require 'rubygems/dependency_installer.rb'
4 require 'rbconfig'
5
6 begin
7 Gem::Command.build_args = ARGV
8 rescue NoMethodError
9 end
10
11 puts "xapian: platform specific dependencies.."
12
13 destination = File.writable?(Gem.dir) ? Gem.dir : Gem.user_dir
14 inst = Gem::DependencyInstaller.new(:install_dir => destination)
15 begin
16
17 if not ENV.include? "SUP_SKIP_XAPIAN_GEM_INSTALL"
18 # update version in Gemfile as well
19 name = "xapian-ruby"
20 version =
21 if /^2\.0\./ =~ RUBY_VERSION
22 ["~> 1.2", "< 1.3.6"]
23 else
24 "~> 1.2"
25 end
26
27 begin
28 # try to load gem
29
30 gem name, version
31 STDERR.puts "xapian: already installed."
32
33 rescue Gem::LoadError
34
35 STDERR.puts "xapian: installing xapian-ruby.."
36 inst.install name, version
37
38 end
39 else
40 STDERR.puts "xapian: you have to install xapian-core and xapian-bindings manually"
41 end
42
43 rescue StandardError => e
44 STDERR.puts "Unable to install #{name} gem: #{e.inspect}"
45 exit(1)
46
47 end
48
49 # create dummy rakefile to indicate success
50 f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
51 f.write("task :default\n")
52 f.close
53