rbinstall.rb: install files expanded from bundled gems

Although gemspec file (e.g., power_assert and rake) often uses
`git ls-files`, as it does not make sense in other than its own
repository, it has been ignored now.  Gather all files expanded
from the bundled gem to install, instead.
This commit is contained in:
Nobuyoshi Nakada 2020-12-07 19:09:23 +09:00
Родитель 7817a438eb
Коммит 29dee10af2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
1 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -871,7 +871,7 @@ install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do
install_default_gem('ext', srcdir)
end
def load_gemspec(file)
def load_gemspec(file, expanded = false)
file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-")
code.gsub!(/`git.*?`/m, '""')
@ -881,6 +881,18 @@ def load_gemspec(file)
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
end
spec.loaded_from = file
# gather expanded bundled gem files
if expanded
base = File.dirname(file)
Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
next if n.start_with?(".git") # git related files are useless
case File.basename(n); when ".", ".."; next; end
next if File.directory?(File.join(base, n))
spec.files << n
end
end
spec
end
@ -955,7 +967,7 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
gem_name = "#$1-#$2"
path = "#{srcdir}/.bundle/gems/#{gem_name}/#$1.gemspec"
next unless File.exist?(path)
spec = load_gemspec(path)
spec = load_gemspec(path, true)
next unless spec.platform == Gem::Platform::RUBY
next unless spec.full_name == gem_name
spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"