cargo-gc-bin

Crates.iocargo-gc-bin
lib.rscargo-gc-bin
version0.1.4
sourcesrc
created_at2023-08-24 12:18:48.848985
updated_at2024-05-07 08:14:45.639356
descriptionGarbage collect outdated cargo build artifacts.
homepage
repositoryhttps://github.com/waynexia/cargo-gc
max_upload_size
id953642
size37,889
Ruihang Xia (waynexia)

documentation

README

cargo gc

Crates.io License

Cargo extension to recycle outdated build artifacts. And try the best to avoid recompilation.

Usage

Install it with cargo:

cargo install cargo-gc-bin

The executable is cargo-gc. You can invoke it with cargo gc command:

cargo gc

It will check and remove all outdated build artifacts in the current project. See cargo gc --help for more information.

Limitations / Known issues

  • It needs to invoke cargo build that takes lots of time.
  • Need to re-link after GC
  • cargo check will re-check from scratch

Explaination

cargo gc uses the output information from cargo build to help recognize build artifacts in use, and removes all others. In the current implementation, top-level arficats are not recognized and leads to re-link after GC.

Compare to other utils like cargo sweep, this one is based on the informations provided by cargo itself rather than filesystem timestamp. So it can be more accurate and still avoiding recompilation as much as possible.

Next steps

Technically, it's possible to implement a "perfect" GC that can remove all outdated artifacts without any recompilation. And done this in a totally static way (i.e., without invoking cargo build). As the tuple ("crate name", "fingreprint") can be computed outside of cargo.

Commit count: 16

cargo fmt