Consider extensions in gems outside of ext/
This commit is contained in:
parent
2dd2204d8c
commit
ea31228d0c
@ -552,6 +552,23 @@ module RbInstall
|
|||||||
requirable_features.sort
|
requirable_features.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def features_from_makefile(makefile_path)
|
||||||
|
makefile = File.read(makefile_path)
|
||||||
|
|
||||||
|
name = makefile[/^TARGET[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
|
||||||
|
return [] if name.empty?
|
||||||
|
|
||||||
|
feature = makefile[/^DLLIB[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
|
||||||
|
feature = feature.sub("$(TARGET)", name)
|
||||||
|
|
||||||
|
target_prefix = makefile[/^target_prefix[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
|
||||||
|
feature = File.join(target_prefix.delete_prefix("/"), feature) unless target_prefix.empty?
|
||||||
|
|
||||||
|
Array(feature)
|
||||||
|
end
|
||||||
|
|
||||||
class Ext < self
|
class Ext < self
|
||||||
def requirable_features
|
def requirable_features
|
||||||
# install ext only when it's configured
|
# install ext only when it's configured
|
||||||
@ -567,18 +584,7 @@ module RbInstall
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ext_features
|
def ext_features
|
||||||
makefile = File.read(makefile_path)
|
features_from_makefile(makefile_path)
|
||||||
|
|
||||||
name = makefile[/^TARGET[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
|
|
||||||
return [] if name.empty?
|
|
||||||
|
|
||||||
feature = makefile[/^DLLIB[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
|
|
||||||
feature = feature.sub("$(TARGET)", name)
|
|
||||||
|
|
||||||
target_prefix = makefile[/^target_prefix[ \t]*=[ \t]*((?:.*\\\n)*.*)/, 1]
|
|
||||||
feature = File.join(target_prefix.delete_prefix("/"), feature) unless target_prefix.empty?
|
|
||||||
|
|
||||||
Array(feature)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def makefile_path
|
def makefile_path
|
||||||
@ -596,6 +602,12 @@ module RbInstall
|
|||||||
|
|
||||||
class Lib < self
|
class Lib < self
|
||||||
def requirable_features
|
def requirable_features
|
||||||
|
ruby_features + ext_features
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def ruby_features
|
||||||
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
|
||||||
@ -618,6 +630,19 @@ module RbInstall
|
|||||||
files
|
files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ext_features
|
||||||
|
loaded_gemspec = Gem::Specification.load("#{root}/#{gemspec}")
|
||||||
|
extension = loaded_gemspec.extensions.first
|
||||||
|
return [] unless extension
|
||||||
|
|
||||||
|
extconf = File.expand_path(extension, srcdir)
|
||||||
|
ext_build_dir = File.dirname(extconf)
|
||||||
|
makefile_path = "#{ext_build_dir}/Makefile"
|
||||||
|
return [] unless File.exist?(makefile_path)
|
||||||
|
|
||||||
|
features_from_makefile(makefile_path)
|
||||||
|
end
|
||||||
|
|
||||||
def root
|
def root
|
||||||
"#{srcdir}/lib"
|
"#{srcdir}/lib"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user