mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Append found lib/<file> entries to spec.files to support out-of-place builds
This commit is contained in:
parent
674ddf4b7d
commit
d6b40320b2
Notes:
git
2025-12-11 11:56:49 +00:00
@ -870,16 +870,25 @@ def load_gemspec(file, base = nil, files: nil)
|
||||
code = File.read(file, encoding: "utf-8:-")
|
||||
|
||||
code.gsub!(/^ *#.*/, "")
|
||||
files = files ? files.map(&:dump).join(", ") : ""
|
||||
spec_files = files ? files.map(&:dump).join(", ") : ""
|
||||
code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split(\([^\)]*\))?/m) do
|
||||
"[" + files + "]"
|
||||
"[" + spec_files + "]"
|
||||
end \
|
||||
or
|
||||
code.gsub!(/IO\.popen\(.*git.*?\)/) do
|
||||
"[" + files + "] || itself"
|
||||
"[" + spec_files + "] || itself"
|
||||
end
|
||||
|
||||
spec = eval(code, binding, file)
|
||||
# for out-of-place build
|
||||
collected_files = files ? spec.files.concat(files).uniq : spec.files
|
||||
spec.files = collected_files.map do |f|
|
||||
if !File.exist?(File.join(base || ".", f)) && f.end_with?(".rb")
|
||||
"lib/#{f}"
|
||||
else
|
||||
f
|
||||
end
|
||||
end
|
||||
unless Gem::Specification === spec
|
||||
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user