LukeMathWalker / LukeMathWalker/cargo-chef
Add support for `--example` to `cargo chef cook`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.7k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
I'm building some example code using:
```
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json --bin my-example
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release -p my-example --example my-example
```
And sadly it seems the dependencies that are being compiled by the `cook` step are not the same ones as the ones used by `cargo build --example my-example`, and so it's rebuilding it all.
I've found that `cook` supports `--examples`, but it seems sometimes it's not always building all the required dependencies for my example binaries, it allows to not rebuild all the dependencies, however, only a few.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the `cargo chef cook` command and compare its existing `--examples` handling with the reported `cargo build --example my-example` workflow. Trace how the recipe identifies example dependencies; done means a supported `--example` option causes `cook` to compile the dependencies needed by that example without rebuilding them afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100