Skip to content

Commit dbf03ed

Browse files
committed
More work for #41
1 parent 35b8728 commit dbf03ed

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

RcppTskit/R/RcppTskit-package.R

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,31 @@
112112
# function should return (a list with additional includes, environment
113113
# variables, such as PKG_LIBS, and other compilation context).
114114
libdir <- system.file("libs", package = "RcppTskit")
115+
if (!nzchar(libdir)) {
116+
stop("Unable to locate the RcppTskit libs directory!")
117+
}
118+
libdirs <- libdir
119+
if (.Platform$OS.type == "windows") {
120+
libdirs <- c(libdirs, file.path(libdir, .Platform$r_arch))
121+
}
115122
candidates <- c(
116123
"RcppTskit.so", # Unix/Linux and macOS
117124
"RcppTskit.dylib", # macOS (backup to RcppTskit.so)
118125
"RcppTskit.dll.a", # Windows (MinGW/Rtools)
119126
"RcppTskit.lib", # Windows (MSVC, backup)
120127
"RcppTskit.dll" # Windows (DLL, backup)
121128
)
122-
libpaths <- file.path(libdir, candidates)
129+
libpaths <- sapply(
130+
libdirs,
131+
function(dir) file.path(dir, candidates),
132+
USE.NAMES = FALSE
133+
)
123134
libfile <- libpaths[file.exists(libpaths)][1]
124-
if (length(libfile) < 1) {
125-
stop("Unable to locate the RcppTskit library file in ", libdir)
135+
if (is.na(libfile) || !nzchar(libfile)) {
136+
stop(
137+
"Unable to locate the RcppTskit library file in: ",
138+
paste(libdirs, collapse = ", ")
139+
)
126140
}
127141
list(env = list(PKG_LIBS = shQuote(libfile)))
128142
})

0 commit comments

Comments
 (0)