@@ -213,7 +213,7 @@ compile <- function(fsub, build_dir = tempfile(paste0(fsub@name, "-build-"))) {
213213
214214 # Link against the same BLAS/LAPACK/Fortran libs as the running R
215215 # to support generated calls to vendor BLAS (e.g., dgemm, dgesv).
216- cfg <- quickr_r_cmd_config_value
216+ cfg <- quickr_cached_r_cmd_config_value
217217 BLAS_LIBS <- strsplit(cfg(" BLAS_LIBS" ), " [[:space:]]+" )[[1 ]]
218218 LAPACK_LIBS <- strsplit(cfg(" LAPACK_LIBS" ), " [[:space:]]+" )[[1 ]]
219219 FLIBS <- strsplit(cfg(" FLIBS" ), " [[:space:]]+" )[[1 ]]
@@ -326,39 +326,47 @@ compile <- function(fsub, build_dir = tempfile(paste0(fsub@name, "-build-"))) {
326326quickr_windows_add_dll_paths <- function (
327327 flags ,
328328 os_type = .Platform $ OS.type ,
329- config_value = quickr_r_cmd_config_value ,
329+ config_value = quickr_cached_r_cmd_config_value ,
330330 which = Sys.which
331331) {
332332 if (! identical(os_type , " windows" )) {
333- return (invisible (FALSE ))
333+ return (invisible (character () ))
334334 }
335+
336+ config_path <- function (value ) {
337+ value <- trimws(value )
338+ if (! nzchar(value )) {
339+ return (" " )
340+ }
341+ value <- sub(" ^\" ([^\" ]+)\" .*" , " \\ 1" , value )
342+ value <- sub(" ^'([^']+)'.*" , " \\ 1" , value )
343+ strsplit(value , " \\ s+" )[[1L ]][[1L ]]
344+ }
345+
335346 dirs <- flags [grepl(" ^-L" , flags )]
336347 dirs <- sub(" ^-L" , " " , dirs )
348+ dirs <- vapply(dirs , config_path , character (1 ))
337349 dirs <- dirs [nzchar(dirs )]
338350
339- bin_siblings <- file.path(dirs , " .." , " bin" )
351+ bin_siblings <- c(
352+ file.path(dirs , " .." , " bin" ),
353+ file.path(dirs , " .." , " .." , " bin" )
354+ )
340355
356+ config_binpref <- config_path(config_value(" BINPREF" ))
357+ if (nzchar(config_binpref ) && ! dir.exists(config_binpref )) {
358+ config_binpref <- dirname(config_binpref )
359+ }
341360 config_values <- c(
342- config_value(" BINPREF" ),
343361 config_value(" FC" ),
344362 config_value(" F77" ),
345363 config_value(" CC" ),
346364 config_value(" CXX" )
347365 )
348- config_paths <- vapply(
349- config_values ,
350- function (value ) {
351- value <- trimws(value )
352- if (! nzchar(value )) {
353- return (" " )
354- }
355- value <- sub(" ^\" ([^\" ]+)\" .*" , " \\ 1" , value )
356- value <- sub(" ^'([^']+)'.*" , " \\ 1" , value )
357- strsplit(value , " \\ s+" )[[1L ]][[1L ]]
358- },
359- character (1 )
360- )
361- config_bins <- unique(dirname(config_paths [nzchar(config_paths )]))
366+ config_paths <- vapply(config_values , config_path , character (1 ))
367+ config_bins <- dirname(config_paths [nzchar(config_paths )])
368+ config_bins <- config_bins [nzchar(config_bins ) & config_bins != " ." ]
369+ config_bins <- unique(c(config_binpref , config_bins ))
362370
363371 r_bin <- R.home(" bin" )
364372 r_bin_x64 <- file.path(r_bin , " x64" )
@@ -373,6 +381,16 @@ quickr_windows_add_dll_paths <- function(
373381 " RTOOLS_HOME"
374382 ))
375383 rtools_roots <- rtools_roots [nzchar(rtools_roots )]
384+ link_dirs <- gsub(" \\ " , " /" , dirs , fixed = TRUE )
385+ rtools_link_roots <- sub(
386+ " /(?:x86_64|aarch64)-w64-mingw32(?:\\ .static(?:\\ .posix)?)?/.*$" ,
387+ " " ,
388+ link_dirs
389+ )
390+ rtools_link_roots <- rtools_link_roots [
391+ nzchar(rtools_link_roots ) & rtools_link_roots != link_dirs
392+ ]
393+ rtools_roots <- unique(c(rtools_roots , rtools_link_roots ))
376394 rtools_bins <- unique(c(
377395 file.path(rtools_roots , " usr" , " bin" ),
378396 file.path(rtools_roots , " mingw64" , " bin" ),
@@ -399,8 +417,9 @@ quickr_windows_add_dll_paths <- function(
399417 dirs <- dirs [nzchar(dirs )]
400418 dirs <- dirs [dir.exists(dirs )]
401419 if (! length(dirs )) {
402- return (invisible (FALSE ))
420+ return (invisible (character () ))
403421 }
422+ dirs <- normalizePath(dirs , winslash = " \\ " , mustWork = FALSE )
404423
405424 path <- Sys.getenv(" PATH" , unset = " " )
406425 existing <- strsplit(path , " ;" , fixed = TRUE )[[1 ]]
@@ -414,10 +433,9 @@ quickr_windows_add_dll_paths <- function(
414433 to_add <- dirs [! dirs_norm %in% existing_norm ]
415434 if (length(to_add )) {
416435 Sys.setenv(PATH = paste(c(to_add , existing ), collapse = " ;" ))
417- return (invisible (TRUE ))
418436 }
419437
420- invisible (FALSE )
438+ invisible (dirs )
421439}
422440
423441
0 commit comments