-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathinstall.libs.R
More file actions
79 lines (60 loc) · 2.23 KB
/
install.libs.R
File metadata and controls
79 lines (60 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# !diagnostics suppress=R_PACKAGE_DIR,SHLIB_EXT,R_ARCH
.install.libs <- function() {
# copy default library
files <- Sys.glob(paste0("*", SHLIB_EXT))
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH))
dir.create(dest, recursive = TRUE, showWarnings = FALSE)
file.copy(files, dest, overwrite = TRUE)
# copy symbols if available
if (file.exists("symbols.rds"))
file.copy("symbols.rds", dest, overwrite = TRUE)
# also copy to package 'libs' folder, for devtools
libsDest <- paste0("../libs", R_ARCH)
dir.create(libsDest, recursive = TRUE, showWarnings = FALSE)
file.copy(files, libsDest, overwrite = TRUE)
# copy tbb (NOTE: do not use inst/ folder as R will resolve symlinks,
# behavior which we do _not_ want here!)
tbbDest <- file.path(R_PACKAGE_DIR, paste0("lib", R_ARCH))
dir.create(tbbDest, recursive = TRUE, showWarnings = FALSE)
# check for bundled vs. system tbb
tbbRoot <- Sys.getenv("TBB_ROOT", unset = NA)
tbbLib <- Sys.getenv("TBB_LIB", unset = NA)
if (is.na(tbbLib) && !is.na(tbbRoot))
tbbLib <- file.path(tbbRoot, "lib")
# note: on Linux, TBB gets compiled with extensions like
# '.so.2', so be ready to handle those
shlibPattern <- switch(
Sys.info()[["sysname"]],
Windows = "^tbb.*\\.dll$",
Darwin = "^libtbb.*\\.dylib$",
"^libtbb.*\\.so.*$"
)
if (is.na(tbbLib)) {
# using bundled TBB
tbbLibs <- list.files(
path = "tbb/build/lib_release",
pattern = shlibPattern,
full.names = TRUE
)
# don't copy symlinks
tbbLibs <- tbbLibs[!nzchar(Sys.readlink(tbbLibs))]
# perform the copy
file.copy(tbbLibs, tbbDest)
} else {
# using system tbb
tbbLibs <- list.files(
path = tbbLib,
pattern = shlibPattern,
full.names = TRUE
)
# don't copy symlinks
tbbLibs <- tbbLibs[!nzchar(Sys.readlink(tbbLibs))]
# copy / link the libraries
useSymlinks <- Sys.getenv("TBB_USE_SYMLINKS", unset = "TRUE")
if (useSymlinks)
file.symlink(tbbLibs, tbbDest)
else
file.copy(tbbLibs, tbbDest)
}
}
.install.libs()