mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
* 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:
parent
92f3904534
commit
e9ddb1a1f9
2 changed files with 61 additions and 16 deletions
|
@ -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>
|
Thu Aug 4 02:45:10 2011 Kenta Murata <mrkn@mrkn.jp>
|
||||||
|
|
||||||
* configure.in: set CXX variable to the C++ compiler that matches the
|
* configure.in: set CXX variable to the C++ compiler that matches the
|
||||||
|
|
|
@ -532,6 +532,53 @@ install?(:local, :comm, :man) do
|
||||||
end
|
end
|
||||||
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
|
install?(:ext, :comm, :gem) do
|
||||||
$:.unshift(File.join(srcdir, "lib"))
|
$:.unshift(File.join(srcdir, "lib"))
|
||||||
require("rubygems.rb")
|
require("rubygems.rb")
|
||||||
|
@ -550,29 +597,22 @@ install?(:ext, :comm, :gem) do
|
||||||
end
|
end
|
||||||
name, src, execs = *words
|
name, src, execs = *words
|
||||||
next unless name and src
|
next unless name and src
|
||||||
execs ||= []
|
|
||||||
src = File.join(srcdir, src)
|
src = File.join(srcdir, src)
|
||||||
version = open(src) {|f| f.find {|s| /^\s*\w*VERSION\s*=(?!=)/ =~ s}} or next
|
specgen = RbInstall::Specs.generator_for(src).new(name, src, execs || [])
|
||||||
version = version.split(%r"=\s*", 2)[1].strip[/\A([\'\"])(.*?)\1/, 2]
|
gemspec = specgen.gemspec
|
||||||
full_name = "#{name}-#{version}"
|
full_name = "#{gemspec.name}-#{gemspec.version}"
|
||||||
|
|
||||||
puts "#{" "*30}#{name} #{version}"
|
puts "#{" "*30}#{gemspec.name} #{gemspec.version}"
|
||||||
open_for_install(File.join(spec_dir, "#{full_name}.gemspec"), $data_mode) do
|
open_for_install(File.join(spec_dir, "#{full_name}.gemspec"), $data_mode) do
|
||||||
<<-GEMSPEC
|
specgen.spec_source
|
||||||
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
|
end
|
||||||
|
|
||||||
unless execs.empty? then
|
unless gemspec.executables.empty? then
|
||||||
bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
|
bin_dir = File.join(gem_dir, 'gems', full_name, 'bin')
|
||||||
makedirs(bin_dir)
|
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)
|
install(execs, bin_dir, :mode => $prog_mode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue