Skip to content

Commit

Permalink
Update --ext=rust to support compiling the native extension from so…
Browse files Browse the repository at this point in the history
…urce
  • Loading branch information
karreiro committed Apr 26, 2024
1 parent 9312624 commit 1f7fed4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 0 additions & 3 deletions bundler/lib/bundler/templates/newgem/Gemfile.tt
Expand Up @@ -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] -%>

Expand Down
8 changes: 4 additions & 4 deletions bundler/lib/bundler/templates/newgem/newgem.gemspec.tt
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bundler/spec/commands/newgem_spec.rb
Expand Up @@ -1398,7 +1398,7 @@ def create_temporary_dir(dir)
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

Expand Down Expand Up @@ -1458,7 +1458,7 @@ def create_temporary_dir(dir)

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

Expand Down

0 comments on commit 1f7fed4

Please sign in to comment.