-
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#[email protected]`.
p.cargo("-Zscript pkgid --manifest-path script.rs")
.masquerade_as_nightly_cargo(&["script"])
.with_stdout_data(str![[r#"
path+[ROOTURL]/foo#[email protected]
"#]]) 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 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
d10f797
to
fc25d9d
Compare
cargo pkgid
support for cargo-scriptcargo pkgid
support for cargo-script
749889c
to
82cbacd
Compare
e98e69a
to
6982520
Compare
497943e
to
b62a3bc
Compare
Signed-off-by: Rustin170506 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
Signed-off-by: Rustin170506 <[email protected]>
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.
ws.packages | ||
.packages | ||
.insert(ws.current_manifest.clone(), package); | ||
ws.target_dir = if let Some(dir) = target_dir { |
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.
Does this reformatting belong on the previous commit?
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.
Oops. I squashed it into the wrong commit.
@@ -1370,6 +1370,47 @@ registry+https://github.com/rust-lang/crates.io-index#[email protected] | |||
.run(); | |||
} | |||
|
|||
#[cargo_test(nightly, reason = "edition2024 hasn't hit stable yet")] | |||
fn script_as_dep() { |
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.
Is there a reason this test wasn't added before the feature commit?
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.
Just want to make sure it already has an error for it. The feature is just to improve the error message.
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