From e36ce5aa91daa135d06a37ec095bdd2090b81b52 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 21:56:20 +0900 Subject: [PATCH 01/12] This PR deprecates platform the following platform values :mswin, :mswin64, :mingw, :x64_mingw in favor of using :windows. This PR also fully unifies their behavior to be identical to :windows, i.e. they no longer are specific to their given architectures as there are basically no gems which are architecture specific. (We've already done lots of unification of these already with no user pushback and this PR finishes the job.) This PR also deprecates the associated Gem::Platform constants in favor of WINDOWS; these are unlikely to be used externally. --- bundler/lib/bundler/current_ruby.rb | 2 + bundler/lib/bundler/dependency.rb | 10 +- bundler/lib/bundler/dsl.rb | 11 ++ bundler/lib/bundler/rubygems_ext.rb | 16 +-- bundler/spec/bundler/dependency_spec.rb | 130 ++++++++++++------------ 5 files changed, 93 insertions(+), 76 deletions(-) diff --git a/bundler/lib/bundler/current_ruby.rb b/bundler/lib/bundler/current_ruby.rb index 93e0c401c056..784960198723 100644 --- a/bundler/lib/bundler/current_ruby.rb +++ b/bundler/lib/bundler/current_ruby.rb @@ -71,6 +71,8 @@ def truffleruby? def windows? Gem.win_platform? end + + # @deprecated Use windows? instead. These methods will be removed in Rubygems version 4. alias_method :mswin?, :windows? alias_method :mswin64?, :windows? alias_method :mingw?, :windows? diff --git a/bundler/lib/bundler/dependency.rb b/bundler/lib/bundler/dependency.rb index 09a145b8c8eb..1f564342169b 100644 --- a/bundler/lib/bundler/dependency.rb +++ b/bundler/lib/bundler/dependency.rb @@ -17,11 +17,11 @@ class Dependency < Gem::Dependency truffleruby: [Gem::Platform::RUBY], jruby: [Gem::Platform::JAVA, [18, 19]], windows: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS], - # deprecated - mswin: [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS], - mswin64: [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]], - mingw: [Gem::Platform::MINGW, ALL_RUBY_VERSIONS], - x64_mingw: [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]], + # @deprecated Use :windows instead. + mswin: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS], + mswin64: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS - [18]], + mingw: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS], + x64_mingw: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS - [18, 19]], }.each_with_object({}) do |(platform, spec), hash| hash[platform] = spec[0] spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] } diff --git a/bundler/lib/bundler/dsl.rb b/bundler/lib/bundler/dsl.rb index 05c60f2f1aab..b1d03ff8e4b0 100644 --- a/bundler/lib/bundler/dsl.rb +++ b/bundler/lib/bundler/dsl.rb @@ -271,6 +271,7 @@ def install_if(*args) end def platforms(*platforms) + deprecate_legacy_windows_platforms(platforms) @platforms.concat platforms yield ensure @@ -488,6 +489,16 @@ def normalize_source(source) end end + def deprecate_legacy_windows_platforms(platforms) + dep_platforms = Array(platforms).select {|pl| pl.to_s.match?(/mingw|mswin/) } + return if dep_platforms.empty? + + dep_platforms = dep_platforms.map! {|pl| ":#{pl}" }.join(', ') + message = "Platform #{dep_platforms} is deprecated. Please use platform :windows instead." + removed_message = "Platform #{dep_platforms} has been removed. Please use platform :windows instead." + Bundler::SharedHelpers.major_deprecation 3, message, removed_message: removed_message + end + def check_path_source_safety return if @sources.global_path_source.nil? diff --git a/bundler/lib/bundler/rubygems_ext.rb b/bundler/lib/bundler/rubygems_ext.rb index bc7f65c7f7eb..74e5c69df551 100644 --- a/bundler/lib/bundler/rubygems_ext.rb +++ b/bundler/lib/bundler/rubygems_ext.rb @@ -292,15 +292,19 @@ def matching_specs(platform_only = false) class Platform JAVA = Gem::Platform.new("java") - MSWIN = Gem::Platform.new("mswin32") - MSWIN64 = Gem::Platform.new("mswin64") - MINGW = Gem::Platform.new("x86-mingw32") - X64_MINGW = [Gem::Platform.new("x64-mingw32"), - Gem::Platform.new("x64-mingw-ucrt")].freeze - WINDOWS = [MSWIN, MSWIN64, MINGW, X64_MINGW].flatten.freeze + WINDOWS = [Gem::Platform.new("mingw"), + Gem::Platform.new("mingw32"), + Gem::Platform.new("mswin32"), + Gem::Platform.new("mswin64")].freeze X64_LINUX = Gem::Platform.new("x86_64-linux") X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") + # @deprecated Use WINDOWS instead. These constants will be removed in RubyGems 4. + MSWIN = WINDOWS + MSWIN64 = WINDOWS + MINGW = WINDOWS + X64_MINGW = WINDOWS + if X64_LINUX === X64_LINUX_MUSL remove_method :=== diff --git a/bundler/spec/bundler/dependency_spec.rb b/bundler/spec/bundler/dependency_spec.rb index 1185c4e5dd04..c9c9b0693078 100644 --- a/bundler/spec/bundler/dependency_spec.rb +++ b/bundler/spec/bundler/dependency_spec.rb @@ -99,71 +99,71 @@ end let(:deprecated) do - { mswin: Gem::Platform::MSWIN, - mswin_18: Gem::Platform::MSWIN, - mswin_19: Gem::Platform::MSWIN, - mswin_20: Gem::Platform::MSWIN, - mswin_21: Gem::Platform::MSWIN, - mswin_22: Gem::Platform::MSWIN, - mswin_23: Gem::Platform::MSWIN, - mswin_24: Gem::Platform::MSWIN, - mswin_25: Gem::Platform::MSWIN, - mswin_26: Gem::Platform::MSWIN, - mswin_27: Gem::Platform::MSWIN, - mswin_30: Gem::Platform::MSWIN, - mswin_31: Gem::Platform::MSWIN, - mswin_32: Gem::Platform::MSWIN, - mswin_33: Gem::Platform::MSWIN, - mswin_34: Gem::Platform::MSWIN, - mswin_35: Gem::Platform::MSWIN, - mswin64: Gem::Platform::MSWIN64, - mswin64_19: Gem::Platform::MSWIN64, - mswin64_20: Gem::Platform::MSWIN64, - mswin64_21: Gem::Platform::MSWIN64, - mswin64_22: Gem::Platform::MSWIN64, - mswin64_23: Gem::Platform::MSWIN64, - mswin64_24: Gem::Platform::MSWIN64, - mswin64_25: Gem::Platform::MSWIN64, - mswin64_26: Gem::Platform::MSWIN64, - mswin64_27: Gem::Platform::MSWIN64, - mswin64_30: Gem::Platform::MSWIN64, - mswin64_31: Gem::Platform::MSWIN64, - mswin64_32: Gem::Platform::MSWIN64, - mswin64_33: Gem::Platform::MSWIN64, - mswin64_34: Gem::Platform::MSWIN64, - mswin64_35: Gem::Platform::MSWIN64, - mingw: Gem::Platform::MINGW, - mingw_18: Gem::Platform::MINGW, - mingw_19: Gem::Platform::MINGW, - mingw_20: Gem::Platform::MINGW, - mingw_21: Gem::Platform::MINGW, - mingw_22: Gem::Platform::MINGW, - mingw_23: Gem::Platform::MINGW, - mingw_24: Gem::Platform::MINGW, - mingw_25: Gem::Platform::MINGW, - mingw_26: Gem::Platform::MINGW, - mingw_27: Gem::Platform::MINGW, - mingw_30: Gem::Platform::MINGW, - mingw_31: Gem::Platform::MINGW, - mingw_32: Gem::Platform::MINGW, - mingw_33: Gem::Platform::MINGW, - mingw_34: Gem::Platform::MINGW, - mingw_35: Gem::Platform::MINGW, - x64_mingw: Gem::Platform::X64_MINGW, - x64_mingw_20: Gem::Platform::X64_MINGW, - x64_mingw_21: Gem::Platform::X64_MINGW, - x64_mingw_22: Gem::Platform::X64_MINGW, - x64_mingw_23: Gem::Platform::X64_MINGW, - x64_mingw_24: Gem::Platform::X64_MINGW, - x64_mingw_25: Gem::Platform::X64_MINGW, - x64_mingw_26: Gem::Platform::X64_MINGW, - x64_mingw_27: Gem::Platform::X64_MINGW, - x64_mingw_30: Gem::Platform::X64_MINGW, - x64_mingw_31: Gem::Platform::X64_MINGW, - x64_mingw_32: Gem::Platform::X64_MINGW, - x64_mingw_33: Gem::Platform::X64_MINGW, - x64_mingw_34: Gem::Platform::X64_MINGW, - x64_mingw_35: Gem::Platform::X64_MINGW } + { mswin: Gem::Platform::WINDOWS, + mswin_18: Gem::Platform::WINDOWS, + mswin_19: Gem::Platform::WINDOWS, + mswin_20: Gem::Platform::WINDOWS, + mswin_21: Gem::Platform::WINDOWS, + mswin_22: Gem::Platform::WINDOWS, + mswin_23: Gem::Platform::WINDOWS, + mswin_24: Gem::Platform::WINDOWS, + mswin_25: Gem::Platform::WINDOWS, + mswin_26: Gem::Platform::WINDOWS, + mswin_27: Gem::Platform::WINDOWS, + mswin_30: Gem::Platform::WINDOWS, + mswin_31: Gem::Platform::WINDOWS, + mswin_32: Gem::Platform::WINDOWS, + mswin_33: Gem::Platform::WINDOWS, + mswin_34: Gem::Platform::WINDOWS, + mswin_35: Gem::Platform::WINDOWS, + mswin64: Gem::Platform::WINDOWS, + mswin64_19: Gem::Platform::WINDOWS, + mswin64_20: Gem::Platform::WINDOWS, + mswin64_21: Gem::Platform::WINDOWS, + mswin64_22: Gem::Platform::WINDOWS, + mswin64_23: Gem::Platform::WINDOWS, + mswin64_24: Gem::Platform::WINDOWS, + mswin64_25: Gem::Platform::WINDOWS, + mswin64_26: Gem::Platform::WINDOWS, + mswin64_27: Gem::Platform::WINDOWS, + mswin64_30: Gem::Platform::WINDOWS, + mswin64_31: Gem::Platform::WINDOWS, + mswin64_32: Gem::Platform::WINDOWS, + mswin64_33: Gem::Platform::WINDOWS, + mswin64_34: Gem::Platform::WINDOWS, + mswin64_35: Gem::Platform::WINDOWS, + mingw: Gem::Platform::WINDOWS, + mingw_18: Gem::Platform::WINDOWS, + mingw_19: Gem::Platform::WINDOWS, + mingw_20: Gem::Platform::WINDOWS, + mingw_21: Gem::Platform::WINDOWS, + mingw_22: Gem::Platform::WINDOWS, + mingw_23: Gem::Platform::WINDOWS, + mingw_24: Gem::Platform::WINDOWS, + mingw_25: Gem::Platform::WINDOWS, + mingw_26: Gem::Platform::WINDOWS, + mingw_27: Gem::Platform::WINDOWS, + mingw_30: Gem::Platform::WINDOWS, + mingw_31: Gem::Platform::WINDOWS, + mingw_32: Gem::Platform::WINDOWS, + mingw_33: Gem::Platform::WINDOWS, + mingw_34: Gem::Platform::WINDOWS, + mingw_35: Gem::Platform::WINDOWS, + x64_mingw: Gem::Platform::WINDOWS, + x64_mingw_20: Gem::Platform::WINDOWS, + x64_mingw_21: Gem::Platform::WINDOWS, + x64_mingw_22: Gem::Platform::WINDOWS, + x64_mingw_23: Gem::Platform::WINDOWS, + x64_mingw_24: Gem::Platform::WINDOWS, + x64_mingw_25: Gem::Platform::WINDOWS, + x64_mingw_26: Gem::Platform::WINDOWS, + x64_mingw_27: Gem::Platform::WINDOWS, + x64_mingw_30: Gem::Platform::WINDOWS, + x64_mingw_31: Gem::Platform::WINDOWS, + x64_mingw_32: Gem::Platform::WINDOWS, + x64_mingw_33: Gem::Platform::WINDOWS, + x64_mingw_34: Gem::Platform::WINDOWS, + x64_mingw_35: Gem::Platform::WINDOWS } end # rubocop:enable Naming/VariableNumber From 9ae0087bf7b0daf55539e70c49afd3c81785818a Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 22:04:22 +0900 Subject: [PATCH 02/12] Fix lint --- bundler/lib/bundler/dsl.rb | 2 +- bundler/lib/bundler/rubygems_ext.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundler/lib/bundler/dsl.rb b/bundler/lib/bundler/dsl.rb index b1d03ff8e4b0..ee7ba7bdefc5 100644 --- a/bundler/lib/bundler/dsl.rb +++ b/bundler/lib/bundler/dsl.rb @@ -493,7 +493,7 @@ def deprecate_legacy_windows_platforms(platforms) dep_platforms = Array(platforms).select {|pl| pl.to_s.match?(/mingw|mswin/) } return if dep_platforms.empty? - dep_platforms = dep_platforms.map! {|pl| ":#{pl}" }.join(', ') + dep_platforms = dep_platforms.map! {|pl| ":#{pl}" }.join(", ") message = "Platform #{dep_platforms} is deprecated. Please use platform :windows instead." removed_message = "Platform #{dep_platforms} has been removed. Please use platform :windows instead." Bundler::SharedHelpers.major_deprecation 3, message, removed_message: removed_message diff --git a/bundler/lib/bundler/rubygems_ext.rb b/bundler/lib/bundler/rubygems_ext.rb index 74e5c69df551..6aa9e6bcd0d0 100644 --- a/bundler/lib/bundler/rubygems_ext.rb +++ b/bundler/lib/bundler/rubygems_ext.rb @@ -291,7 +291,7 @@ def matching_specs(platform_only = false) require "rubygems/platform" class Platform - JAVA = Gem::Platform.new("java") + JAVA = Gem::Platform.new("java") WINDOWS = [Gem::Platform.new("mingw"), Gem::Platform.new("mingw32"), Gem::Platform.new("mswin32"), From ebf3eb0cdf61407580571ab6a447bb1659bcd217 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 22:49:58 +0900 Subject: [PATCH 03/12] Introduce "windows" as a generic platform --- bundler/lib/bundler/gem_helpers.rb | 12 +++++------- bundler/lib/bundler/rubygems_ext.rb | 7 ++++--- lib/rubygems.rb | 1 + 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bundler/lib/bundler/gem_helpers.rb b/bundler/lib/bundler/gem_helpers.rb index 75243873f26c..29ac1d6e3117 100644 --- a/bundler/lib/bundler/gem_helpers.rb +++ b/bundler/lib/bundler/gem_helpers.rb @@ -5,13 +5,11 @@ module GemHelpers GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant GENERICS = [ [Gem::Platform.new("java"), Gem::Platform.new("java")], - [Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")], - [Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")], - [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")], - [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")], - [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")], - [Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")], - [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")], + [Gem::Platform.new("windows"), Gem::Platform.new("windows")], + [Gem::Platform.new("mswin32"), Gem::Platform.new("windows")], + [Gem::Platform.new("mswin64"), Gem::Platform.new("windows")], + [Gem::Platform.new("mingw32"), Gem::Platform.new("windows")], + [Gem::Platform.new("mingw"), Gem::Platform.new("windows")] ].freeze def generic(p) diff --git a/bundler/lib/bundler/rubygems_ext.rb b/bundler/lib/bundler/rubygems_ext.rb index 6aa9e6bcd0d0..f467f4a2589f 100644 --- a/bundler/lib/bundler/rubygems_ext.rb +++ b/bundler/lib/bundler/rubygems_ext.rb @@ -292,10 +292,11 @@ def matching_specs(platform_only = false) class Platform JAVA = Gem::Platform.new("java") - WINDOWS = [Gem::Platform.new("mingw"), - Gem::Platform.new("mingw32"), + WINDOWS = [Gem::Platform.new("windows"), Gem::Platform.new("mswin32"), - Gem::Platform.new("mswin64")].freeze + Gem::Platform.new("mswin64"), + Gem::Platform.new("mingw32"), + Gem::Platform.new("mingw")].freeze X64_LINUX = Gem::Platform.new("x86_64-linux") X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 5951dfe05b5e..210738bd3182 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -120,6 +120,7 @@ module Gem # An Array of Regexps that match windows Ruby platforms. WIN_PATTERNS = [ + /windows/i, /bccwin/i, /cygwin/i, /djgpp/i, From 7fdfb92524fd643aa5d3d91bb8cdbecfe25961a4 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 22:54:20 +0900 Subject: [PATCH 04/12] Lint --- bundler/lib/bundler/gem_helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/lib/bundler/gem_helpers.rb b/bundler/lib/bundler/gem_helpers.rb index 29ac1d6e3117..4d5044d5a51b 100644 --- a/bundler/lib/bundler/gem_helpers.rb +++ b/bundler/lib/bundler/gem_helpers.rb @@ -9,7 +9,7 @@ module GemHelpers [Gem::Platform.new("mswin32"), Gem::Platform.new("windows")], [Gem::Platform.new("mswin64"), Gem::Platform.new("windows")], [Gem::Platform.new("mingw32"), Gem::Platform.new("windows")], - [Gem::Platform.new("mingw"), Gem::Platform.new("windows")] + [Gem::Platform.new("mingw"), Gem::Platform.new("windows")], ].freeze def generic(p) From b515ee72527481faea6dd7ed504dcca675bbdf3d Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:00:39 +0900 Subject: [PATCH 05/12] Revert change --- lib/rubygems.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 210738bd3182..5951dfe05b5e 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -120,7 +120,6 @@ module Gem # An Array of Regexps that match windows Ruby platforms. WIN_PATTERNS = [ - /windows/i, /bccwin/i, /cygwin/i, /djgpp/i, From be2dcebbbeb64be4e0e3f0c57074032418b7c6c2 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:05:17 +0900 Subject: [PATCH 06/12] Cleanup --- bundler/lib/bundler/rubygems_ext.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bundler/lib/bundler/rubygems_ext.rb b/bundler/lib/bundler/rubygems_ext.rb index f467f4a2589f..be571f160d5e 100644 --- a/bundler/lib/bundler/rubygems_ext.rb +++ b/bundler/lib/bundler/rubygems_ext.rb @@ -292,19 +292,20 @@ def matching_specs(platform_only = false) class Platform JAVA = Gem::Platform.new("java") - WINDOWS = [Gem::Platform.new("windows"), - Gem::Platform.new("mswin32"), - Gem::Platform.new("mswin64"), - Gem::Platform.new("mingw32"), - Gem::Platform.new("mingw")].freeze + WINDOWS = Gem::Platform.new("windows") X64_LINUX = Gem::Platform.new("x86_64-linux") X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") # @deprecated Use WINDOWS instead. These constants will be removed in RubyGems 4. - MSWIN = WINDOWS - MSWIN64 = WINDOWS - MINGW = WINDOWS - X64_MINGW = WINDOWS + MSWIN = Gem::Platform.new("mswin32") + MSWIN64 = Gem::Platform.new("mswin64") + MINGW = Gem::Platform.new("x86-mingw32") + X64_MINGW = [Gem::Platform.new("x64-mingw32"), + Gem::Platform.new("x64-mingw-ucrt")].freeze + deprecate_constant :MSWIN + deprecate_constant :MSWIN64 + deprecate_constant :MINGW + deprecate_constant :X64_MINGW if X64_LINUX === X64_LINUX_MUSL remove_method :=== From affccbe289b79a232fb58023b43afde8e4575b59 Mon Sep 17 00:00:00 2001 From: Johnny Shields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:06:13 +0900 Subject: [PATCH 07/12] Update gem_helpers.rb --- bundler/lib/bundler/gem_helpers.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/bundler/lib/bundler/gem_helpers.rb b/bundler/lib/bundler/gem_helpers.rb index 4d5044d5a51b..795bb576e1bb 100644 --- a/bundler/lib/bundler/gem_helpers.rb +++ b/bundler/lib/bundler/gem_helpers.rb @@ -5,7 +5,6 @@ module GemHelpers GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant GENERICS = [ [Gem::Platform.new("java"), Gem::Platform.new("java")], - [Gem::Platform.new("windows"), Gem::Platform.new("windows")], [Gem::Platform.new("mswin32"), Gem::Platform.new("windows")], [Gem::Platform.new("mswin64"), Gem::Platform.new("windows")], [Gem::Platform.new("mingw32"), Gem::Platform.new("windows")], From 11ea0beb8c870c381f10e772ee7a31c0572b382b Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:12:57 +0900 Subject: [PATCH 08/12] Fix specs --- bundler/spec/other/ext_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bundler/spec/other/ext_spec.rb b/bundler/spec/other/ext_spec.rb index 9fc0414b4d33..74dadf2bb723 100644 --- a/bundler/spec/other/ext_spec.rb +++ b/bundler/spec/other/ext_spec.rb @@ -46,7 +46,12 @@ end it "converts 64-bit mingw UCRT platform variants into x64-mingw-ucrt" do - expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("x64-mingw-ucrt")) + expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("mingw")) + end + + it "converts aarch64 mingw platform variants into x64-mingw-ucrt" do + expect(generic(pl("aarch64-mingw"))).to eq(pl("mingw")) + expect(generic(pl("aarch64-mingw-ucrt"))).to eq(pl("mingw")) end end From f592f0b82b694d9a4cae75569d3e6fab1cd4ade8 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:14:45 +0900 Subject: [PATCH 09/12] fix spec --- bundler/spec/other/ext_spec.rb | 36 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/bundler/spec/other/ext_spec.rb b/bundler/spec/other/ext_spec.rb index 74dadf2bb723..c4f69b17a35e 100644 --- a/bundler/spec/other/ext_spec.rb +++ b/bundler/spec/other/ext_spec.rb @@ -28,30 +28,18 @@ expect(generic(pl("java"))).to eq(pl("java")) end - it "converts mswin platform variants into x86-mswin32" do - expect(generic(pl("mswin32"))).to eq(pl("x86-mswin32")) - expect(generic(pl("i386-mswin32"))).to eq(pl("x86-mswin32")) - expect(generic(pl("x86-mswin32"))).to eq(pl("x86-mswin32")) - end - - it "converts 32-bit mingw platform variants into x86-mingw32" do - expect(generic(pl("mingw32"))).to eq(pl("x86-mingw32")) - expect(generic(pl("i386-mingw32"))).to eq(pl("x86-mingw32")) - expect(generic(pl("x86-mingw32"))).to eq(pl("x86-mingw32")) - end - - it "converts 64-bit mingw platform variants into x64-mingw32" do - expect(generic(pl("x64-mingw32"))).to eq(pl("x64-mingw32")) - expect(generic(pl("x86_64-mingw32"))).to eq(pl("x64-mingw32")) - end - - it "converts 64-bit mingw UCRT platform variants into x64-mingw-ucrt" do - expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("mingw")) - end - - it "converts aarch64 mingw platform variants into x64-mingw-ucrt" do - expect(generic(pl("aarch64-mingw"))).to eq(pl("mingw")) - expect(generic(pl("aarch64-mingw-ucrt"))).to eq(pl("mingw")) + it "converts windows platform variants into windows" do + expect(generic(pl("mswin32"))).to eq(pl("windows")) + expect(generic(pl("i386-mswin32"))).to eq(pl("windows")) + expect(generic(pl("x86-mswin32"))).to eq(pl("windows")) + expect(generic(pl("mingw32"))).to eq(pl("windows")) + expect(generic(pl("i386-mingw32"))).to eq(pl("windows")) + expect(generic(pl("x86-mingw32"))).to eq(pl("windows")) + expect(generic(pl("x64-mingw32"))).to eq(pl("windows")) + expect(generic(pl("x86_64-mingw32"))).to eq(pl("windows")) + expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("windows")) + expect(generic(pl("aarch64-mingw"))).to eq(pl("windows")) + expect(generic(pl("aarch64-mingw-ucrt"))).to eq(pl("windows")) end end From 7b612d1eaebb00ed4718b46b6c4c9f2eefef2731 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Fri, 3 Jan 2025 00:31:19 +0900 Subject: [PATCH 10/12] Fix specs --- bundler/spec/support/platforms.rb | 2 +- lib/rubygems/platform.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bundler/spec/support/platforms.rb b/bundler/spec/support/platforms.rb index 526e1c09a9c0..e3e855f59379 100644 --- a/bundler/spec/support/platforms.rb +++ b/bundler/spec/support/platforms.rb @@ -59,7 +59,7 @@ def not_local def local_tag if RUBY_PLATFORM == "java" :jruby - elsif ["x64-mingw32", "x64-mingw-ucrt"].include?(RUBY_PLATFORM) + elsif RUBY_PLATFORM.match?(/mingw|mswin/) :windows else :ruby diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb index 450c2141676e..1a18ac46bbb6 100644 --- a/lib/rubygems/platform.rb +++ b/lib/rubygems/platform.rb @@ -125,6 +125,7 @@ def initialize(arch) when /^dotnet$/ then ["dotnet", nil] when /^dotnet([\d.]*)/ then ["dotnet", $1] when /linux-?(\w+)?/ then ["linux", $1] + when /windows-?(\w+)?/ then ["windows", $1] when /mingw32/ then ["mingw32", nil] when /mingw-?(\w+)?/ then ["mingw", $1] when /(mswin\d+)(\_(\d+))?/ then From 248948f2377c8475431d0fd38e511c5f60058954 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Fri, 3 Jan 2025 07:22:37 +0900 Subject: [PATCH 11/12] Fix specs --- bundler/spec/support/platforms.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/spec/support/platforms.rb b/bundler/spec/support/platforms.rb index e3e855f59379..790fd13fdff5 100644 --- a/bundler/spec/support/platforms.rb +++ b/bundler/spec/support/platforms.rb @@ -105,7 +105,7 @@ def lockfile_platforms(*extra, defaults: default_locked_platforms) end def default_locked_platforms - [local_platform, generic_local_platform] + [local_platform, generic_local_platform] - [Gem::Platform.new("windows")] end end end From b8450688977558ee192ae131b3e66394d9c3cc34 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Fri, 3 Jan 2025 07:36:02 +0900 Subject: [PATCH 12/12] Add test for windows as a platform value --- test/rubygems/test_gem_platform.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/rubygems/test_gem_platform.rb b/test/rubygems/test_gem_platform.rb index 070c8007bc00..a78e3cf34b2c 100644 --- a/test/rubygems/test_gem_platform.rb +++ b/test/rubygems/test_gem_platform.rb @@ -121,6 +121,7 @@ def test_initialize "i386-linux" => ["x86", "linux", nil], "i586-linux-gnu" => ["x86", "linux", "gnu"], "i386-linux-gnu" => ["x86", "linux", "gnu"], + "windows" => [nil, "windows", nil], "i386-mingw32" => ["x86", "mingw32", nil], "x64-mingw-ucrt" => ["x64", "mingw", "ucrt"], "i386-mswin32" => ["x86", "mswin32", nil],