Open pzmarzly opened 5 years ago
Faster build time (considering my own is 10+ mins) is always good.
:+1:
While a faster build time is good, I'm not sure about writing cached files into the user's system's cache directory. Is there any other popular crate which does this?
Is there any other popular crate which does this?
I wasn't familiar with any, which is why I suggested it as an optional feature. Quick search on crates.io led me to gmp-mpfr-sys
, which creates temporary files in ~/.cache/gmp-mpfr-sys
, though it doesn't have to (it could use $OUT_DIR
provided by cargo).
I was thinking about using target
dir, but AFAIK we don't get any path to it. We would need to either:
a) assume it's $PWD/target
- but it's sometimes not,
b) assume it's $CARGO_MANIFEST_DIR/target
- false in multi-crate projects,
c) use $PWD
to find a topmost directory that contains both Cargo.toml
and target
- which would work for 99% of use cases, but that 1% of users could get surprised
Many Rust developers already have large ~/.cargo/registry
and ~/.cache/sccache
dirs, so I thought writing few hundred KBs to ~/.cache
wouldn't be that much of an issue if users were warned about that.
Cargo actually provides a per-crate temporary directory for such a use-case. You can have a look how I use caching in Nate: build.rs, generate.rs. (Actually I use it because then you have better error messages. The caching is only a by-product.)
In a project I'm working on, this decreases overall build time from between 8 and 10 to between 5 and 7 seconds.