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

prepare seems to bring some unnecessary files when used with --bin #300

Open
0xangelo opened this issue Feb 9, 2025 · 0 comments
Open

Comments

@0xangelo
Copy link

0xangelo commented Feb 9, 2025

Hi, I've been noticing some cache misses when building out containerized bins in a Cargo workspace, so I set up https://github.com/0xangelo/cargo-workspace-template to experiment with.

In there you'll see two crates with binary targets: hello-world and goodbye-world. The former has a binary with the same name. The latter has 2 bins and importantly, no dependencies.

Here's my experiments with cargo chef prepare --bin with each of the 3 binaries

Image

The difference between the recipes for hello-world and goodbye-world are as expected: the root Cargo.toml generated only includes the respective crates defining those binaries.

However, you'll notice above that for hasta-la-vista (the other binary of the goodbye-world crate), it includes all the crates in the workspace. Seems unnecessary as it has no dependencies on any other crates in the project.


On a general note: would it be possible to enhance prepare --bin in a way that the .skeleton.lock_file in recipe.json only includes the contents necessary to build the --bin in question? For instance, for the goodbye-world bin in the example repo above, that would mean the Cargo.lock contents in recipe.json would just be

# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4

[[package]]
name = "goodbye-world"
version = "0.0.1"

So, if one made changes to, say, hello-world dependencies only, that would not change the 'recipe' for goodbye-world, so we could keep the dependencies cached for that binary (well, not a great example since that binary doesn't have deps, but imagine it had one). I'd be willing to work on such feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant