summaryrefslogtreecommitdiff
path: root/lib/bundler/rubygems_ext.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-03-13 18:13:15 +0900
committergit <svn-admin@ruby-lang.org>2023-03-15 03:35:54 +0000
commit55a0fbfaf855da513e7c8e1234e9edfd51693efa (patch)
treef46ea0706db1965d6bfe69e148397697c7a7587e /lib/bundler/rubygems_ext.rb
parent3dc8cde70078ccb38f5f4b0818ad5eecded01bd5 (diff)
downloadruby-55a0fbfaf855da513e7c8e1234e9edfd51693efa.tar.gz
[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
Diffstat (limited to 'lib/bundler/rubygems_ext.rb')
-rw-r--r--lib/bundler/rubygems_ext.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 0252e1a81a..ff3defa5b4 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -74,6 +74,23 @@ module Gem
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)
def gem_dir
full_gem_path