This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Resolve for specific platforms #4836
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a7163e3
Resolve for specific platforms
segiddins 1c84a7c
[LazySpecification] Only materialize for the current platform when
segiddins 7edf2e1
[Resolver] Remove required_by attribute from SpecGroup
segiddins 46f375e
Refactor best-platform matching
segiddins 8ae471e
Add a helper to the_bundler to get a parsed lockfile
segiddins d114818
Add a platform helper for x64_mac
segiddins 5248cc3
Automatically add platform to version in the spec’s builders
segiddins ea664da
Add a spec for platform_specific resolution / runtime
segiddins 3707f56
[Source] Always print the platform when installing
segiddins 07c76fd
[SpecSet] Fix #for when installing with --deployment
segiddins a846279
[LockfileParser] Ensure specs are consistently ordered
segiddins eab72a0
[Definition] Only add current platform if not frozen
segiddins bb7d870
[Definition] Validate platform in addition to ruby
segiddins 0ac668d
[Plugin] Don’t print GemfileErrors twice
segiddins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,8 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti | |
if lockfile && File.exist?(lockfile) | ||
@lockfile_contents = Bundler.read_file(lockfile) | ||
@locked_gems = LockfileParser.new(@lockfile_contents) | ||
@platforms = @locked_gems.platforms | ||
@locked_platforms = @locked_gems.platforms | ||
@platforms = @locked_platforms.dup | ||
@locked_bundler_version = @locked_gems.bundler_version | ||
@locked_ruby_version = @locked_gems.ruby_version | ||
|
||
|
@@ -91,6 +92,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti | |
@locked_deps = [] | ||
@locked_specs = SpecSet.new([]) | ||
@locked_sources = [] | ||
@locked_platforms = [] | ||
end | ||
|
||
@unlock[:gems] ||= [] | ||
|
@@ -102,8 +104,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti | |
|
||
@gem_version_promoter = create_gem_version_promoter | ||
|
||
current_platform = Bundler.rubygems.platforms.map {|p| generic(p) }.compact.last | ||
add_platform(current_platform) | ||
add_current_platform unless Bundler.settings[:frozen] | ||
|
||
@path_changes = converge_paths | ||
eager_unlock = expand_dependencies(@unlock[:gems]) | ||
|
@@ -414,6 +415,11 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false) | |
deleted = [] | ||
changed = [] | ||
|
||
new_platforms = @platforms - @locked_platforms | ||
deleted_platforms = @locked_platforms - @platforms | ||
added.concat new_platforms.map {|p| "* platform: #{p}" } | ||
deleted.concat deleted_platforms.map {|p| "* platform: #{p}" } | ||
|
||
gemfile_sources = sources.lock_sources | ||
|
||
new_sources = gemfile_sources - @locked_sources | ||
|
@@ -462,6 +468,11 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false) | |
raise ProductionError, msg if added.any? || deleted.any? || changed.any? | ||
end | ||
|
||
def validate_runtime! | ||
validate_ruby! | ||
validate_platforms! | ||
end | ||
|
||
def validate_ruby! | ||
return unless ruby_version | ||
|
||
|
@@ -487,6 +498,22 @@ def validate_ruby! | |
end | ||
end | ||
|
||
# TODO: refactor this so that `match_platform` can be called with two platforms | ||
DummyPlatform = Struct.new(:platform) | ||
class DummyPlatform; include MatchPlatform; end | ||
def validate_platforms! | ||
return if @platforms.any? do |bundle_platform| | ||
bundle_platform = DummyPlatform.new(bundle_platform) | ||
Bundler.rubygems.platforms.any? do |local_platform| | ||
bundle_platform.match_platform(local_platform) | ||
end | ||
end | ||
|
||
raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \ | ||
"but your local platforms are #{Bundler.rubygems.platforms.map(&:to_s)}, and " \ | ||
"there's no compatible match between those two lists." | ||
end | ||
|
||
def add_platform(platform) | ||
@new_platform ||= [email protected]?(platform) | ||
@platforms |= [platform] | ||
|
@@ -497,6 +524,12 @@ def remove_platform(platform) | |
raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}" | ||
end | ||
|
||
def add_current_platform | ||
current_platform = Bundler.rubygems.platforms.last | ||
add_platform(current_platform) if Bundler.settings[:specific_platform] | ||
add_platform(generic(current_platform)) | ||
end | ||
|
||
attr_reader :sources | ||
private :sources | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really? we're doing trailing commas now? 😝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have been since introducing rubocop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way we don't have to touch that line when adding a new element to the array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what good is it to be in charge of a project if we adopt code style that clashes with my personal coding aesthetic 😝