[前][次][番号順一覧][スレッド一覧]

ruby-changes:73087

From: shields <ko1@a...>
Date: Mon, 29 Aug 2022 00:33:29 +0900 (JST)
Subject: [ruby-changes:73087] 8799c91205 (master): [rubygems/rubygems] Add platform :windows as a shortcut for all Windows platforms

https://git.ruby-lang.org/ruby.git/commit/?id=8799c91205

From 8799c912052f8bb957a65edd103e0064cac94598 Mon Sep 17 00:00:00 2001
From: shields <shields@t...>
Date: Sun, 28 Aug 2022 22:40:02 +0900
Subject: [rubygems/rubygems] Add platform :windows as a shortcut for all
 Windows platforms

https://github.com/rubygems/rubygems/commit/f3c49ad3f7
---
 lib/bundler/current_ruby.rb                        | 19 ++++++++----
 lib/bundler/dependency.rb                          |  1 +
 lib/bundler/rubygems_ext.rb                        |  1 +
 spec/bundler/commands/install_spec.rb              |  4 +--
 spec/bundler/commands/lock_spec.rb                 | 12 ++++----
 spec/bundler/install/gemfile/gemspec_spec.rb       |  2 +-
 spec/bundler/install/gemfile/platform_spec.rb      |  2 +-
 .../install/gemfile/specific_platform_spec.rb      |  4 +--
 spec/bundler/install/gems/dependency_api_spec.rb   |  2 +-
 spec/bundler/install/gems/resolving_spec.rb        |  4 +--
 spec/bundler/runtime/platform_spec.rb              | 34 +++++++++++++++++++++-
 spec/bundler/support/builders.rb                   | 10 ++++++-
 spec/bundler/support/helpers.rb                    |  2 +-
 spec/bundler/support/platforms.rb                  | 20 ++++++++++---
 14 files changed, 90 insertions(+), 27 deletions(-)

diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
index 36f26b7ab4..f9987c4da8 100644
--- a/lib/bundler/current_ruby.rb
+++ b/lib/bundler/current_ruby.rb
@@ -36,17 +36,18 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/current_ruby.rb#L36
       rbx
       ruby
       truffleruby
+      windows
       x64_mingw
     ].freeze
 
     def ruby?
       return true if Bundler::GemHelpers.generic_local_platform == Gem::Platform::RUBY
 
-      !mswin? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
+      !windows? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
     end
 
     def mri?
-      !mswin? && RUBY_ENGINE == "ruby"
+      !windows? && RUBY_ENGINE == "ruby"
     end
 
     def rbx?
@@ -65,16 +66,24 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/current_ruby.rb#L66
       RUBY_ENGINE == "truffleruby"
     end
 
-    def mswin?
+    def windows?
       Gem.win_platform?
     end
 
+    def mswin?
+      # For backwards compatibility
+      windows?
+
+      # TODO: This should correctly be:
+      # windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin32" && Bundler.local_platform.cpu == "x86"
+    end
+
     def mswin64?
-      Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
+      windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
     end
 
     def mingw?
-      Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
+      windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
     end
 
     def x64_mingw?
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 52c6fff194..49ce23ec88 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -42,6 +42,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L42
       :jruby    => Gem::Platform::JAVA,
       :jruby_18 => Gem::Platform::JAVA,
       :jruby_19 => Gem::Platform::JAVA,
+      :windows  => Gem::Platform::WINDOWS,
       :mswin    => Gem::Platform::MSWIN,
       :mswin_18 => Gem::Platform::MSWIN,
       :mswin_19 => Gem::Platform::MSWIN,
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index d976170f12..056053a783 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -237,6 +237,7 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/bundler/rubygems_ext.rb#L237
     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
 
     if Gem::Platform.new("x86_64-linux-musl") === Gem::Platform.new("x86_64-linux")
       remove_method :===
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index 7bf36ee020..56945346e1 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -285,7 +285,7 @@ RSpec.describe "bundle install with gem sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/install_spec.rb#L285
       end
 
       it "installs gems for windows" do
-        simulate_platform mswin
+        simulate_platform x86_mswin32
 
         install_gemfile <<-G
           source "#{file_uri_for(gem_repo1)}"
