0

This is similar to this question and answer, except specialized to R packages. Since R uses its own custom build process, what is the correct way to force a rebuild using Rcpp?

(For reasons that I won't go into here, all of my C++ code is located outside /pkg/src, and is called via a simple wrapper function that never changes. For this reason, when the important code changes, R thinks nothing has changed and declares the dreaded make: Nothing to be done for 'all'.)

Community
  • 1
  • 1
JohnA
  • 321
  • 2
  • 11

2 Answers2

1

Regarding

what is the correct way to force a rebuild using Rcpp

the obvious answer is to rebuild from source

R CMD INSTALL sourceTarballOfPackage_0.1.2.tar.gz

The question then becomes where to get the source: CRAN, GitHub, GitLab, BitBucket, ... but we have helpers for that.

If your code is internal, then you just need to rebuild the wrapper calling it, and that is still in src/ in the package. That is no different then another R(cpp) package linking against external resources.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • "you just need to rebuild the wrapper calling it" -- precisely! And what is the best way to do that? By default, `R CMD INSTALL` will not rebuild this if the timestamp has not changed. – JohnA Jan 04 '17 at 18:57
  • My packages all have a script `cleanup` (which is standard-but-optional part) which blows away, _inter alia_, what remains from `configure` and `gcc` and ... These things can be studied by looking at existing packages -- you have almost 10k to choose from! – Dirk Eddelbuettel Jan 04 '17 at 18:59
  • In RStudio you also have a 'clean & rebuild' option. Approximating the cleaning step, you can probably just do `rm src/*.{o,so,dylib}`. – Dirk Eddelbuettel Jan 04 '17 at 19:00
  • Thanks for the hint. This led me to the `--preclean` flag, which seems like the easiest solution. (Incidentally, I haven't seen the use of `cleanup` scripts before but this sounds like a great idea in general. Would love to see some kind of description of how this works!) – JohnA Jan 04 '17 at 19:08
  • 3
    I am not sure why you may this sound so difficult as [this is documented](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Configure-and-cleanup). – Dirk Eddelbuettel Jan 04 '17 at 19:10
1

The simplest solution is to add the flag --preclean to R CMD INSTALL. In Rstudio, this flag can be added under Project Options -> Build Tools -> Build and reload - R CMD INSTALL additonal options.

JohnA
  • 321
  • 2
  • 11