-
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
Implement workspaces in Cargo #2759
Conversation
r? @wycats (rust_highfive has picked a reviewer for you, use r? to override) |
I wanted to put this up for review, but I don't think that this is ready to merge yet. I believe I've covered the bases of an implementation, tests, and documentation. So far In implementing this I can only think of one possible catch in the RFC, which is that The major piece that this has not implemented yet is the modification to
Unfortunately connecting a crate to a workspace is not always a simple and local operation. We can always provide a pointer back to the workspace (e.g. I've left this unimplemented for now as I'm unsure what the best way to move forward this would be. On one hand if we omit Curious on others' thoughts though! |
Those transitive deps still need to specify the virtual manifest as workspace root, or be in a subdirectory, for symmetry, right? |
No, they're typically lower in the filesystem hierarchy. |
Hmm? You mean the subtree with virtual manifest at its root contains the specified members' path dependencies---what I meant by "or be in a subdirectory", or something else? |
Ah yes I misread, the original statement you made is correct (it just follows from what was written in the RFC) |
ping r? @brson, thoughts? |
I know I need to read this one closely and I just haven't yet. |
Ah yeah sure, we should talk in person tomorrow as well |
name = "bar" | ||
version = "0.1.0" | ||
authors = [] | ||
workspace = ".." |
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 'workspace' key is under project
, but the RFC says it goes under 'package'. Why the discrepancy?
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.
Oh the [package]
and [project]
keys are actually synonymous right now. There were initial ideas of how to treat them differently but that never came to fruition, so it's it's just a semi-unfortunate legacy "feature"
Great patch. This integrates really cleanly for such a big feature. |
I'll work on some better error messages, but @wycats do you have thoughts about the implicitly traveling all path dependencies in the |
f7c5a18
to
72749ab
Compare
Ok, after some more discussion with @wycats and @brson offline, I've updated the PR with two new pieces:
Due to the size of this feature and the concerns of the @rust-lang/tools team, r? @brson but this should probably merge after we branch beta next week. |
@larsbergstrom as a heads up, this is what it looks like for me to add workspaces to Servo (probably incomplete) alexcrichton/servo@1094428. I found it cool that the top-level It looked like there were spurious rebuilds between switching In any case, just wanted to ensure that it worked at scale, and it looks like it's working like a charm! |
r=me |
@alexcrichton Thanks for trying that out - it looks REALLY fantastic! One area of questioning: @SimonSapin is doing some work to help us do a dual-build using Rust Stable for just the geckolib target. Do you have any ideas for how that should integrate into this? And, can we still share the Cargo.lock file across nightly/stable builds? IIRC, we will need separate |
@larsbergstrom perhaps I misunderstand, but Cargo has long been able to compile multiple targets with a single |
@Ericson2314 Aha, yes! The difference here is that it's the same target triple, but with different versions of the Rust compiler itself (the |
@bors: r=brson |
📌 Commit 8b3933d has been approved by |
⌛ Testing commit 8b3933d with merge 2af552d... |
💔 Test failed - cargo-cross-linux |
@bors: r=brson |
📌 Commit 0c2ee50 has been approved by |
⌛ Testing commit 0c2ee50 with merge 23f2962... |
💔 Test failed - cargo-win-msvc-64 |
@bors: r=brson |
📌 Commit 9a6aebe has been approved by |
⌛ Testing commit 9a6aebe with merge 4daf6b5... |
💔 Test failed - cargo-linux-64 |
This commit is an implementation of [RFC 1525] which specifies the addition of **workspaces** to Cargo. [RFC 1525]: https://github.com/rust-lang/rfcs/blob/master/text/1525-cargo-workspace.md A workspace is a group of crates which are all compiled into the same output directory and share the same `Cargo.lock` file. This means that dependencies are cached between builds as well as dependencies all being shared at the same versions. An update to any one dependency transitively affects all other members of the workspace. Typical repository layouts with a crate at the root and a number of path dependencies simply need to add the following to the root `Cargo.toml`: ```toml [workspace] ``` Otherwise more advanced configuration may be necessary through the `package.workspace` or `workspace.members` keys. More information can be found as part of [RFC 1525].
@bors: r=brson |
📌 Commit 58ddb28 has been approved by |
Implement workspaces in Cargo This commit is an implementation of [RFC 1525] which specifies the addition of **workspaces** to Cargo. [RFC 1525]: https://github.com/rust-lang/rfcs/blob/master/text/1525-cargo-workspace.md A workspace is a group of crates which are all compiled into the same output directory and share the same `Cargo.lock` file. This means that dependencies are cached between builds as well as dependencies all being shared at the same versions. An update to any one dependency transitively affects all other members of the workspace. Typical repository layouts with a crate at the root and a number of path dependencies simply need to add the following to the root `Cargo.toml`: ```toml [workspace] ``` Otherwise more advanced configuration may be necessary through the `package.workspace` or `workspace.members` keys. More information can be found as part of [RFC 1525].
☀️ Test successful - cargo-cross-linux, cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-gnu-64, cargo-win-msvc-32, cargo-win-msvc-64 |
This commit is an implementation of RFC 1525 which specifies the addition of
workspaces to Cargo.
A workspace is a group of crates which are all compiled into the same output
directory and share the same
Cargo.lock
file. This means that dependencies arecached between builds as well as dependencies all being shared at the same
versions. An update to any one dependency transitively affects all other members
of the workspace.
Typical repository layouts with a crate at the root and a number of path
dependencies simply need to add the following to the root
Cargo.toml
:[workspace]
Otherwise more advanced configuration may be necessary through the
package.workspace
orworkspace.members
keys. More information can be foundas part of RFC 1525.