Skip to content

Commit

Permalink
Use environment variables if set (#288)
Browse files Browse the repository at this point in the history
And trim newlines before splitting compilers

Closes #287
  • Loading branch information
TimTaylor authored Jun 30, 2024
1 parent a108a20 commit e6a3bab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/compilation-db.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ has_compilation_db <- function(desc) {

out <- as.logical(field)
check_bool(out, arg = "Config/build/compilation-database")

out
}

Expand Down Expand Up @@ -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, " ")
Expand Down

0 comments on commit e6a3bab

Please sign in to comment.