From 142baf0b1a7ff1cc1314bcca786eb95189691b6d Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sat, 1 Jan 2022 12:51:16 +0100 Subject: [PATCH 1/9] Add fat binary gem support for ruby-3.1 Ruby-3.1-x64 on Windows has a changed platform string "x64-mingw-ucrt" vc. "x64-mingw32". Consequentally rake-compiler-dock has a new corresponding platform image. See https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html Unfortunately the compiler triplet is still "x86_64-w64-mingw32" for both ruby platforms, although the compiled code isn't compatible. Therefore we have to differ by RUBY_PLATFROM instead of the "host" string. --- .cross_rubies | 31 +++++++++++------- ext/nokogiri/extconf.rb | 12 +++++-- nokogiri.gemspec | 2 +- rakelib/extensions.rake | 69 ++++++++++++++++++++++++++++------------- 4 files changed, 76 insertions(+), 38 deletions(-) diff --git a/.cross_rubies b/.cross_rubies index dbb64a4806..d0d7755fba 100644 --- a/.cross_rubies +++ b/.cross_rubies @@ -1,21 +1,28 @@ -3.0.0:i686-w64-mingw32 -3.0.0:x86_64-w64-mingw32 -3.0.0:i686-linux-gnu -3.0.0:x86_64-linux-gnu +3.1.0:x86-mingw32 +3.1.0:x64-mingw-ucrt +3.1.0:x86-linux +3.1.0:x86_64-linux +3.1.0:x86_64-darwin +3.1.0:arm64-darwin +3.1.0:aarch64-linux +3.0.0:x86-mingw32 +3.0.0:x64-mingw32 +3.0.0:x86-linux +3.0.0:x86_64-linux 3.0.0:x86_64-darwin 3.0.0:arm64-darwin 3.0.0:aarch64-linux -2.7.0:i686-w64-mingw32 -2.7.0:x86_64-w64-mingw32 -2.7.0:i686-linux-gnu -2.7.0:x86_64-linux-gnu +2.7.0:x86-mingw32 +2.7.0:x64-mingw32 +2.7.0:x86-linux +2.7.0:x86_64-linux 2.7.0:x86_64-darwin 2.7.0:arm64-darwin 2.7.0:aarch64-linux -2.6.0:i686-w64-mingw32 -2.6.0:x86_64-w64-mingw32 -2.6.0:i686-linux-gnu -2.6.0:x86_64-linux-gnu +2.6.0:x86-mingw32 +2.6.0:x64-mingw32 +2.6.0:x86-linux +2.6.0:x86_64-linux 2.6.0:x86_64-darwin 2.6.0:arm64-darwin 2.6.0:aarch64-linux diff --git a/ext/nokogiri/extconf.rb b/ext/nokogiri/extconf.rb index 3f536cdb63..f4ac18b61b 100644 --- a/ext/nokogiri/extconf.rb +++ b/ext/nokogiri/extconf.rb @@ -176,7 +176,7 @@ def config_system_libraries? end def windows? - RbConfig::CONFIG["target_os"].match?(/mingw32|mswin/) + RbConfig::CONFIG["target_os"].match?(/mingw|mswin/) end def solaris? @@ -413,11 +413,17 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p = true) end MiniPortile.new(name, version).tap do |recipe| + def recipe.port_path + "#{@target}/#{RUBY_PLATFORM}/#{@name}/#{@version}" + end + recipe.target = File.join(PACKAGE_ROOT_DIR, "ports") if cacheable_p - # Prefer host_alias over host in order to use i586-mingw32msvc as + # Prefer host_alias over host in order to use the # correct compiler prefix for cross build, but use host if not set. recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"] recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}" + # The libiconv configure script doesn't accept "arm64" host string but "aarch64" + recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin") yield recipe @@ -473,7 +479,7 @@ def process_recipe(name, version, static_p, cross_p, cacheable_p = true) "#{key}=#{value.strip}" end - checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed" + checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{RUBY_PLATFORM}.installed" if File.exist?(checkpoint) && !recipe.source_directory message("Building Nokogiri with a packaged version of #{name}-#{version}.\n") else diff --git a/nokogiri.gemspec b/nokogiri.gemspec index be61f17aee..4f8ad90577 100644 --- a/nokogiri.gemspec +++ b/nokogiri.gemspec @@ -332,7 +332,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency("minitest-reporters", "~> 1.4") spec.add_development_dependency("rake", "~> 13.0") spec.add_development_dependency("rake-compiler", "= 1.1.6") - spec.add_development_dependency("rake-compiler-dock", "~> 1.1") + spec.add_development_dependency("rake-compiler-dock", "~> 1.2") spec.add_development_dependency("rdoc", "~> 6.3") spec.add_development_dependency("rexical", "~> 1.0.7") spec.add_development_dependency("rubocop", "~> 1.23") diff --git a/rakelib/extensions.rake b/rakelib/extensions.rake index 8a8a69857f..efaf06878f 100644 --- a/rakelib/extensions.rake +++ b/rakelib/extensions.rake @@ -3,8 +3,9 @@ require "rbconfig" require "shellwords" -CrossRuby = Struct.new(:version, :host) do +CrossRuby = Struct.new(:version, :platform) do WINDOWS_PLATFORM_REGEX = /mingw|mswin/ + MINGWUCRT_PLATFORM_REGEX = /mingw-ucrt/ MINGW32_PLATFORM_REGEX = /mingw32/ LINUX_PLATFORM_REGEX = /linux/ X86_LINUX_PLATFORM_REGEX = /x86.*linux/ @@ -40,30 +41,32 @@ CrossRuby = Struct.new(:version, :host) do end end - def platform - @platform ||= case host - when /\Ax86_64.*mingw32/ - "x64-mingw32" - when /\Ai[3-6]86.*mingw32/ - "x86-mingw32" - when /\Ax86_64.*linux/ - "x86_64-linux" - when /\Ai[3-6]86.*linux/ - "x86-linux" - when /\Aaarch64-linux/ + def host + @host ||= case platform + when "x64-mingw-ucrt" + "x86_64-w64-mingw32" + when "x64-mingw32" + "x86_64-w64-mingw32" + when "x86-mingw32" + "i686-w64-mingw32" + when "x86_64-linux" + "x86_64-linux-gnu" + when "x86-linux" + "i686-linux-gnu" + when "aarch64-linux" "aarch64-linux" - when /\Ax86_64-darwin/ + when "x86_64-darwin" "x86_64-darwin" - when /\Aarm64-darwin/ - "arm64-darwin" + when "arm64-darwin" + "aarch64-darwin" else - raise "CrossRuby.platform: unsupported host: #{host}" + raise "CrossRuby.platform: unsupported platform: #{platform}" end end def tool(name) (@binutils_prefix ||= case platform - when "x64-mingw32" + when "x64-mingw-ucrt", "x64-mingw32" "x86_64-w64-mingw32-" when "x86-mingw32" "i686-w64-mingw32-" @@ -71,11 +74,11 @@ CrossRuby = Struct.new(:version, :host) do "x86_64-redhat-linux-" when "x86-linux" "i686-redhat-linux-" - when /a.*64.*linux/ + when "aarch64-linux" "aarch64-linux-gnu-" - when /x86_64.*darwin/ + when "x86_64-darwin" "x86_64-apple-darwin-" - when /a.*64.*darwin/ + when "arm64-darwin" "aarch64-apple-darwin-" else raise "CrossRuby.tool: unmatched platform: #{platform}" @@ -84,7 +87,7 @@ CrossRuby = Struct.new(:version, :host) do def target_file_format case platform - when "x64-mingw32" + when "x64-mingw-ucrt", "x64-mingw32" "pei-x86-64" when "x86-mingw32" "pei-i386" @@ -113,6 +116,8 @@ CrossRuby = Struct.new(:version, :host) do def libruby_dll case platform + when "x64-mingw-ucrt" + "x64-ucrt-ruby#{api_ver_suffix}.dll" when "x64-mingw32" "x64-msvcrt-ruby#{api_ver_suffix}.dll" when "x86-mingw32" @@ -133,6 +138,25 @@ CrossRuby = Struct.new(:version, :host) do "advapi32.dll", libruby_dll, ] + when MINGWUCRT_PLATFORM_REGEX + [ + "kernel32.dll", + "ws2_32.dll", + "advapi32.dll", + "api-ms-win-crt-convert-l1-1-0.dll", + "api-ms-win-crt-environment-l1-1-0.dll", + "api-ms-win-crt-filesystem-l1-1-0.dll", + "api-ms-win-crt-heap-l1-1-0.dll", + "api-ms-win-crt-locale-l1-1-0.dll", + "api-ms-win-crt-math-l1-1-0.dll", + "api-ms-win-crt-private-l1-1-0.dll", + "api-ms-win-crt-runtime-l1-1-0.dll", + "api-ms-win-crt-stdio-l1-1-0.dll", + "api-ms-win-crt-string-l1-1-0.dll", + "api-ms-win-crt-time-l1-1-0.dll", + "api-ms-win-crt-utility-l1-1-0.dll", + libruby_dll, + ] when X86_LINUX_PLATFORM_REGEX [ "libm.so.6", @@ -145,6 +169,7 @@ CrossRuby = Struct.new(:version, :host) do [ "libm.so.6", "libc.so.6", + "libdl.so.2", # on old dists only - now in libc "ld-linux-aarch64.so.1", ].tap do |dlls| dlls << "libpthread.so.0" if ver < "2.6.0" @@ -282,7 +307,7 @@ namespace "gem" do desc "build native gem for #{plat} platform" task plat do RakeCompilerDock.sh(<<~EOT, platform: plat) - rvm use 3.0 && + rvm use 3.1.0 && gem install bundler --no-document && bundle && bundle exec rake gem:#{plat}:builder MAKE='nice make -j`nproc`' From d232e238249653def1dc097e0e2e2df33b54b853 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 4 Jan 2022 16:33:03 -0500 Subject: [PATCH 2/9] ci: test Ruby 3.1 native gem installation --- .github/workflows/gem-install.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gem-install.yml b/.github/workflows/gem-install.yml index a65b5346cf..2db2fb0dcb 100644 --- a/.github/workflows/gem-install.yml +++ b/.github/workflows/gem-install.yml @@ -132,7 +132,7 @@ jobs: strategy: fail-fast: false matrix: - plat: ["x86_64-linux", "x86_64-darwin", "x64-mingw32"] + plat: ["x86_64-linux", "x86_64-darwin", "x64-mingw32", "x64-mingw-ucrt"] runs-on: ubuntu-latest container: image: "larskanis/rake-compiler-dock-mri-${{matrix.plat}}:1.1.0" @@ -156,7 +156,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["2.6", "2.7", "3.0"] + ruby: ["2.6", "2.7", "3.0", "3.1"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -193,7 +193,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["2.6", "2.7", "3.0"] + ruby: ["2.6", "2.7", "3.0", "3.1"] runs-on: macos-latest steps: - uses: actions/checkout@v2 @@ -228,6 +228,26 @@ jobs: gem list -d nokogiri nokogiri -v + cruby-x64-mingw-ucrt-install: + needs: ["cruby-native-package"] + strategy: + fail-fast: false + matrix: + ruby: ["3.1"] + runs-on: windows-2022 + steps: + - uses: MSP-Greg/setup-ruby-pkgs@win-ucrt-2 + with: + ruby-version: "${{matrix.ruby}}" + setup-ruby-ref: MSP-Greg/ruby-setup-ruby/win-ucrt-1 + - uses: actions/download-artifact@v2 + with: + name: cruby-x64-mingw-ucrt-gem + path: gems + - run: | + gem install --verbose --no-document gems/*.gem + gem list -d nokogiri + nokogiri -v jruby-package: name: "jruby-package" From fa5a99d452c4980896e324d15fb09c0378840f39 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Wed, 5 Jan 2022 06:38:16 +0100 Subject: [PATCH 3/9] Adjust tests for rake-compiler-dock-1.2.0 --- .github/workflows/gem-install.yml | 6 +++--- scripts/test-gem-build | 4 ---- scripts/test-gem-file-contents | 10 +++++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/gem-install.yml b/.github/workflows/gem-install.yml index 2db2fb0dcb..483f93101d 100644 --- a/.github/workflows/gem-install.yml +++ b/.github/workflows/gem-install.yml @@ -20,7 +20,7 @@ jobs: name: "cruby-package" runs-on: ubuntu-latest container: - image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.1.0" + image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.2.0" steps: - uses: actions/checkout@v2 with: @@ -135,7 +135,7 @@ jobs: plat: ["x86_64-linux", "x86_64-darwin", "x64-mingw32", "x64-mingw-ucrt"] runs-on: ubuntu-latest container: - image: "larskanis/rake-compiler-dock-mri-${{matrix.plat}}:1.1.0" + image: "larskanis/rake-compiler-dock-mri-${{matrix.plat}}:1.2.0" steps: - uses: actions/checkout@v2 with: @@ -253,7 +253,7 @@ jobs: name: "jruby-package" runs-on: ubuntu-latest container: - image: "larskanis/rake-compiler-dock-jruby:1.1.0" + image: "larskanis/rake-compiler-dock-jruby:1.2.0" steps: - uses: actions/checkout@v2 with: diff --git a/scripts/test-gem-build b/scripts/test-gem-build index eae9574989..8ad58fddc1 100755 --- a/scripts/test-gem-build +++ b/scripts/test-gem-build @@ -14,10 +14,6 @@ BUILD_NATIVE_GEM=$2 test -e /etc/os-release && cat /etc/os-release -if [[ "${BUILD_NATIVE_GEM}" != "java" ]] ; then - rvm use 3.0 # because the default ruby is 2.5 as of rake-compiler-dock 1.1.0 -fi - set -u # TODO remove this stanza once https://github.com/rake-compiler/rake-compiler-dock/pull/57 is diff --git a/scripts/test-gem-file-contents b/scripts/test-gem-file-contents index 4884be237f..ce33c676f9 100755 --- a/scripts/test-gem-file-contents +++ b/scripts/test-gem-file-contents @@ -47,7 +47,7 @@ gemspec = Dir.mktmpdir do |dir| unless system("tar -xf #{gemfile} metadata.gz") raise "could not unpack gem #{gemfile}" end - YAML.load(%x(gunzip -c metadata.gz)) + YAML.safe_load(%x(gunzip -c metadata.gz), permitted_classes: [Gem::Specification, Gem::Version, Gem::Dependency, Gem::Requirement, Time, Symbol]) end end @@ -67,10 +67,14 @@ Minitest::Reporters.use!([Minitest::Reporters::SpecReporter.new]) puts "Testing '#{gemfile}' (#{gemspec.platform})" describe File.basename(gemfile) do let(:cross_rubies_path) { File.join(File.dirname(__FILE__), "..", ".cross_rubies") } + + # Ruby versions that should be supported by the native gem depending on the platform let(:native_ruby_versions) do File.read(cross_rubies_path).split("\n").map do |line| - line.split(":").first.split(".").take(2).join(".") # ugh - end.uniq.sort + ver, plat = line.split(":") + next if plat != gemspec.platform.to_s + ver.split(".").take(2).join(".") # ugh + end.compact.uniq.sort end describe "setup" do From 433850c94c0f42428f66fd38c66737aca7281f80 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Jan 2022 10:56:16 -0500 Subject: [PATCH 4/9] package: work around ruby-maven issue The ruby-maven gem was packaged from commit ef96c08, see https://github.com/jruby/jruby/issues/6904#issuecomment-1005863685 for background information. --- misc/ruby-maven-3.3.12.gem | Bin 0 -> 10240 bytes nokogiri.gemspec | 7 +------ rakelib/extensions.rake | 10 ++++++++-- scripts/test-gem-build | 7 ++++++- test/html5/test_nokogumbo.rb | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 misc/ruby-maven-3.3.12.gem diff --git a/misc/ruby-maven-3.3.12.gem b/misc/ruby-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: [PATCH 5/9] ci: remove workaround for RCD runas https://github.com/rake-compiler/rake-compiler-dock/pull/57 has been shipped in RCD v1.2.0 making this unnecessary. --- scripts/test-gem-build | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/scripts/test-gem-build b/scripts/test-gem-build index a50382e431..eb241ec539 100755 --- a/scripts/test-gem-build +++ b/scripts/test-gem-build @@ -14,18 +14,7 @@ BUILD_NATIVE_GEM=$2 test -e /etc/os-release && cat /etc/os-release -set -u - -# TODO remove this stanza once https://github.com/rake-compiler/rake-compiler-dock/pull/57 is -# shipped in a version of rake-compiler-dock -if [[ "${XRUBIES:-}" != "" ]] ; then - # normally part of rake-compiler-dock "runas" - . /etc/rubybashrc - ln -s /usr/local/rake-compiler "$HOME"/.rake-compiler - export RAKE_EXTENSION_TASK_NO_NATIVE=true -fi - -set -x +set -u -x if [[ "${BUILD_NATIVE_GEM}" == "java" ]] ; then # TODO remove after ruby-maven 3.3.13 or later is shipped From d5584a777536f15a3a5d4a24a69034fe2f0e9061 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Jan 2022 11:54:16 -0500 Subject: [PATCH 6/9] package: move host hack into the libiconv recipe --- ext/nokogiri/extconf.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ext/nokogiri/extconf.rb b/ext/nokogiri/extconf.rb index f4ac18b61b..de0eb548b9 100644 --- a/ext/nokogiri/extconf.rb +++ b/ext/nokogiri/extconf.rb @@ -418,12 +418,10 @@ def recipe.port_path end recipe.target = File.join(PACKAGE_ROOT_DIR, "ports") if cacheable_p - # Prefer host_alias over host in order to use the - # correct compiler prefix for cross build, but use host if not set. + # Prefer host_alias over host in order to use the correct compiler prefix for cross build, but + # use host if not set. recipe.host = RbConfig::CONFIG["host_alias"].empty? ? RbConfig::CONFIG["host"] : RbConfig::CONFIG["host_alias"] recipe.configure_options << "--libdir=#{File.join(recipe.path, "lib")}" - # The libiconv configure script doesn't accept "arm64" host string but "aarch64" - recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin") yield recipe @@ -724,6 +722,9 @@ def compile sha256: dependencies["libiconv"]["sha256"], }] + # The libiconv configure script doesn't accept "arm64" host string but "aarch64" + recipe.host = recipe.host.gsub("arm64-apple-darwin", "aarch64-apple-darwin") + cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g") recipe.configure_options += [ From c6f195aade9313bff1de5c021ec202787f4c28ba Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Jan 2022 11:55:58 -0500 Subject: [PATCH 7/9] style: sort .cross_rubies --- .cross_rubies | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.cross_rubies b/.cross_rubies index d0d7755fba..35488a2a5e 100644 --- a/.cross_rubies +++ b/.cross_rubies @@ -1,28 +1,28 @@ -3.1.0:x86-mingw32 -3.1.0:x64-mingw-ucrt -3.1.0:x86-linux -3.1.0:x86_64-linux -3.1.0:x86_64-darwin -3.1.0:arm64-darwin -3.1.0:aarch64-linux -3.0.0:x86-mingw32 -3.0.0:x64-mingw32 -3.0.0:x86-linux -3.0.0:x86_64-linux -3.0.0:x86_64-darwin -3.0.0:arm64-darwin -3.0.0:aarch64-linux -2.7.0:x86-mingw32 -2.7.0:x64-mingw32 -2.7.0:x86-linux -2.7.0:x86_64-linux -2.7.0:x86_64-darwin -2.7.0:arm64-darwin -2.7.0:aarch64-linux -2.6.0:x86-mingw32 +2.6.0:aarch64-linux +2.6.0:arm64-darwin 2.6.0:x64-mingw32 2.6.0:x86-linux -2.6.0:x86_64-linux +2.6.0:x86-mingw32 2.6.0:x86_64-darwin -2.6.0:arm64-darwin -2.6.0:aarch64-linux +2.6.0:x86_64-linux +2.7.0:aarch64-linux +2.7.0:arm64-darwin +2.7.0:x64-mingw32 +2.7.0:x86-linux +2.7.0:x86-mingw32 +2.7.0:x86_64-darwin +2.7.0:x86_64-linux +3.0.0:aarch64-linux +3.0.0:arm64-darwin +3.0.0:x64-mingw32 +3.0.0:x86-linux +3.0.0:x86-mingw32 +3.0.0:x86_64-darwin +3.0.0:x86_64-linux +3.1.0:aarch64-linux +3.1.0:arm64-darwin +3.1.0:x64-mingw-ucrt +3.1.0:x86-linux +3.1.0:x86-mingw32 +3.1.0:x86_64-darwin +3.1.0:x86_64-linux From a76963c4a6e66f595ba3857db49cd2af5c928055 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Jan 2022 12:06:50 -0500 Subject: [PATCH 8/9] update CHANGELOG with ruby 3.1 native gem support --- CHANGELOG.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4d3b86481..e85d8f7771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,23 +8,27 @@ Nokogiri follows [Semantic Versioning](https://semver.org/), please see the [REA ### Notes +#### Ruby + +This release introduces native gem support for Ruby 3.1. Please note that Windows users should use the `x64-mingw-ucrt` platform gem for Ruby 3.1, and `x64-mingw32` for Ruby 2.6–3.0 (see [RubyInstaller 3.1.0 release notes](https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html)). + +This release ends support for: + +* Ruby 2.5, for which [official support ended 2021-03-31](https://www.ruby-lang.org/en/downloads/branches/). +* JRuby 9.2, which is a Ruby 2.5-compatible release. + + #### Faster, more reliable installation: Native Gem for ARM64 Linux This version of Nokogiri ships experimental native gem support for the `aarch64-linux` platform, which should support AWS Graviton and other ARM Linux platforms. We don't yet have CI running for this platform, and so we're interested in hearing back from y'all whether this is working, and what problems you're seeing. Please send us feedback here: [Feedback: Have you used the `aarch64-linux` native gem?](https://github.com/sparklemotion/nokogiri/discussions/2359) + #### Publishing This version of Nokogiri opts-in to the ["MFA required to publish" setting](https://guides.rubygems.org/mfa-requirement-opt-in/) on Rubygems.org. This and all future Nokogiri gem files must be published to Rubygems by an account with multi-factor authentication enabled. This should provide some additional protection against supply-chain attacks. A related discussion about Trust exists at [#2357](https://github.com/sparklemotion/nokogiri/issues/2357) in which I invite you to participate if you have feelings or opinions on this topic. -#### Ruby - -This release ends support for: - -* Ruby 2.5, for which [official support ended 2021-03-31](https://www.ruby-lang.org/en/downloads/branches/). -* JRuby 9.2, which is a Ruby 2.5-compatible release. - ### Dependencies From 56b89d952cd55daaa3564311e24bb8c9b82476c6 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 5 Jan 2022 15:27:34 -0500 Subject: [PATCH 9/9] package: native win gem correctly specifies required ruby version --- rakelib/extensions.rake | 9 +++++++++ scripts/test-gem-file-contents | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/rakelib/extensions.rake b/rakelib/extensions.rake index 9cbb2fa758..af3a2f6df1 100644 --- a/rakelib/extensions.rake +++ b/rakelib/extensions.rake @@ -405,6 +405,15 @@ else spec.files.reject! { |path| File.fnmatch?("gumbo-parser/**/*", path) } spec.dependencies.reject! { |dep| dep.name == "mini_portile2" } + # I would like rake-compiler to do this, but can't quite figure it out right now + supported_rubies = CROSS_RUBIES.select { |c| spec.platform =~ c.platform } + .map { |c| Gem::Version.new(c.ver) } + .sort + spec.required_ruby_version = [ + ">= #{supported_rubies.first.to_s.split(".").take(2).join(".")}", + "< #{supported_rubies.last.to_s.split(".").take(2).join(".").succ}.dev", + ] + # when pre-compiling a native gem, package all the C headers sitting in ext/nokogiri/include # which were copied there in the $INSTALLFILES section of extconf.rb. # (see scripts/test-gem-file-contents and scripts/test-gem-installation for tests) diff --git a/scripts/test-gem-file-contents b/scripts/test-gem-file-contents index ce33c676f9..08a3c0905f 100755 --- a/scripts/test-gem-file-contents +++ b/scripts/test-gem-file-contents @@ -68,8 +68,7 @@ puts "Testing '#{gemfile}' (#{gemspec.platform})" describe File.basename(gemfile) do let(:cross_rubies_path) { File.join(File.dirname(__FILE__), "..", ".cross_rubies") } - # Ruby versions that should be supported by the native gem depending on the platform - let(:native_ruby_versions) do + let(:platform_supported_ruby_versions) do File.read(cross_rubies_path).split("\n").map do |line| ver, plat = line.split(":") next if plat != gemspec.platform.to_s @@ -77,6 +76,13 @@ describe File.basename(gemfile) do end.compact.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 + end + describe "setup" do it "gemfile contains some files" do actual = gemfile_contents.length @@ -179,7 +185,7 @@ describe File.basename(gemfile) do end it "contains expected shared library files " do - native_ruby_versions.each do |version| + platform_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 @@ -194,7 +200,27 @@ describe File.basename(gemfile) do actual = gemfile_contents.find_all do |p| File.fnmatch?("lib/nokogiri/**/*.{so,bundle}", p, File::FNM_EXTGLOB) end - assert_equal(native_ruby_versions.length, actual.length, "did not expect extra shared library files") + assert_equal( + platform_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| + assert( + gemspec.required_ruby_version.satisfied_by?(Gem::Version.new(v)), + "required_ruby_version='#{gemspec.required_ruby_version}' should support ruby #{v}", + ) + end + unsupported_versions.each do |v| + refute( + gemspec.required_ruby_version.satisfied_by?(Gem::Version.new(v)), + "required_ruby_version='#{gemspec.required_ruby_version}' should not support ruby #{v}", + ) + end end end if gemspec.platform.is_a?(Gem::Platform) && gemspec.platform.cpu