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

Commit

Permalink
[Definition] Only sort platforms once in expand_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Jul 4, 2017
1 parent a677287 commit 76a5657
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 3 additions & 2 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,12 @@ def concat_ruby_version_requirements(ruby_version, ruby_versions = [])
end

def expand_dependencies(dependencies, remote = false)
sorted_platforms = Resolver.sort_platforms(@platforms)
deps = []
dependencies.each do |dep|
dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
next if !remote && !dep.current_platform?
platforms = dep.gem_platforms(@platforms)
platforms = dep.gem_platforms(sorted_platforms)
if platforms.empty?
mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }
Bundler.ui.warn \
Expand All @@ -904,7 +905,7 @@ def expand_dependencies(dependencies, remote = false)
"To add those platforms to the bundle, " \
"run `bundle lock --add-platform #{mapped_platforms.join " "}`."
end
Resolver.sort_platforms(platforms).each do |p|
platforms.each do |p|
deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
end
end
Expand Down
12 changes: 5 additions & 7 deletions lib/bundler/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,14 @@ def initialize(name, version, options = {}, &blk)
@autorequire = Array(options["require"] || []) if options.key?("require")
end

# Returns the platforms this dependency is valid for, in the same order as
# passed in the `valid_platforms` parameter
def gem_platforms(valid_platforms)
return valid_platforms if @platforms.empty?

platforms = []
@platforms.each do |p|
platform = PLATFORM_MAP[p]
next unless valid_platforms.include?(platform)
platforms |= [platform]
end
platforms
@gem_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq

valid_platforms & @gem_platforms
end

def should_include?
Expand Down

0 comments on commit 76a5657

Please sign in to comment.