Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundler/lib/bundler/gem_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module GemHelpers
[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("mingw"), Gem::Platform.new("mingw")],
].freeze

def generic(p)
Expand Down
3 changes: 2 additions & 1 deletion bundler/lib/bundler/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ class Platform
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"),
MSWIN, MSWIN64, MINGW, X64_MINGW].flatten.freeze
X64_LINUX = Gem::Platform.new("x86_64-linux")
X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl")

Expand Down
11 changes: 11 additions & 0 deletions bundler/spec/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@
expect(the_bundle).to include_gems("platform_specific 1.0 x86-mswin32")
end
end

it "installs gems for aarch64-mingw-ucrt" do
simulate_platform aarch64_mingw_ucrt do
install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific"
G

expect(the_bundle).to include_gems("platform_specific 1.0 aarch64-mingw-ucrt")
end
end
end

describe "doing bundle install foo" do
Expand Down
9 changes: 7 additions & 2 deletions bundler/spec/other/ext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@
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("x64-mingw-ucrt"))
it "converts 64-bit mingw UCRT platform variants into mingw" do
expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("mingw"))
end

it "converts aarch64 mingw platform variants into mingw" do
expect(generic(pl("aarch64-mingw"))).to eq(pl("mingw"))
expect(generic(pl("aarch64-mingw-ucrt"))).to eq(pl("mingw"))
end
end

Expand Down
24 changes: 23 additions & 1 deletion bundler/spec/runtime/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@
end
end

%w[x86-mswin32 x64-mswin64 x86-mingw32 x64-mingw32 x64-mingw-ucrt].each do |arch|
%w[aarch64-mingw-ucrt x86-mswin32 x64-mswin64 x86-mingw32 x64-mingw32 x64-mingw-ucrt].each do |arch|
it "allows specifying platform windows on #{arch} arch" do
platform = send(arch.tr("-", "_"))

Expand Down Expand Up @@ -469,4 +469,26 @@
end
end
end

%w[aarch64-mingw x64-mingw x64-mingw-foobar].each do |arch|
it "does not find platform-specific gems on #{arch} arch" do
platform = Gem::Platform.new(arch)

simulate_windows platform do
lockfile <<-L
PLATFORMS
#{platform}
L

install_gemfile <<-G
source "https://gem.repo1"
gem "platform_specific", :platforms => [:windows]
G

bundle "install"

expect(the_bundle).to_not include_gems "platform_specific 1.0 #{platform}"
end
end
end
end
4 changes: 4 additions & 0 deletions bundler/spec/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def build_repo1
s.platform = "x64-mingw-ucrt"
end

build_gem "platform_specific" do |s|
s.platform = "aarch64-mingw-ucrt"
end

build_gem "platform_specific" do |s|
s.platform = "x86-darwin-100"
end
Expand Down
10 changes: 7 additions & 3 deletions bundler/spec/support/platforms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ def x64_mingw_ucrt
Gem::Platform.new(["x64", "mingw", "ucrt"])
end

def aarch64_mingw_ucrt
Gem::Platform.new(["aarch64", "mingw", "ucrt"])
end

def windows_platforms
[x86_mswin32, x64_mswin64, x86_mingw32, x64_mingw32, x64_mingw_ucrt]
[x86_mswin32, x64_mswin64, x86_mingw32, x64_mingw32, x64_mingw_ucrt, aarch64_mingw_ucrt]
end

def all_platforms
Expand All @@ -59,7 +63,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
Expand Down Expand Up @@ -105,7 +109,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("mingw")]
end
end
end
1 change: 1 addition & 0 deletions test/rubygems/test_gem_platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_initialize
"i386-linux-gnu" => ["x86", "linux", "gnu"],
"i386-mingw32" => ["x86", "mingw32", nil],
"x64-mingw-ucrt" => ["x64", "mingw", "ucrt"],
"aarch64-mingw-ucrt" => ["aarch64", "mingw", "ucrt"],
"i386-mswin32" => ["x86", "mswin32", nil],
"i386-mswin32_80" => ["x86", "mswin32", "80"],
"i386-mswin32-80" => ["x86", "mswin32", "80"],
Expand Down