Skip to content
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

Add the path to the manifest in json output #9022

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Dec 28, 2020

This allows consumers of the json messages to avoid guessing where
exactly the package root is. Having access to the package root is
difficult by virtue of requiring logic to guess its location by e.g.
walking filesystem from the source file.

This guessing logic becomes further complicated in presence of
workspaces and nigh impossible to implement correctly in instances where
artifacts end up produced from paths above the package root (e.g.
../foo.rs).

Since Cargo has access to this data in the first place, there doesn't
seem to be much reason to force consumers to invent their own, possibly
flawed, logic.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 28, 2020
@alexcrichton
Copy link
Member

Thanks for this! Could you describe your use case a bit more as well? There's presumably a lot of possible information we could put into each blob, e.g. everything cargo metadata prints as well. I'm not sure if it's worth drawing the line somewhere, but I'm also curious why the manifest path is all you need since it seems like you might also need the source file entry point as well.

@nagisa
Copy link
Member Author

nagisa commented Jan 4, 2021

seems like you might also need the source file entry point as well

That is already present as part of target.src_path, if I understand what you mean.

Could you describe your use case a bit more

Sure, so I'm implementing/hacking on a cargo subcommand – cargo-phabricator – and there is at least one instance where being able to access find out the project root/manifest is useful.

In particular I had to resort to implementing a custom test runner, because cargo does not present messages about tests in a machine readable format (cf. #8903). Tests may depend on the very precise environment that cargo sets up for them (cwd = package root; environment variables, like CARGO_PKG_NAME, CARGO_MANIFEST_DIR, etc) so it is necessary for me to emulate that behaviour at least to some extent. Being able to easily access the manifest for a given test harness binary makes it comparatively easy(-ier) to set such an environment.

Now, I'm sure that ideally we'd improve cargo's test runner so that implementing custom test runners is not necessary – and I intend to hack on that as well – but I can also imagine other people finding other use-cases where being able to access the manifest helps to tremendously simplify their cargo wrappers.

@alexcrichton alexcrichton added the T-cargo Team: Cargo label Jan 5, 2021
@alexcrichton
Copy link
Member

Ok thanks for the info and seems reasonable to me!

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Jan 5, 2021

Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Jan 5, 2021
@bors
Copy link
Contributor

bors commented Feb 3, 2021

☔ The latest upstream changes (presumably #9122) made this pull request unmergeable. Please resolve the merge conflicts.

@rfcbot rfcbot added final-comment-period FCP — a period for last comments before action is taken and removed proposed-final-comment-period An FCP proposal has started, but not yet signed off. labels Feb 18, 2021
@rfcbot
Copy link
Collaborator

rfcbot commented Feb 18, 2021

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot
Copy link
Collaborator

rfcbot commented Feb 28, 2021

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@rfcbot rfcbot added to-announce and removed final-comment-period FCP — a period for last comments before action is taken labels Feb 28, 2021
@alexcrichton
Copy link
Member

@nagisa want to rebase this and I'll r+?

This allows consumers of the json messages to avoid guessing where
exactly the package root is. Having access to the package root is
difficult by virtue of requiring logic to guess its location by e.g.
walking filesystem from the source file.

This guessing logic becomes further complicated in presence of
workspaces and nigh impossible to implement correctly in instances where
artifacts end up produced from paths above the package root (e.g.
`../foo.rs`).

Since Cargo has access to this data in the first place, there doesn't
seem to be much reason to force consumers to invent their own, possibly
flawed, logic.
@nagisa
Copy link
Member Author

nagisa commented Mar 4, 2021

Rebased.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Mar 4, 2021

📌 Commit 548300b has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 4, 2021
@bors
Copy link
Contributor

bors commented Mar 4, 2021

⌛ Testing commit 548300b with merge c694096...

@bors
Copy link
Contributor

bors commented Mar 4, 2021

☀️ Test successful - checks-actions
Approved by: alexcrichton
Pushing c694096 to master...

@bors bors merged commit c694096 into rust-lang:master Mar 4, 2021
bors added a commit that referenced this pull request Mar 8, 2021
Add documentation for JSON message_path.

Documentation for the feature added in #9022.
@ehuss ehuss added this to the 1.52.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge FCP with intent to merge finished-final-comment-period FCP complete S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-cargo Team: Cargo to-announce
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants