Skip to content

Commit b2070b8

Browse files
committed
Build versioned native extension paths for Ruby 3.2-4.0
Install the compiled extension into lib/code_ownership/<major.minor>/ so cross-gem can package multiple Ruby minors into a single platform gem without overwriting.
1 parent a17c309 commit b2070b8

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
/target/
1010
/vendor
1111

12+
# Locally-built native extensions (installed into versioned directories)
13+
/lib/code_ownership/*/
14+
1215
Gemfile.lock
1316

1417
# rspec failure tracking

code_ownership.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
'public gem pushes.'
2222
end
2323

24-
spec.required_ruby_version = '>= 3.2'
24+
spec.required_ruby_version = Gem::Requirement.new('>= 3.2', '< 5')
2525

2626
# https://guides.rubygems.org/make-your-own-gem/#adding-an-executable
2727
# and

ext/code_ownership/extconf.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
require 'mkmf'
44
require 'rb_sys/mkmf'
55

6-
create_rust_makefile('code_ownership/code_ownership') do |ext|
6+
ruby_minor = RUBY_VERSION[/\d+\.\d+/]
7+
create_rust_makefile("code_ownership/#{ruby_minor}/code_ownership") do |ext|
78
ext.extra_cargo_args += ['--crate-type', 'cdylib']
89
ext.extra_cargo_args += ['--package', 'code_ownership']
910
end

rakelib/compile.rake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'rb_sys/extensiontask'
22

33
RbSys::ExtensionTask.new('code_ownership', GEMSPEC) do |ext|
4-
ext.lib_dir = 'lib/code_ownership'
4+
ruby_minor = RUBY_VERSION[/\d+\.\d+/]
5+
ext.lib_dir = "lib/code_ownership/#{ruby_minor}"
56
end

0 commit comments

Comments
 (0)