diff --git a/NEWS.md b/NEWS.md index 698d04f0..7128af7b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # rextendr (development version) +* `use_extendr()` now generates `cleanup` and `cleanup.win`. * Refactor of `rust_source()` and `rust_function()` <(https://github.com/extendr/rextendr/pull/478)> * Adds `opts = extendr_options()` to simplify `rust_source()` API with `...` to maintain backwards compatibility * Adds rlang standalone type checks to `rust_source()` and `rust_function()` diff --git a/R/use_extendr.R b/R/use_extendr.R index 15b6a358..00336bfd 100644 --- a/R/use_extendr.R +++ b/R/use_extendr.R @@ -119,6 +119,20 @@ use_extendr <- function( data = list(lib_name = lib_name) ) + use_rextendr_template( + "cleanup", + save_as = file.path("src", "cleanup"), + quiet = quiet, + overwrite = overwrite + ) + + use_rextendr_template( + "cleanup.win", + save_as = file.path("src", "cleanup.win"), + quiet = quiet, + overwrite = overwrite + ) + use_rextendr_template( "_gitignore", save_as = file.path("src", ".gitignore"), diff --git a/inst/templates/cleanup b/inst/templates/cleanup new file mode 100644 index 00000000..e346d71d --- /dev/null +++ b/inst/templates/cleanup @@ -0,0 +1 @@ +rm -f src/Makevars diff --git a/inst/templates/cleanup.win b/inst/templates/cleanup.win new file mode 100644 index 00000000..699571bf --- /dev/null +++ b/inst/templates/cleanup.win @@ -0,0 +1 @@ +rm -f src/Makevars.win \ No newline at end of file diff --git a/tests/testthat/_snaps/use_extendr.md b/tests/testthat/_snaps/use_extendr.md index 901e87d0..b2b0acbe 100644 --- a/tests/testthat/_snaps/use_extendr.md +++ b/tests/testthat/_snaps/use_extendr.md @@ -372,6 +372,8 @@ > File 'src/entrypoint.c' already exists. Skip writing the file. > File 'src/Makevars.in' already exists. Skip writing the file. > File 'src/Makevars.win.in' already exists. Skip writing the file. + > File 'src/cleanup' already exists. Skip writing the file. + > File 'src/cleanup.win' already exists. Skip writing the file. > File 'src/.gitignore' already exists. Skip writing the file. > File 'src/rust/Cargo.toml' already exists. Skip writing the file. > File 'src/rust/src/lib.rs' already exists. Skip writing the file. @@ -393,6 +395,8 @@ v Writing 'src/entrypoint.c' v Writing 'src/Makevars.in' v Writing 'src/Makevars.win.in' + v Writing 'src/cleanup' + v Writing 'src/cleanup.win' v Writing 'src/.gitignore' v Writing 'src/rust/Cargo.toml' v Writing 'src/rust/src/lib.rs'