Simplified to find gemspecs for bundled gems (#12709)

* Simplified to find gemspecs for bundled gems

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
This commit is contained in:
Hiroshi SHIBATA 2025-02-07 18:40:07 +09:00 committed by GitHub
parent 8dbbc79e8b
commit 7178593558
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-02-07 09:40:26 +00:00
Merged-By: hsbt <hsbt@ruby-lang.org>

View File

@ -1138,21 +1138,18 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
next unless /^(\S+)\s+(\S+).*/ =~ name next unless /^(\S+)\s+(\S+).*/ =~ name
gem = $1 gem = $1
gem_name = "#$1-#$2" gem_name = "#$1-#$2"
# Try to find the original gemspec file path = [
path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem}.gemspec" # gemspec that removed duplicated dependencies of bundled gems
unless File.exist?(path) "#{srcdir}/.bundle/gems/#{gem_name}/#{gem}.gemspec",
# Try to find the gemspec file for C ext gems # gemspec for C ext gems, It has the original dependencies
# ex .bundle/gems/debug-1.7.1/debug-1.7.1.gemspec # ex .bundle/gems/debug-1.7.1/debug-1.7.1.gemspec
# This gemspec keep the original dependencies "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec",
path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec" # original gemspec generated by rubygems
unless File.exist?(path) "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
# Try to find the gemspec file for gems that hasn't own gemspec ].find { |gemspec| File.exist?(gemspec) }
path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec" if path.nil?
unless File.exist?(path) skipped[gem_name] = "gemspec not found"
skipped[gem_name] = "gemspec not found" next
next
end
end
end end
spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}") spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
unless spec.platform == Gem::Platform::RUBY unless spec.platform == Gem::Platform::RUBY