From 241c4cfdd47c3f5df0738bb636d3f3954101de49 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 21 Feb 2023 18:17:02 +0900 Subject: [PATCH] Move dummy gemspec file creation for extract-gems-sequential --- defs/gmake.mk | 6 ++++++ tool/lib/bundled_gem.rb | 43 +++++++++++++++++------------------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/defs/gmake.mk b/defs/gmake.mk index 9918e01f54..e646968b6f 100644 --- a/defs/gmake.mk +++ b/defs/gmake.mk @@ -352,6 +352,12 @@ $(srcdir)/.bundle/.timestamp/$(1).revision: \ : echo $(3) | $(IFCHANGE) $$(@) - +# The repository of minitest does not include minitest.gemspec because it uses hoe. +# This creates a dummy gemspec. +$(srcdir)/gems/src/$(1)/$(1).gemspec: \ + | $(srcdir)/gems/src/$(1)/.git + $(Q) $(BASERUBY) -I$(tooldir)/lib -rbundled_gem -e 'BundledGem.dummy_gemspec(*ARGV)' $$(@) + $(srcdir)/gems/$(1)-$(2).gem: $(srcdir)/gems/src/$(1)/$(1).gemspec \ $(srcdir)/.bundle/.timestamp/$(1).revision $(ECHO) Building $(1)@$(3) to $$(@) diff --git a/tool/lib/bundled_gem.rb b/tool/lib/bundled_gem.rb index 6b6940b45d..a08124b679 100644 --- a/tool/lib/bundled_gem.rb +++ b/tool/lib/bundled_gem.rb @@ -18,31 +18,6 @@ module BundledGem outdir = File.expand_path(outdir) gemdir, gemfile = File.split(gemspec) Dir.chdir(gemdir) do - if gemspec == "gems/src/minitest/minitest.gemspec" && !File.exist?("minitest.gemspec") - # The repository of minitest does not include minitest.gemspec because it uses hoe. - # This creates a dummy gemspec. - File.write("minitest.gemspec", <, [">= 4.0", "< 7"]) - s.add_development_dependency(%q, ["~> 4.0"]) -end -END - end spec = Gem::Specification.load(gemfile) abort "Failed to load #{gemspec}" unless spec abort "Unexpected version #{spec.version}" unless spec.version == Gem::Version.new(version) @@ -90,4 +65,22 @@ END end FileUtils.rm_rf(Dir.glob("#{gem_dir}/.git*")) end + + def dummy_gemspec(gemspec) + return if File.exist?(gemspec) + gemdir, gemfile = File.split(gemspec) + Dir.chdir(gemdir) do + spec = Gem::Specification.new do |s| + s.name = gemfile.chomp(".gemspec") + s.version = File.read("lib/#{s.name}.rb")[/VERSION = "(.+?)"/, 1] + s.authors = ["DUMMY"] + s.email = ["dummy@ruby-lang.org"] + s.files = Dir.glob("{lib,ext}/**/*").select {|f| File.file?(f)} + s.licenses = ["Ruby"] + s.description = "DO NOT USE; dummy gemspec only for test" + s.summary = "(dummy gemspec)" + end + File.write(gemfile, spec.to_ruby) + end + end end