@@ -293,7 +293,7 @@ RSpec.describe "bundle install with gem sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/install_spec.rb#L293
         G
 
         run "require 'platform_specific' ; puts PLATFORM_SPECIFIC"
-        expect(out).to eq("1.0.0 MSWIN")
+        expect(out).to eq("1.0 x86-mswin32")
       end
     end
 
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index b314169a98..007e53f4e2 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -217,7 +217,7 @@ RSpec.describe "bundle lock" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/lock_spec.rb#L217
 
     allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
     lockfile = Bundler::LockfileParser.new(read_lockfile)
-    expect(lockfile.platforms).to match_array([java, mingw, specific_local_platform].uniq)
+    expect(lockfile.platforms).to match_array([java, x86_mingw32, specific_local_platform].uniq)
   end
 
   it "supports adding new platforms with force_ruby_platform = true" do
@@ -241,7 +241,7 @@ RSpec.describe "bundle lock" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/lock_spec.rb#L241
 
     allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
     lockfile = Bundler::LockfileParser.new(read_lockfile)
-    expect(lockfile.platforms).to contain_exactly(rb, linux, java, mingw)
+    expect(lockfile.platforms).to contain_exactly(rb, linux, java, x86_mingw32)
   end
 
   it "supports adding the `ruby` platform" do
@@ -262,12 +262,12 @@ RSpec.describe "bundle lock" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/lock_spec.rb#L262
 
     allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
     lockfile = Bundler::LockfileParser.new(read_lockfile)
-    expect(lockfile.platforms).to match_array([java, mingw, specific_local_platform].uniq)
+    expect(lockfile.platforms).to match_array([java, x86_mingw32, specific_local_platform].uniq)
 
     bundle "lock --remove-platform java"
 
     lockfile = Bundler::LockfileParser.new(read_lockfile)
-    expect(lockfile.platforms).to match_array([mingw, specific_local_platform].uniq)
+    expect(lockfile.platforms).to match_array([x86_mingw32, specific_local_platform].uniq)
   end
 
   it "errors when removing all platforms" do
@@ -280,7 +280,7 @@ RSpec.describe "bundle lock" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/lock_spec.rb#L280
     build_repo4 do
       build_gem "ffi", "1.9.14"
       build_gem "ffi", "1.9.14" do |s|
-        s.platform = mingw
+        s.platform = x86_mingw32
       end
 
       build_gem "gssapi", "0.1"
@@ -312,7 +312,7 @@ RSpec.describe "bundle lock" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/lock_spec.rb#L312
       gem "gssapi"
     G
 
-    simulate_platform(mingw) { bundle :lock }
+    simulate_platform(x86_mingw32) { bundle :lock }
 
     expect(lockfile).to eq <<~G
       GEM
diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb
index 941f1c6db9..7e2e7c345a 100644
--- a/spec/bundler/install/gemfile/gemspec_spec.rb
+++ b/spec/bundler/install/gemfile/gemspec_spec.rb
@@ -436,7 +436,7 @@ RSpec.describe "bundle install from an existing gemspec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/gemspec_spec.rb#L436
 
         simulate_new_machine
         simulate_platform("jruby") { bundle "install" }
-        simulate_platform(x64_mingw) { bundle "install" }
+        simulate_platform(x64_mingw32) { bundle "install" }
       end
 
       context "on ruby" do
diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb
index a357a92272..62e6bda4cd 100644
--- a/spec/bundler/install/gemfile/platform_spec.rb
+++ b/spec/bundler/install/gemfile/platform_spec.rb
@@ -501,7 +501,7 @@ end https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/platform_spec.rb#L501
 
 RSpec.describe "when a gem has no architecture" do
   it "still installs correctly" do
-    simulate_platform mswin
+    simulate_platform x86_mswin32
 
     build_repo2 do
       # The rcov gem is platform mswin32, but has no arch
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
index 094186e63d..699672f357 100644
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ b/spec/bundler/install/gemfile/specific_platform_spec.rb
@@ -227,9 +227,9 @@ RSpec.describe "bundle install with specific platforms" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/specific_platform_spec.rb#L227
       it "adds the foreign platform" do
         setup_multiplatform_gem
         install_gemfile(google_protobuf)
-        bundle "lock --add-platform=#{x64_mingw}"
+        bundl (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]