[rubygems/rubygems] Move build artifact detection logic for root gemspec to bundler from Gem::Specification.

Gem::Specification#missing_extension? is heavily called from RubyGems.
  We should reduce extra method call from this place.

https://github.com/rubygems/rubygems/commit/e24e59d44d
This commit is contained in:
Hiroshi SHIBATA 2023-03-13 18:13:15 +09:00 committed by git
parent 3dc8cde700
commit 55a0fbfaf8
2 changed files with 17 additions and 10 deletions

View File

@ -74,6 +74,23 @@ module Gem
end end
end end
alias_method :rg_missing_extensions?, :missing_extensions?
def missing_extensions?
# When we use this methods with local gemspec, we don't handle
# build status of extension correctly. So We need to find extension
# files in require_paths.
# TODO: Gem::Specification couldn't access extension name from extconf.rb
# so we find them with heuristic way. We should improve it.
if source.respond_to?(:root)
return false if (full_require_paths - [extension_dir]).any? do |path|
File.exist?(File.join(path, "#{name}.#{RbConfig::CONFIG['DLEXT']}")) ||
!Dir.glob(File.join(path, name, "*.#{RbConfig::CONFIG['DLEXT']}")).empty?
end
end
rg_missing_extensions?
end
remove_method :gem_dir if instance_methods(false).include?(:gem_dir) remove_method :gem_dir if instance_methods(false).include?(:gem_dir)
def gem_dir def gem_dir
full_gem_path full_gem_path

View File

@ -2184,16 +2184,6 @@ class Gem::Specification < Gem::BasicSpecification
return false if default_gem? return false if default_gem?
return false if File.exist? gem_build_complete_path return false if File.exist? gem_build_complete_path
# When we use this methods with local gemspec, we don't handle
# build status of extension correctly. So We need to find extension
# files in require_paths.
# TODO: Gem::Specification couldn't access extension name from extconf.rb
# so we find them with heuristic way. We should improve it.
return false if (full_require_paths - [extension_dir]).any? do |path|
File.exist?(File.join(path, "#{name}.#{RbConfig::CONFIG['DLEXT']}")) ||
!Dir.glob(File.join(path, name, "*.#{RbConfig::CONFIG['DLEXT']}")).empty?
end
true true
end end