diff options
author | Sutou Kouhei <kou@clear-code.com> | 2019-12-31 01:16:22 +0900 |
---|---|---|
committer | Sutou Kouhei <kou@clear-code.com> | 2020-01-15 06:27:03 +0900 |
commit | 6da46014b9a55d43d8bb7ae3d90783a80581be47 (patch) | |
tree | 13169fc8f425226c9d528f068d23d7235d84aca0 /lib | |
parent | 22857e2d63b700077b33398b0ae86201d06ebc79 (diff) | |
download | bundler-6da46014b9a55d43d8bb7ae3d90783a80581be47.tar.gz |
Add support for multiple platform spec group again
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/resolver.rb | 22 | ||||
-rw-r--r-- | lib/bundler/resolver/spec_group.rb | 13 |
2 files changed, 31 insertions, 4 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 9753efd088..ed0eab41f2 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -149,15 +149,33 @@ module Bundler selected_sgs = [] search.each do |sg| next unless sg.for?(platform) - sg.activate_platform!(platform) - if sg.spec(platform).platform != Gem::Platform::RUBY + spec_platform = sg.spec(platform).platform + if spec_platform && spec_platform != Gem::Platform::RUBY + # Add a spec group for "non platform specific spec" as the fallback + # spec group. sg_ruby = SpecGroup.new(sg.all_specs) sg_ruby.ignores_bundler_dependencies = sg.ignores_bundler_dependencies if sg_ruby.for?(Gem::Platform::RUBY) sg_ruby.activate_platform!(Gem::Platform::RUBY) selected_sgs << sg_ruby end + # Add a spec group for ["non platform specific spec", "platform + # specific spec"] to resolve a spec for multiple platforms. + # If Gemfile.lock file has the following entries, we need a ffi-1.9.14 + # spec group for ["ruby", "x86-mingw32"]. + # + # GEM + # specs: + # ffi (1.9.14) + # ffi (1.9.14-x86-mingw32) + sg_ruby_platform = SpecGroup.new(sg.all_specs) + sg_ruby_platform.ignores_bundler_dependencies = + sg.ignores_bundler_dependencies + sg_ruby_platform.activate_platform!(Gem::Platform::RUBY) + sg_ruby_platform.activate_platform!(platform) + selected_sgs << sg_ruby_platform end + sg.activate_platform!(platform) selected_sgs << sg end selected_sgs diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb index f79797a3ca..1e2a9f5929 100644 --- a/lib/bundler/resolver/spec_group.rb +++ b/lib/bundler/resolver/spec_group.rb @@ -48,7 +48,8 @@ module Bundler end def to_s - @to_s ||= "#{name} (#{version})" + activated_platforms_string = sorted_activated_platforms.join(", ") + "#{name} (#{version}) (#{activated_platforms_string})" end def dependencies_for_activated_platforms @@ -63,6 +64,7 @@ module Bundler return unless other.is_a?(SpecGroup) name == other.name && version == other.version && + sorted_activated_platforms == other.sorted_activated_platforms && source == other.source end @@ -70,11 +72,18 @@ module Bundler return unless other.is_a?(SpecGroup) name.eql?(other.name) && version.eql?(other.version) && + sorted_activated_platforms.eql?(other.sorted_activated_platforms) && source.eql?(other.source) end def hash - to_s.hash ^ source.hash + name.hash ^ version.hash ^ sorted_activated_platforms.hash ^ source.hash + end + + protected + + def sorted_activated_platforms + @activated_platforms.sort_by(&:to_s) end private |