|
112 | 112 | # function should return (a list with additional includes, environment |
113 | 113 | # variables, such as PKG_LIBS, and other compilation context). |
114 | 114 | 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 | + } |
115 | 122 | candidates <- c( |
116 | 123 | "RcppTskit.so", # Unix/Linux and macOS |
117 | 124 | "RcppTskit.dylib", # macOS (backup to RcppTskit.so) |
118 | 125 | "RcppTskit.dll.a", # Windows (MinGW/Rtools) |
119 | 126 | "RcppTskit.lib", # Windows (MSVC, backup) |
120 | 127 | "RcppTskit.dll" # Windows (DLL, backup) |
121 | 128 | ) |
122 | | - libpaths <- file.path(libdir, candidates) |
| 129 | + libpaths <- sapply( |
| 130 | + libdirs, |
| 131 | + function(dir) file.path(dir, candidates), |
| 132 | + USE.NAMES = FALSE |
| 133 | + ) |
123 | 134 | 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 | + ) |
126 | 140 | } |
127 | 141 | list(env = list(PKG_LIBS = shQuote(libfile))) |
128 | 142 | }) |
|
0 commit comments