@@ -28,11 +28,18 @@ sourceCpp <- function(file = "",
28
28
verbose = getOption(" verbose" ),
29
29
dryRun = FALSE ) {
30
30
31
+ # use an architecture/version specific subdirectory of the cacheDir
32
+ # (since cached dynlibs can now perist across sessions we need to be
33
+ # sure to invalidate them when R or Rcpp versions change)
34
+ cacheDir <- path.expand(cacheDir )
35
+ cacheDir <- normalizePath(cacheDir , winslash = " /" , mustWork = FALSE )
36
+ cacheDir <- .sourceCppPlatformCacheDir(cacheDir )
37
+
31
38
# resolve code into a file if necessary. also track the working
32
39
# directory to source the R embedded code chunk within
33
40
if (! missing(code )) {
34
41
rWorkingDir <- getwd()
35
- file <- tempfile(fileext = " .cpp" )
42
+ file <- tempfile(fileext = " .cpp" , tmpdir = cacheDir )
36
43
con <- file(file , open = " w" )
37
44
writeLines(code , con )
38
45
close(con )
@@ -57,13 +64,6 @@ sourceCpp <- function(file = "",
57
64
}
58
65
}
59
66
60
- # use an architecture/version specific subdirectory of the cacheDir
61
- # (since cached dynlibs can now perist across sessions we need to be
62
- # sure to invalidate them when R or Rcpp versions change)
63
- cacheDir <- path.expand(cacheDir )
64
- cacheDir <- normalizePath(cacheDir , winslash = " /" , mustWork = FALSE )
65
- cacheDir <- .sourceCppPlatformCacheDir(cacheDir )
66
-
67
67
# get the context (does code generation as necessary)
68
68
context <- .Call(" sourceCppContext" , PACKAGE = " Rcpp" ,
69
69
file , code , rebuild , cacheDir , .Platform )
0 commit comments