Skip to content

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

@0xangelo

Description

@0xangelo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions