Fix gemspec file list for extension gems

So that it also includes requirable features provided by extensions.
This commit is contained in:
David Rodríguez 2024-01-24 10:16:48 +01:00 committed by Hiroshi SHIBATA
parent 1e6117d665
commit bece07e6c3

View File

@ -549,26 +549,44 @@ module RbInstall
end end
def collect def collect
ruby_libraries.sort libraries.sort
end end
class Ext < self class Ext < self
def ruby_libraries def libraries
# install ext only when it's configured # 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 end
private 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 def makefile_dir
File.expand_path("#{$ext_build_dir}/#{relative_base}", srcdir) File.expand_path("#{$ext_build_dir}/#{relative_base}", srcdir)
end end
end end
class Lib < self class Lib < self
def ruby_libraries def libraries
gemname = File.basename(gemspec, ".gemspec") gemname = File.basename(gemspec, ".gemspec")
base = relative_base || gemname base = relative_base || gemname
# for lib/net/net-smtp.gemspec # for lib/net/net-smtp.gemspec