* tool/rbinstall.rb: use rubygems to load gemspecs, copy actual

gemspecs on install rather than generate fake ones for all gems.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2011-08-03 18:08:57 +00:00
parent 92f3904534
commit e9ddb1a1f9
2 changed files with 61 additions and 16 deletions

View file

@ -1,3 +1,8 @@
Thu Aug 4 03:02:54 2011 Aaron Patterson <aaron@tenderlovemaking.com>
* tool/rbinstall.rb: use rubygems to load gemspecs, copy actual
gemspecs on install rather than generate fake ones for all gems.
Thu Aug 4 02:45:10 2011 Kenta Murata <mrkn@mrkn.jp>
* configure.in: set CXX variable to the C++ compiler that matches the

View file

@ -532,6 +532,53 @@ install?(:local, :comm, :man) do
end
end
# :stopdoc:
module RbInstall
module Specs
class Reader < Struct.new(:name, :src, :execs)
def gemspec
@gemspec ||= begin
Gem::Specification.load(src) || raise("invalid spec in #{src}")
end
end
def spec_source
File.read src
end
end
class Generator < Struct.new(:name, :src, :execs)
def gemspec
@gemspec ||= eval spec_source
end
def spec_source
<<-GEMSPEC
Gem::Specification.new do |s|
s.name = #{name.dump}
s.version = #{version.dump}
s.summary = "This #{name} is bundled with Ruby"
s.executables = #{execs.inspect}
end
GEMSPEC
end
private
def version
version = open(src) { |f|
f.find { |s| /^\s*\w*VERSION\s*=(?!=)/ =~ s }
} or return
version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
end
end
def self.generator_for(file)
File.extname(file) == '.gemspec' ? Reader : Generator
end
end
end
# :startdoc:
install?(:ext, :comm, :gem) do
$:.unshift(File.join(srcdir, "lib"))
require("rubygems.rb")
@ -550,29 +597,22 @@ install?(:ext, :comm, :gem) do
end
name, src, execs = *words
next unless name and src
execs ||= []
src = File.join(srcdir, src)
version = open(src) {|f| f.find {|s| /^\s*\w*VERSION\s*=(?!=)/ =~ s}} or next
version = version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
full_name = "#{name}-#{version}"
puts "#{" "*30}#{name} #{version}"
src = File.join(srcdir, src)
specgen = RbInstall::Specs.generator_for(src).new(name, src, execs || [])
gemspec = specgen.gemspec
full_name = "#{gemspec.name}-#{gemspec.version}"
puts "#{" "*30}#{gemspec.name} #{gemspec.version}"
open_for_install(File.join(spec_dir, "#{full_name}.gemspec"), $data_mode) do
<<-GEMSPEC
Gem::Specification.new do |s|
s.name = #{name.dump}
s.version = #{version.dump}
s.summary = "This #{name} is bundled with Ruby"
s.executables = #{execs.inspect}
end
GEMSPEC
specgen.spec_source
end
unless execs.empty? then
unless gemspec.executables.empty? then
bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
makedirs(bin_dir)
execs = execs.map {|exec| File.join(srcdir, 'bin', exec)}
execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)}
install(execs, bin_dir, :mode => $prog_mode)
end
end