diff --git a/NEWS.md b/NEWS.md index baa548a..f2dd8f6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # pkgbuild (development version) +* `compile_dll()` gains a `debug` argument for more control over the compile options used (@richfitz, #100) * `pkgbuild_process()` and `build()` now use colored compiler diagnostics if supported (#102) # pkgbuild 1.1.0 diff --git a/R/compile-dll.R b/R/compile-dll.R index dd03265..5739f7e 100644 --- a/R/compile-dll.R +++ b/R/compile-dll.R @@ -15,13 +15,18 @@ #' @inheritParams build #' @param force If `TRUE`, for compilation even if [needs_compile()] is #' `FALSE`. +#' @param debug If `TRUE`, and if no user Makevars is found, then the build +#' runs without optimisation (`-O0`) and with debug symbols (`-g`). See +#' [compiler_flags()] for details. If you have a user Makevars (e.g., +#' `~/.R/Makevars`) then this argument is ignored. #' @seealso [clean_dll()] to delete the compiled files. #' @export compile_dll <- function(path = ".", force = FALSE, compile_attributes = pkg_links_to_cpp11(path) || pkg_links_to_rcpp(path), register_routines = FALSE, - quiet = FALSE) { + quiet = FALSE, + debug = TRUE) { path <- pkg_path(path) if (!needs_compile(path) && !isTRUE(force)) { @@ -49,7 +54,7 @@ compile_dll <- function(path = ".", ) } else { # Otherwise set makevars for fast development / debugging - withr::with_makevars(compiler_flags(TRUE), assignment = "+=", { + withr::with_makevars(compiler_flags(debug), assignment = "+=", { install_min( path, dest = install_dir, diff --git a/man/compile_dll.Rd b/man/compile_dll.Rd index 7650ec7..ef6cbe8 100644 --- a/man/compile_dll.Rd +++ b/man/compile_dll.Rd @@ -9,7 +9,8 @@ compile_dll( force = FALSE, compile_attributes = pkg_links_to_cpp11(path) || pkg_links_to_rcpp(path), register_routines = FALSE, - quiet = FALSE + quiet = FALSE, + debug = TRUE ) } \arguments{ @@ -28,6 +29,11 @@ register routines with the package. It is ignored if package does not need compilation.} \item{quiet}{if \code{TRUE} suppresses output from this function.} + +\item{debug}{If \code{TRUE}, and if no user Makevars is found, then the build +runs without optimisation (\code{-O0}) and with debug symbols (\code{-g}). See +\code{\link[=compiler_flags]{compiler_flags()}} for details. If you have a user Makevars (e.g., +\verb{~/.R/Makevars}) then this argument is ignored.} } \description{ \code{compile_dll} performs a fake R CMD install so code that