Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Add support for the x64-mingw32 platform #2590

Merged
merged 4 commits into from
Aug 15, 2013
Merged
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
10 changes: 9 additions & 1 deletion lib/bundler/current_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def mswin?
end

def mingw?
Bundler::WINDOWS && Gem::Platform.local.os == "mingw32"
Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu != 'x64'
end

def mingw_18?
Expand All @@ -84,5 +84,13 @@ def mingw_20?
mingw? && on_20?
end

def x64_mingw?
Bundler::WINDOWS && Gem::Platform.local.os == "mingw32" && Gem::Platform.local.cpu == 'x64'
end

def x64_mingw_20?
x64_mingw? && on_20?
end

end
end
4 changes: 3 additions & 1 deletion lib/bundler/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class Dependency < Gem::Dependency
:mingw => Gem::Platform::MINGW,
:mingw_18 => Gem::Platform::MINGW,
:mingw_19 => Gem::Platform::MINGW,
:mingw_20 => Gem::Platform::MINGW
:mingw_20 => Gem::Platform::MINGW,
:x64_mingw => Gem::Platform::X64_MINGW,
:x64_mingw_20 => Gem::Platform::X64_MINGW
}.freeze

def initialize(name, version, options = {}, &blk)
Expand Down
13 changes: 7 additions & 6 deletions lib/bundler/gem_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ module GemHelpers

GENERIC_CACHE = {}
GENERICS = [
Gem::Platform.new('java'),
Gem::Platform.new('mswin32'),
Gem::Platform.new('x86-mingw32'),
Gem::Platform::RUBY
[Gem::Platform.new('java'), Gem::Platform.new('java')],
[Gem::Platform.new('mswin32'), Gem::Platform.new('mswin32')],
[Gem::Platform.new('x64-mingw32'), Gem::Platform.new('x64-mingw32')],
[Gem::Platform.new('x86_64-mingw32'), Gem::Platform.new('x64-mingw32')],
[Gem::Platform.new('mingw32'), Gem::Platform.new('x86-mingw32')]
]

def generic(p)
return p if p == Gem::Platform::RUBY

GENERIC_CACHE[p] ||= begin
found = GENERICS.find do |p2|
p2.is_a?(Gem::Platform) && p.os == p2.os
_, found = GENERICS.find do |match, _generic|
p.os == match.os && (!match.cpu || p.cpu == match.cpu)
end
found || Gem::Platform::RUBY
end
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/rubygems_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Platform
JAVA = Gem::Platform.new('java') unless defined?(JAVA)
MSWIN = Gem::Platform.new('mswin32') unless defined?(MSWIN)
MINGW = Gem::Platform.new('x86-mingw32') unless defined?(MINGW)
X64_MINGW = Gem::Platform.new('x64-mingw32') unless defined?(X64_MINGW)

undef_method :hash if method_defined? :hash
def hash
Expand Down
6 changes: 5 additions & 1 deletion man/gemfile.5.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,17 @@ There are a number of `Gemfile` platforms:
* `mswin`:
Windows
* `mingw`:
Windows 'mingw32' platform (aka RubyInstaller)
Windows 32 bit 'mingw32' platform (aka RubyInstaller)
* `mingw_18`:
_mingw_ `AND` version 1.8
* `mingw_19`:
_mingw_ `AND` version 1.9
* `mingw_20`:
_mingw_ `AND` version 2.0
* `x64_mingw`:
Windows 64 bit 'mingw32' platform (aka RubyInstaller x64)
* `x64_mingw_20`:
_x64_mingw_ `AND` version 2.0

As with groups, you can specify one or more platforms:

Expand Down
23 changes: 23 additions & 0 deletions spec/other/ext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@

it "converts non-windows platforms into ruby" do
expect(generic(pl('x86-darwin-10'))).to eq(pl('ruby'))
expect(generic(pl('ruby'))).to eq(pl('ruby'))
end

it "converts java platform variants into java" do
expect(generic(pl('universal-java-17'))).to eq(pl('java'))
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
end

Expand Down
8 changes: 7 additions & 1 deletion spec/resolver/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

before :each do
@index = build_index do
platforms "mingw32 mswin32" do |platform|
platforms "mingw32 mswin32 x64-mingw32" do |platform|
gem "thin", "1.2.7", platform
end
end
Expand All @@ -51,6 +51,12 @@
dep "thin"
should_resolve_as %w(thin-1.2.7-x86-mingw32)
end

it "finds x64-mingw gems" do
platforms "x64-mingw32"
dep "thin"
should_resolve_as %w(thin-1.2.7-x64-mingw32)
end
end

describe "with conflicting cases" do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/indexes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def an_awesome_index
end

versions '1.0 1.2 1.2.1 1.2.2 1.3 1.3.0.1 1.3.5 1.4.0 1.4.2 1.4.2.1' do |version|
platforms "ruby java mswin32 mingw32" do |platform|
platforms "ruby java mswin32 mingw32 x64-mingw32" do |platform|
next if version == v('1.4.2.1') && platform != pl('x86-mswin32')
next if version == v('1.4.2') && platform == pl('x86-mswin32')
gem "nokogiri", version, platform do
Expand Down
6 changes: 5 additions & 1 deletion spec/support/platforms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ def mingw
Gem::Platform.new(['x86', 'mingw32', nil])
end

def x64_mingw
Gem::Platform.new(['x64', 'mingw32', nil])
end

def all_platforms
[rb, java, linux, mswin, mingw]
[rb, java, linux, mswin, mingw, x64_mingw]
end

def local
Expand Down