-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Implement support for base paths (RFC 3529) #12974
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
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.
Blocked on rust-lang/rfcs#3529
(doing this just to make it obvious in tandem with the draft status)
FYI, there appears to be a bug where, if a workspace has a path dependency with a base, then the member using that workspace dependency still sees the |
☔ The latest upstream changes (presumably #13080) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #13296) made this pull request unmergeable. Please resolve the merge conflicts. |
897f38e
to
96c9c05
Compare
b75dd6b
to
5d87b9f
Compare
61b3354
to
1ca5eb2
Compare
Question for reviewers: should I remove the documentation (either for the feature itself or for |
CLI flags should have |
I might not get to this for a few days. Something that might be helpful is to split the core feature PR from |
Fair enough: I'll convert this to a draft and then split it into chunks. |
Splitting this PR into a series of smaller PRs |
RFC: rust-lang/rfcs#3529
Tracking Issue: #14355
Introduce a table of path "bases" in Cargo configuration files that can be used
to prefix the path of
path
dependencies andpatch
entries.This feature will not support declaring path bases in manifest files to avoid
additional design complexity, though this may be added in the future.
Motivation
As a project grows in size, it becomes necessary to split it into smaller
sub-projects, architected into layers with well-defined boundaries.
One way to enforce these boundaries is to use different Git repos (aka
"multi-repo"). Cargo has good support for multi-repo projects using either
git
dependencies, or developers can use private registries if they want to
explicitly publish code or need to preprocess their sub-projects (e.g.,
generating code) before they can be consumed.
If all of the code is kept in a single Git repo (aka "mono-repo"), then these
boundaries must be enforced a different way: either leveraging tooling during
the build to check layering, or requiring that sub-projects explicitly publish
and consume from some intermediate directory. Cargo has poor support for
mono-repos: the only viable mechanism is
path
dependencies, but these requirerelative paths (which makes refactoring and moving sub-projects very difficult)
and don't work at all if the mono-repo requires publishing and consuming from an
intermediate directory (as this may very per host, or per target being built).
This RFC proposes a mechanism to specify path bases in
config.toml
files whichcan be used to prepend
path
dependencies. This allows mono-repos to specifydependencies relative to their root directory, which allows the consuming
project to be moved freely (no relative paths to update) and a simple
find-and-replace to handle a producing project being moved. Additionally, a
host-specific or target-specific intermediate directory may be specified as a
base
, allowing code to be consumed from there usingpath
dependencies.Implementation Details
patch
table.workspace
built-in path base.cargo add
(via--base
option).