Debian Codegraph @

R/sdkroot.R

raw
1
2 renv_sdkroot_init <- function() {
3
4 if (!renv_platform_macos())
5 return()
6
7 enabled <- Sys.getenv("RENV_SDKROOT_ENABLED", unset = "TRUE")
8 if (!truthy(enabled, default = TRUE))
9 return()
10
11 sdkroot <- Sys.getenv("SDKROOT", unset = NA)
12 if (!is.na(sdkroot))
13 return()
14
15 sdk <- "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
16 if (!file.exists(sdk))
17 return()
18
19 makeconf <- file.path(R.home("etc"), "Makeconf")
20 if (!file.exists(makeconf))
21 return()
22
23 contents <- readLines(makeconf)
24 cxx <- grep("^CXX\\s*=", contents, value = TRUE, perl = TRUE)
25 if (length(cxx) == 0L)
26 return()
27
28 if (!grepl("(?:/usr/local|/opt/homebrew)/opt/llvm", cxx))
29 return()
30
31 Sys.setenv(SDKROOT = sdk)
32
33 }