diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-12-22 08:20:23 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-12-24 16:57:07 +0900 |
commit | f6620037ba1477d2c337d7b511f094d6d0fbb69c (patch) | |
tree | 4d8d38eaf97e6ca88162dd574e7871e1739f22ae /lib/bundler/cli/gem.rb | |
parent | d5635dfe36588b04d3dd6065ab4e422f51629b11 (diff) |
Merge RubyGems-3.4.0 and Bundler-2.4.0
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6987
Diffstat (limited to 'lib/bundler/cli/gem.rb')
-rw-r--r-- | lib/bundler/cli/gem.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index 40c464cc2c..7f1200f4a0 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -31,6 +31,7 @@ module Bundler @extension = options[:ext] validate_ext_name if @extension + validate_rust_builder_rubygems_version if @extension == "rust" travis_removal_info end @@ -73,6 +74,7 @@ module Bundler :git => use_git, :github_username => github_username.empty? ? "[USERNAME]" : github_username, :required_ruby_version => required_ruby_version, + :rust_builder_required_rubygems_version => rust_builder_required_rubygems_version, :minitest_constant_name => minitest_constant_name, } ensure_safe_gem_name(name, constant_array) @@ -189,14 +191,23 @@ module Bundler templates.merge!("exe/newgem.tt" => "exe/#{name}") if config[:exe] - if extension + if extension == "c" templates.merge!( - "ext/newgem/extconf.rb.tt" => "ext/#{name}/extconf.rb", + "ext/newgem/extconf-c.rb.tt" => "ext/#{name}/extconf.rb", "ext/newgem/newgem.h.tt" => "ext/#{name}/#{underscored_name}.h", "ext/newgem/newgem.c.tt" => "ext/#{name}/#{underscored_name}.c" ) end + if extension == "rust" + templates.merge!( + "Cargo.toml.tt" => "Cargo.toml", + "ext/newgem/Cargo.toml.tt" => "ext/#{name}/Cargo.toml", + "ext/newgem/extconf-rust.rb.tt" => "ext/#{name}/extconf.rb", + "ext/newgem/src/lib.rs.tt" => "ext/#{name}/src/lib.rs", + ) + end + if target.exist? && !target.directory? Bundler.ui.error "Couldn't create a new gem named `#{gem_name}` because there's an existing file named `#{gem_name}`." exit Bundler::BundlerError.all_errors[Bundler::GenericSystemCallError] @@ -415,6 +426,10 @@ module Bundler thor.run(%(#{editor} "#{file}")) end + def rust_builder_required_rubygems_version + "3.3.11" + end + def required_ruby_version "2.6.0" end @@ -427,7 +442,6 @@ module Bundler "1.3" end - # # TODO: remove at next minor release def travis_removal_info if options[:ci] == "travis" @@ -440,5 +454,12 @@ module Bundler exit 1 end end + + def validate_rust_builder_rubygems_version + if Gem::Version.new(rust_builder_required_rubygems_version) > Gem.rubygems_version + Bundler.ui.error "Your RubyGems version (#{Gem.rubygems_version}) is too old to build Rust extension. Please update your RubyGems using `gem update --system` or any other way and try again." + exit 1 + end + end end end |