diff --git a/DESCRIPTION b/DESCRIPTION index b7029b251..84ba1a51f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -69,4 +69,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 diff --git a/NEWS.md b/NEWS.md index c67e0bc1c..8d9a6cae8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # devtools (development version) +* On macOS, `install()` now generates `dSYM` sidecar files for native libraries by default. + * Functions that use httr now explicitly check that it is installed (@catalamarti, #2573). diff --git a/R/install.R b/R/install.R index c9346475f..df1a22e3a 100644 --- a/R/install.R +++ b/R/install.R @@ -36,6 +36,23 @@ #' @param keep_source If `TRUE` will keep the srcrefs from an installed #' package. This is useful for debugging (especially inside of RStudio). #' It defaults to the option `"keep.source.pkgs"`. +#' @param generate_dsym (macOS only) If `TRUE`, and if the package includes a +#' native library (a `.so` file), a `dSYM` sidecar file is generated and +#' installed alongside the library. This file contains source and line +#' information that allows a debugger to step through original sources. +#' +#' Note that since `install()` operates from a temporary directory, the source +#' paths will point to dangling locations. You will need to remap these paths +#' to the actual sources on your disk, e.g. with lldb: +#' +#' ``` +#' # Get information about the dangling temporary path for a function in your +#' # library +#' image lookup -vn my_function +#' +#' # Remap the dangling location to the actual package path +#' settings set target.source-map /private/tmp/Rtmpnl5XgE/R.INSTALLe5133dcc3211/mypackage /path/to/mypackage +#' ``` #' @param ... additional arguments passed to [remotes::install_deps()] #' when installing dependencies. #' @family package installation @@ -50,6 +67,7 @@ install <- build_vignettes = FALSE, keep_source = getOption("keep.source.pkgs"), force = FALSE, + generate_dsym = TRUE, ...) { pkg <- as.package(pkg) @@ -70,6 +88,7 @@ install <- opts <- c( if (keep_source) "--with-keep.source", + if (is_macos && generate_dsym) "--dsym", "--install-tests" ) if (quick) { diff --git a/R/utils.R b/R/utils.R index 48629a0e6..d9f01e914 100644 --- a/R/utils.R +++ b/R/utils.R @@ -10,6 +10,7 @@ compact <- function(x) { } is_windows <- isTRUE(.Platform$OS.type == "windows") +is_macos <- isTRUE(tolower(Sys.info()[["sysname"]]) == "darwin") sort_ci <- function(x) { withr::with_collate("C", x[order(tolower(x), x)]) diff --git a/man/install.Rd b/man/install.Rd index 0009f2407..f1cfe908c 100644 --- a/man/install.Rd +++ b/man/install.Rd @@ -16,6 +16,7 @@ install( build_vignettes = FALSE, keep_source = getOption("keep.source.pkgs"), force = FALSE, + generate_dsym = TRUE, ... ) } @@ -78,6 +79,23 @@ It defaults to the option \code{"keep.source.pkgs"}.} \item{force}{Force installation, even if the remote state has not changed since the previous install.} +\item{generate_dsym}{(macOS only) If \code{TRUE}, and if the package includes a +native library (a \code{.so} file), a \code{dSYM} sidecar file is generated and +installed alongside the library. This file contains source and line +information that allows a debugger to step through original sources. + +Note that since \code{install()} operates from a temporary directory, the source +paths will point to dangling locations. You will need to remap these paths +to the actual sources on your disk, e.g. with lldb: + +\if{html}{\out{
}}\preformatted{# Get information about the dangling temporary path for a function in your +# library +image lookup -vn my_function + +# Remap the dangling location to the actual package path +settings set target.source-map /private/tmp/Rtmpnl5XgE/R.INSTALLe5133dcc3211/mypackage /path/to/mypackage +}\if{html}{\out{
}}} + \item{...}{additional arguments passed to \code{\link[remotes:install_deps]{remotes::install_deps()}} when installing dependencies.} }