1 2## The checking code looks for the objects in the package namespace, so defining 3## dll here removes the following NOTE 4## Registration problem: 5## Evaluating ‘dll$foo’ during check gives error 6## ‘object 'dll' not found’: 7## .C(dll$foo, 0L) 8## See https://github.com/wch/r-source/blob/d4e8fc9832f35f3c63f2201e7a35fbded5b5e14c/src/library/tools/R/QC.R##L1950-L1980 9## Setting the class is needed to avoid a note about returning the wrong class. 10## The local object is found first in the actual call, so current behavior is 11## unchanged. 12 13dll <- list(foo = structure(list(), class = "NativeSymbolInfo")) 14 15has_devel <- function() { 16 tryCatch( 17 has_devel2(), 18 error = function(e) FALSE 19 ) 20} 21 22## This is similar to devtools:::has_devel(), with some 23## very minor differences. 24 25has_devel2 <- function() { 26 foo_path <- file.path(tempfile(fileext = ".c")) 27 28 cat("void foo(int *bar) { *bar=1; }\n", file = foo_path) 29 on.exit(unlink(foo_path)) 30 31 R(c("CMD", "SHLIB", basename(foo_path)), dirname(foo_path)) 32 dylib <- sub("\\.c$", .Platform$dynlib.ext, foo_path) 33 on.exit(unlink(dylib), add = TRUE) 34 35 dll <- dyn.load(dylib) 36 on.exit(dyn.unload(dylib), add = TRUE) 37 38 stopifnot(.C(dll$foo, 0L)[[1]] == 1L) 39 TRUE 40} 41 42missing_devel_warning <- function(pkgdir) { 43 pkgname <- tryCatch( 44 get_desc_field(file.path(pkgdir, "DESCRIPTION"), "Package"), 45 error = function(e) NULL 46 ) %||% "<unknown>" 47 48 sys <- sys_type() 49 50 warning( 51 "Package ", 52 pkgname, 53 " has compiled code, but no suitable ", 54 "compiler(s) were found. Installation will likely fail.\n ", 55 if (sys == "windows") { 56 c("Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).", 57 "Then use the pkgbuild package, or make sure that Rtools in the PATH.") 58 }, 59 if (sys == "macos") "Install XCode and make sure it works.", 60 if (sys == "linux") "Install compilers via your Linux package manager." 61 ) 62} 63 64R <- function(args, path = tempdir()) { 65 66 r <- file.path(R.home("bin"), "R") 67 68 args <- c( 69 "--no-site-file", "--no-environ", "--no-save", 70 "--no-restore", "--quiet", 71 args 72 ) 73 74 system_check(r, args, path = path) 75} 76