Skip to content

Commit

Permalink
dep: update to rake-compiler-dock v1.9.1
Browse files Browse the repository at this point in the history
and replace the .cross_rubies file with misc/native.yml
  • Loading branch information
flavorjones committed Jan 20, 2025
1 parent acac18d commit 0994b4e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 66 deletions.
36 changes: 0 additions & 36 deletions .cross_rubies

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ group :development do

# building extensions
gem "rake-compiler", "1.2.9"
gem "rake-compiler-dock", "1.8.0"
gem "rake-compiler-dock", "1.9.1"

# parser generator
gem "rexical", "1.0.8"
Expand Down
16 changes: 16 additions & 0 deletions misc/native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# configuration file for precompiled native gem packaging
platforms:
- aarch64-linux-gnu
- aarch64-linux-musl
- arm64-darwin
- arm-linux-gnu
- arm-linux-musl
- x64-mingw-ucrt
- x86_64-darwin
- x86_64-linux-gnu
- x86_64-linux-musl
rubies:
- "3.4"
- "3.3"
- "3.2"
- "3.1"
1 change: 0 additions & 1 deletion rakelib/check-manifest.rake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ task :check_manifest, [:verbose] do |_, args|
[0-9]*
}
ignore_files = %w[
.cross_rubies
.editorconfig
.gitignore
.gitmodules
Expand Down
17 changes: 8 additions & 9 deletions rakelib/extensions.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require "rbconfig"
require "shellwords"
require "rake_compiler_dock"
require "yaml"

CrossRuby = Struct.new(:version, :platform) do
LINUX_PLATFORM_REGEX = /linux/
Expand Down Expand Up @@ -166,16 +168,14 @@ CrossRuby = Struct.new(:version, :platform) do
end
end

CROSS_RUBIES = File.read(".cross_rubies").split("\n").filter_map do |line|
case line
when /\A([^#]+):([^#]+)/
CrossRuby.new(Regexp.last_match(1), Regexp.last_match(2))
native_config = YAML.load_file("misc/native.yml")
CROSS_RUBIES = native_config["platforms"].flat_map do |platform|
native_config["rubies"].map do |minor|
version = RakeCompilerDock.cross_rubies[minor]
CrossRuby.new(version, platform)
end
end

ENV["RUBY_CC_VERSION"] = CROSS_RUBIES.map(&:ver).uniq.join(":")

require "rake_compiler_dock"
RakeCompilerDock.set_ruby_cc_version(*native_config["rubies"])

def java?
RUBY_PLATFORM.include?("java")
Expand Down Expand Up @@ -375,7 +375,6 @@ if java?
end
else
require "rake/extensiontask"
require "yaml"

dependencies = YAML.load_file("dependencies.yml")

Expand Down
29 changes: 10 additions & 19 deletions scripts/test-gem-file-contents
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "minitest"
gem "rake-compiler-dock", ">= 1.9.1"
end

require "rake_compiler_dock"
require "yaml"

def usage_and_exit(message = nil)
Expand Down Expand Up @@ -68,22 +70,10 @@ require "minitest/autorun"

puts "Testing '#{gemfile}' (#{gemspec.platform})"
describe File.basename(gemfile) do
let(:cross_rubies_path) { File.join(File.dirname(__FILE__), "..", ".cross_rubies") }
let(:native_config) { YAML.load_file(File.join(__dir__, "..", "misc", "native.yml")) }

let(:platform_supported_ruby_versions) do
File.read(cross_rubies_path).split("\n").filter_map do |line|
ver, plat = line.split(":")
next if plat != gemspec.platform.to_s

ver.split(".").take(2).join(".") # ugh
end.uniq.sort
end

let(:all_supported_ruby_versions) do
File.read(cross_rubies_path).split("\n").map do |line|
ver, _ = line.split(":")
ver.split(".").take(2).join(".") # ugh
end.uniq.sort
let(:supported_ruby_versions) do
native_config["rubies"]
end

describe "setup" do
Expand Down Expand Up @@ -194,7 +184,7 @@ describe File.basename(gemfile) do
end

it "contains expected shared library files " do
platform_supported_ruby_versions.each do |version|
supported_ruby_versions.each do |version|
actual = gemfile_contents.find do |p|
File.fnmatch?("lib/nokogiri/#{version}/nokogiri.{so,bundle}", p, File::FNM_EXTGLOB)
end
Expand All @@ -210,15 +200,16 @@ describe File.basename(gemfile) do
File.fnmatch?("lib/nokogiri/**/*.{so,bundle}", p, File::FNM_EXTGLOB)
end
assert_equal(
platform_supported_ruby_versions.length,
supported_ruby_versions.length,
actual.length,
"did not expect extra shared library files",
)
end

it "sets required_ruby_version appropriately" do
unsupported_versions = all_supported_ruby_versions - platform_supported_ruby_versions
platform_supported_ruby_versions.each do |v|
all_supported_ruby_versions = RakeCompilerDock.cross_rubies.keys
unsupported_versions = all_supported_ruby_versions - supported_ruby_versions
supported_ruby_versions.each do |v|
assert(
gemspec.required_ruby_version.satisfied_by?(Gem::Version.new(v)),
"required_ruby_version='#{gemspec.required_ruby_version}' should support ruby #{v}",
Expand Down

0 comments on commit 0994b4e

Please sign in to comment.