summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-02-21 20:30:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-02-22 02:07:59 +0900
commit289080e4d86c70f8231a74a78892b2db65a86e9a (patch)
treee46529c82bb4778930a156b23477a578e7cc1d4c
parent241c4cfdd47c3f5df0738bb636d3f3954101de49 (diff)
Clone and create dummy gemspec in sequential build
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7347
-rw-r--r--common.mk14
-rw-r--r--tool/lib/bundled_gem.rb11
2 files changed, 25 insertions, 0 deletions
diff --git a/common.mk b/common.mk
index 1476910aae..a2318ac708 100644
--- a/common.mk
+++ b/common.mk
@@ -1411,6 +1411,20 @@ extract-gems$(gnumake:yes=-sequential): PHONY
-e 'end' \
gems/bundled_gems
+extract-gems$(gnumake:yes=-sequential): clone-bundled-gems-src
+
+clone-bundled-gems-src: PHONY
+ $(Q) $(BASERUBY) -C "$(srcdir)" \
+ -Itool/lib -rbundled_gem -answ \
+ -e 'BEGIN {git = $$git}' \
+ -e 'gem, _, repo, rev = *$$F' \
+ -e 'next if !rev or /^#/=~gem' \
+ -e 'gemdir = "gems/src/#{gem}"' \
+ -e 'BundledGem.checkout(gemdir, repo, rev, git: git)' \
+ -e 'BundledGem.dummy_gemspec("#{gemdir}/#{gem}.gemspec")' \
+ -- -git="$(GIT)" \
+ gems/bundled_gems
+
outdate-bundled-gems: PHONY
$(Q) $(BASERUBY) $(tooldir)/$@.rb --make="$(MAKE)" --mflags="$(MFLAGS)" "$(srcdir)"
diff --git a/tool/lib/bundled_gem.rb b/tool/lib/bundled_gem.rb
index a08124b679..81549acbdf 100644
--- a/tool/lib/bundled_gem.rb
+++ b/tool/lib/bundled_gem.rb
@@ -83,4 +83,15 @@ module BundledGem
File.write(gemfile, spec.to_ruby)
end
end
+
+ def checkout(gemdir, repo, rev, git: $git)
+ return unless rev
+ unless File.exist?("#{gemdir}/.git")
+ puts "Cloning #{repo}"
+ system("#{git} clone #{repo} #{gemdir}") or raise
+ end
+ puts "Update #{File.basename(gemdir)} to #{rev}"
+ system("#{git} fetch origin #{rev}", chdir: gemdir)
+ system("#{git} checkout --detach #{rev}", chdir: gemdir)
+ end
end