extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
186 stars 27 forks source link

`rextender::clean()` - should that be a thing? #161

Closed Thell closed 2 years ago

Thell commented 2 years ago

Sometimes, when weird and odd things start to happen during the development process you really want to restart with a clean slate. Most dev tools have a clean and rebuild and I noted that to do a 'cargo clean' when playing with rextender that I needed to dive into the project src/rust to manually issue it. Would it be useful to have a clean/rebuild? Even along the lines of rcpp's sourcing with rebuild=T could be enough for those clean slate moments.

Ilia-Kosenkov commented 2 years ago

We do track Cargo.toml and *rs files and rebuild every time they are modified (modification time of source > modification time of binary) https://github.com/extendr/rextendr/blob/68fc6154440a1dcfb3d88dafee7bcc6238626188/R/track_rust_source.R#L97-L125

There is pkgbuild::clean_dll, also re-exported by {devtools}. We could have something like

rextendr::clean <- function(path = ".") {
   run_cargo_clean(path)
   pkgbuild::clean_dll(path)
}

Perhaps, with an additional level of verbosity (if needed).

Thell commented 2 years ago

I think that'd be good. Its surely not something that's a big issue though as manually issuing cargo clean is easy enough.

Ilia-Kosenkov commented 2 years ago

If you feel like you are up to the task, I invite you to contribute this function to {rextendr}. I can guide you through the review process.

Thell commented 2 years ago

Sure! Give me some time to familiarize myself with the code base and such along with using it a bit more and I'll submit a PR.