From e6a3bab7f38e89b27267cd47b28da9f4017469fd Mon Sep 17 00:00:00 2001 From: Tim Taylor Date: Sun, 30 Jun 2024 10:57:31 +0100 Subject: [PATCH] Use environment variables if set (#288) And trim newlines before splitting compilers Closes #287 --- R/compilation-db.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/compilation-db.R b/R/compilation-db.R index 8102bd15..4ab30233 100644 --- a/R/compilation-db.R +++ b/R/compilation-db.R @@ -58,7 +58,7 @@ has_compilation_db <- function(desc) { out <- as.logical(field) check_bool(out, arg = "Config/build/compilation-database") - + out } @@ -193,15 +193,15 @@ compilers <- function() { # These variables are normally set by frontends but just in case env <- c( "current", - R_INCLUDE_DIR = fs::path(R.home(), "include"), - R_SHARE_DIR = fs::path(R.home(), "share") + R_INCLUDE_DIR = Sys.getenv("R_INCLUDE_DIR", unset = fs::path(R.home(), "include")), + R_SHARE_DIR = Sys.getenv("R_SHARE_DIR", unset = fs::path(R.home(), "share")) ) pkgbuild::with_build_tools( out <- processx::run("make", c(makevars, "print-compilers"), env = env) ) - compilers <- strsplit(out$stdout, "\n")[[1]] + compilers <- strsplit(trimws(out$stdout), "\n")[[1]] # Remove arguments compilers <- strsplit(compilers, " ")