summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Carreiro <[email protected]>2024-04-25 21:24:32 +0200
committergit <[email protected]>2024-10-30 23:09:12 +0000
commitc3fea18094988f965cb14ca775c25f757df277b5 (patch)
tree73d892cb883e7f73ea01650bdac55a92af394972
parent22abcce704cf3d82aaa9af5b8ae4e6bf628502ea (diff)
[rubygems/rubygems] Update `--ext=rust` to support compiling the native extension from source
https://github.com/rubygems/rubygems/commit/9b0ec807c7
-rw-r--r--lib/bundler/templates/newgem/Gemfile.tt3
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt8
-rw-r--r--spec/bundler/commands/newgem_spec.rb4
3 files changed, 6 insertions, 9 deletions
diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt
index a0d2ac2826..de82a63c5f 100644
--- a/lib/bundler/templates/newgem/Gemfile.tt
+++ b/lib/bundler/templates/newgem/Gemfile.tt
@@ -9,9 +9,6 @@ gem "rake", "~> 13.0"
<%- if config[:ext] -%>
gem "rake-compiler"
-<%- if config[:ext] == 'rust' -%>
-gem "rb_sys", "~> 0.9.63"
-<%- end -%>
<%- end -%>
<%- if config[:test] -%>
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index 6e88f4dab1..ced300f379 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -37,15 +37,15 @@ Gem::Specification.new do |spec|
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
-<%- if config[:ext] == 'c' -%>
+<%- if config[:ext] == 'c' || config[:ext] == 'rust' -%>
spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
<%- end -%>
-<%- if config[:ext] == 'rust' -%>
- spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"]
-<%- end -%>
# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
+<%- if config[:ext] == 'rust' -%>
+ spec.add_dependency "rb_sys", "~> 0.9.91"
+<%- end -%>
# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 668bc0f95e..9a5bc9c24f 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -1518,7 +1518,7 @@ RSpec.describe "bundle gem" do
it "includes rake-compiler, but no Rust related changes" do
expect(bundled_app("#{gem_name}/Gemfile").read).to include('gem "rake-compiler"')
- expect(bundled_app("#{gem_name}/Gemfile").read).to_not include('gem "rb_sys"')
+ expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to_not include('spec.add_dependency "rb_sys"')
expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to_not include('spec.required_rubygems_version = ">= ')
end
@@ -1578,7 +1578,7 @@ RSpec.describe "bundle gem" do
it "includes rake-compiler, rb_sys gems and required_rubygems_version constraint" do
expect(bundled_app("#{gem_name}/Gemfile").read).to include('gem "rake-compiler"')
- expect(bundled_app("#{gem_name}/Gemfile").read).to include('gem "rb_sys"')
+ expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to include('spec.add_dependency "rb_sys"')
expect(bundled_app("#{gem_name}/#{gem_name}.gemspec").read).to include('spec.required_rubygems_version = ">= ')
end