Debian Codegraph @

R/xcode.R

raw
1
2 renv_xcode_available <- function() {
3
4 # allow bypass if required
5 check <- getOption("renv.xcode.available", default = NULL)
6 if (!is.null(check))
7 return(check)
8
9 # otherwise, check via xcode-select
10 status <- suppressWarnings(
11 system2("/usr/bin/xcode-select", "-p", stdout = FALSE, stderr = FALSE)
12 )
13
14 identical(status, 0L)
15
16 }
17
18 renv_xcode_check <- function() {
19
20 # allow bypass of xcode check if required
21 check <- getOption("renv.xcode.check", default = TRUE)
22 if (identical(check, FALSE))
23 return()
24
25 # only run on macOS
26 if (!renv_platform_macos())
27 return()
28
29 # only run check once per session
30 if (once())
31 return()
32
33 command <- "/usr/bin/xcrun --find --show-sdk-path"
34 status <- system(command, ignore.stdout = TRUE, ignore.stderr = TRUE)
35 if (identical(status, 0L))
36 return()
37
38 if (identical(status, 69L)) {
39
40 msg <- "
41 macOS is reporting that you have not yet agreed to the Xcode license.
42 You must accept the Xcode license before R packages can be installed from source.
43 Please run:
44
45 sudo xcodebuild -license accept
46
47 in the Terminal to accept the Xcode license.
48 Set options(renv.xcode.check = FALSE) to disable this warning.
49 "
50 warning(msg)
51
52 }
53
54 fmt <- "%s returned exit code %i"
55 warningf(fmt, command, status)
56
57 }