-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[rust gem] Major improvements for gem scaffolding #7608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
b090e96
eccfe06
fca21a6
e368499
264d1d6
3a46d5c
fb32dc2
f7c037e
ac358f4
376ace6
bea50ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pub fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| let _ = rb_sys_env::activate()?; | ||
|
|
||
| Ok(()) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,14 @@ | |
|
|
||
| require_relative "<%= File.basename(config[:namespaced_path]) %>/version" | ||
| <%- if config[:ext] -%> | ||
| require_relative "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>" | ||
| # Attempt to load a versioned extension based on the Ruby version. | ||
| # Fall back to loading the non-versioned extension if version-specific loading fails. | ||
| begin | ||
| RUBY_VERSION =~ /(\d+\.\d+)/ | ||
| require "#{Regexp.last_match(1)}/<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something users frequently stumble on when trying to precompile gems, so let's just use the recommended pattern by rake-compiler as a default: https://github.com/rake-compiler/rake-compiler?tab=readme-ov-file#cross-compilation---the-future-is-now |
||
| rescue LoadError | ||
| require "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>" | ||
| end | ||
| <%- end -%> | ||
|
|
||
| <%- config[:constant_array].each_with_index do |c, i| -%> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,10 +15,6 @@ Gem::Specification.new do |spec| | |
| spec.license = "MIT" | ||
| <%- end -%> | ||
| spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>" | ||
| <%- if config[:ext] == 'rust' -%> | ||
| spec.required_rubygems_version = ">= <%= config[:rust_builder_required_rubygems_version] %>" | ||
| <%- end -%> | ||
|
|
||
| spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" | ||
|
|
||
| spec.metadata["homepage_uri"] = spec.homepage | ||
|
|
@@ -41,7 +37,7 @@ Gem::Specification.new do |spec| | |
| spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"] | ||
| <%- end -%> | ||
| <%- if config[:ext] == 'rust' -%> | ||
| spec.extensions = ["ext/<%= config[:underscored_name] %>/Cargo.toml"] | ||
| spec.add_dependency "rb_sys", "~> 0.9" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| <%- end -%> | ||
|
|
||
| # Uncomment to register a new dependency of your gem | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this, we support
ruby-headout of the box. This allows users to run development/unstable rubies in production without friction