Skip to content

Commit 440c0a0

Browse files
committed
Testing CI for Make configure.R::setRcppTskitLibAndFlags() portable across Unix/Linux/macOS/Windows platforms
Fixes #19
1 parent 67b028b commit 440c0a0

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

RcppTskit/tools/configure.R

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
#!/usr/bin/env Rscript
22

3-
# Set platform specific name of RcppTskit library and add appropriate flags
3+
# TODO: Make configure.R::setRcppTskitLibAndFlags() portable across Unix/Linux/macOS/Windows platforms #19
4+
# https://github.com/HighlanderLab/RcppTskit/issues/19
5+
6+
# Set platform-specific linker flags for RcppTskit
47
setRcppTskitLibAndFlags <- function() {
5-
if (.Platform$OS.type == "unix") {
6-
# Unix/Linux & macOS
8+
sysname <- Sys.info()[["sysname"]]
9+
os_type <- .Platform$OS.type
10+
if (os_type == "unix") {
711
libname <- "RcppTskit.so"
8-
} else if (.Platform$OS.type == "windows") {
9-
libname <- "RcppTskit.dll.a" # MinGW/Rtools (default)
10-
# "RcppTskit.lib" # MSVC (backup to MinGW/Rtools)
11-
# "RcppTskit.dll" # DLL (backup to MinGW/Rtools)
12+
if (sysname == "Darwin") {
13+
# macOS: Use -install_name with @rpath for better portability
14+
return(paste0("-Wl,-install_name,@rpath/", libname))
15+
} else {
16+
# Linux/Solaris/FreeBSD: Use -soname for shared library versioning
17+
return(paste0("-Wl,-soname,", libname))
18+
}
19+
} else if (os_type == "windows") {
20+
# Windows: Rtools 4.x/5.x uses --out-implib for import libraries
21+
# libname should typically be the import library .dll.a
22+
libname <- "RcppTskit.dll.a"
23+
return(paste0("-Wl,--out-implib,", libname))
1224
} else {
13-
stop("Unknown .Platform$OS.type!")
25+
stop(sprintf("Unsupported platform: %s (%s)", sysname, os_type))
1426
}
15-
# TODO: Make configure.R::setRcppTskitLibAndFlags() portable across Unix/Linux/macOS/Windows platforms #19
16-
# https://github.com/HighlanderLab/RcppTskit/issues/19
17-
ret <- paste0("-Wl,-install_name,@rpath/", libname)
18-
return(ret)
1927
}
2028

2129
# Render a Makevars file from a template by replacing placeholders.

0 commit comments

Comments
 (0)