-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: add cargo pkgid
support for cargo-script
#14961
base: master
Are you sure you want to change the base?
Conversation
73e3975
to
3e3383a
Compare
Another test we'll need is that we error when a cargo script is specified as a dependency which might become possible with this change. |
3022d26
to
44ded93
Compare
Do you mean by |
I mean [package]
name = "foo"
[dependencies]
bar.path = "bar.rs" |
This comment has been minimized.
This comment has been minimized.
I just did a really rough commit to prove the idea here. It seems to work. But the code is totally messed up. I want to check two things with you before I move forward and improve the code.
|
The RFC says
cargo/src/cargo/util/toml/embedded.rs Line 115 in 0499e31
cargo/src/cargo/util/toml/embedded.rs Lines 147 to 176 in 0499e31
|
// FIXME: It should be `path+[ROOTURL]/foo#script.rs@0.0.0`.
p.cargo("-Zscript pkgid --manifest-path script.rs")
.masquerade_as_nightly_cargo(&["script"])
.with_stdout_data(str![[r#"
path+[ROOTURL]/foo#script@0.0.0
"#]]) this should instead be // FIXME: It should be `path+[ROOTURL]/foo/script.rs#0.0.0`.
p.cargo("-Zscript pkgid --manifest-path script.rs")
.masquerade_as_nightly_cargo(&["script"])
.with_stdout_data(str![[r#"
path+[ROOTURL]/foo/script.rs#0.0.0
"#]]) according to #14831 (comment) Switching to that scheme should simplify the code, not requiring updates to |
Oh, I misunderstood
Yes. Got it. |
So I guess if the package name is foo, then we have: path+[ROOTURL]/foo/script.rs#foo@0.0.0 |
If the user explicitly overrode it, yes |
c10754e
to
6659d5f
Compare
…ommand Signed-off-by: Rustin170506 <techregister@pm.me>
Signed-off-by: Rustin170506 <techregister@pm.me>
Signed-off-by: Rustin170506 <techregister@pm.me>
d10f797
to
fc25d9d
Compare
cargo pkgid
support for cargo-scriptcargo pkgid
support for cargo-script
749889c
to
82cbacd
Compare
e98e69a
to
6982520
Compare
bff4962
to
a4ca61d
Compare
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.
🔢 Self-check (PR reviewed by myself and ready for feedback.)
@@ -124,6 +124,9 @@ impl<'gctx> PathSource<'gctx> { | |||
} | |||
|
|||
fn read_package(&self) -> CargoResult<Package> { | |||
if crate::util::toml::is_embedded(&self.path) { |
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 am not sure if this is the best place to check this. Maybe we should move it to where we create the source ID?
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.
imo this feels too spooky as this function is not directly tied to dependencies.
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.
Then I guess we should do the check when we read the manifest file.
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.
Or the dependency resolution phase. Maybe do it when resolving dependencies makes more sense.
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.
Maybe it isn't so bad? If we view the lack of dependency / workspace support as not far away, this just needs to hold us over until then. If its far away or unlikely, then more care might be needed.
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 we view the lack of dependency / workspace support as not far away, this just needs to hold us over until then.
Do you have any plans for these features? They sound like big features. So I would prefer to find a better place for it. At least we could move it to the earlier stage, for example when we build the source for this package?
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.
Dependency support is dependent on either
[lib]
support which is hazy- artifact dependencies which I'd really like to move forward for build script delegation
Workspace support could be really useful for cargo-xtasks
These were deferred out of the first RFC just to focus on the minimal, core feature set. I am not lined up to immediately follow with these features but I could see them being high demand when this gets stabilized.
Signed-off-by: Rustin170506 <techregister@pm.me> fix
Signed-off-by: Rustin170506 <techregister@pm.me>
Signed-off-by: Rustin170506 <techregister@pm.me>
a4ca61d
to
183eeff
Compare
What does this PR try to resolve?
close #14831
In this PR, we added the
cargo pkgid
support for the cargo-script.For the package itself:
For its dependence:
How should we test and review this PR?
I have updated the unit tests and also added more test cases for it.
Additional information
None