-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple package in a single WIT source #1577
Merged
alexcrichton
merged 11 commits into
bytecodealliance:main
from
azaslavsky:component-model-313
Jun 6, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9fdcd8c
Squashed and rebased previous work onto HEAD
azaslavsky a837ff2
Updated push_path and push_dir return signature
azaslavsky 7b36db9
Fix pretty printing signature and output
azaslavsky 74913a5
Fix some more comments
azaslavsky 0ae683b
Added ResloverKind and UnresolvedPackageGroup
azaslavsky 81a7234
SourceMap is actually per UnresolvedPackageGroup now
azaslavsky 350e39a
New append method is now topologically sorted
azaslavsky 08eec14
Add some tests
azaslavsky a87f944
Cargo fmt
azaslavsky 581c2b2
Fix cargo fmt crankiness
azaslavsky b1f4914
Resolve final comments
azaslavsky 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
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.
This is more-or-less a replacement of
Resolve::select_world
. In that case what would you think of basically replacingselect_world
with this? That way callers can largely stay the same where they'll pass in a list of ids here rather than a single id and the"foo"
selector will only work if the list of packages is of length 1.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.
I initially had the same instinct, but felt like the current approach may be a little more typesafe?
In either case, the caller has to make sure of something at the call site: in the current setup, they have to make sure to select the right
PackageId
for theworld_name
they're interested in (I can add a comment to the doc-string to help point them to the right helper for doing this), but at least the type signature gives a hint that they need to do this. In the alternative world whereselect_world
always takes aVec<PackageId>
, I could easily imagine authors forgetting to check that their inputworld_name
formatting conforms to the rules dictated by theVec<PackageId>
count, and hitting this error condition in (probably relatively rarely tested) multi package scenarios.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.
I think you're right, but I also think we'll still want to change
select_world
, lemme expand on this though. You're right in that if a singlePackageId
was what the caller already had then it's best to have the current signature ofselect_world
. Note though that theworld
argument ofselect_world
is not just"foo"
but it can also be the fully qualified name offoo:bar/baz
.Otherwise though, why I think this still needs to change, is that the
select_world
is a method that has not aged well. The intention of the method was to be "here are the two inputs bindings generators typically have and then here's the canonical way to acquire a world". In that sense this is supposed to be the helper to acquire aWorldId
to generate bindings for (and all bindings generators operate at the level of a world). The history of this method looked like:default world
in each packageworld: Option<&str>
argumentdefault world
but theOption
remained for "if there's only one world otherwise disambiguate with the name here"foo:bar/baz
.Basically what I'm getting at is that the exact signature of
select_world
is not really all that important because it's pretty rare to have a singlePackageId
after this change. The input from all bindings generators is going to be "here's the set of packages that was defined in the 'main package' now please select a world from here". Given that I think it's best to switch this to&[PackageId]
. I'd love one day to be able to remove the package argument entirely, but I think that's for a bit further down the road.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.
If possible, I'd like to save such a refactor for a follow on PR, to get a good baseline landed and free of merge conflicts here.
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.
Sounds good to me 👍