summaryrefslogtreecommitdiff
path: root/tool/rbinstall.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-07 19:09:23 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-07 19:09:23 +0900
commit29dee10af28e5766916ad3aa93401508508d53e2 (patch)
tree725a5840b980fbc3db75f5643885140237f3801d /tool/rbinstall.rb
parent7817a438eb1803e7b3358f43bd1f38479badfbdc (diff)
rbinstall.rb: install files expanded from bundled gems
Although gemspec file (e.g., power_assert and rake) often uses `git ls-files`, as it does not make sense in other than its own repository, it has been ignored now. Gather all files expanded from the bundled gem to install, instead.
Diffstat (limited to 'tool/rbinstall.rb')
-rwxr-xr-xtool/rbinstall.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 7d22a83431..97cde087c6 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -871,7 +871,7 @@ install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do
install_default_gem('ext', srcdir)
end
-def load_gemspec(file)
+def load_gemspec(file, expanded = false)
file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-")
code.gsub!(/`git.*?`/m, '""')
@@ -881,6 +881,18 @@ def load_gemspec(file)
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
end
spec.loaded_from = file
+
+ # gather expanded bundled gem files
+ if expanded
+ base = File.dirname(file)
+ Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
+ next if n.start_with?(".git") # git related files are useless
+ case File.basename(n); when ".", ".."; next; end
+ next if File.directory?(File.join(base, n))
+ spec.files << n
+ end
+ end
+
spec
end
@@ -955,7 +967,7 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
gem_name = "#$1-#$2"
path = "#{srcdir}/.bundle/gems/#{gem_name}/#$1.gemspec"
next unless File.exist?(path)
- spec = load_gemspec(path)
+ spec = load_gemspec(path, true)
next unless spec.platform == Gem::Platform::RUBY
next unless spec.full_name == gem_name
spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"