From bece07e6c3716f93c0f2b98159430aa5df51c0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 24 Jan 2024 10:16:48 +0100 Subject: [PATCH] Fix gemspec file list for extension gems So that it also includes requirable features provided by extensions. --- tool/rbinstall.rb | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 62a44af6f9..b13e6d5ba9 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -549,26 +549,44 @@ module RbInstall end def collect - ruby_libraries.sort + libraries.sort end class Ext < self - def ruby_libraries + def libraries # install ext only when it's configured - return [] unless File.exist?("#{makefile_dir}/Makefile") + return [] unless File.exist?(makefile_path) - Dir.glob("lib/**/*.rb", base: makefile_dir) + ruby_libraries + ext_libraries end private + def ruby_libraries + Dir.glob("**/*.rb", base: "#{makefile_dir}/lib") + end + + def ext_libraries + makefile = File.read(makefile_path) + + name = makefile[/^TARGET[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1] + return [] if name.empty? + + feature = makefile[/^DLLIB[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1] + Array(feature.sub("$(TARGET)", name)) + end + + def makefile_path + "#{makefile_dir}/Makefile" + end + def makefile_dir File.expand_path("#{$ext_build_dir}/#{relative_base}", srcdir) end end class Lib < self - def ruby_libraries + def libraries gemname = File.basename(gemspec, ".gemspec") base = relative_base || gemname # for lib/net/net-smtp.gemspec