diff --git a/NEWS.md b/NEWS.md index e3b3415..5310e23 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # pkgbuild (development version) +* pkgbuild now does a better job at finding Rtools 4.3 and 4.4 if they + were not installed from an installer. + # pkgbuild 1.4.4 * pkgbuild now supports R 4.4.x and Rtools44 (#183). diff --git a/R/rtools-metadata.R b/R/rtools-metadata.R index c935672..1404be7 100644 --- a/R/rtools-metadata.R +++ b/R/rtools-metadata.R @@ -75,6 +75,11 @@ version_info <- list( ), "4.3" = list( version_min = "4.3.0", + version_max = "4.3.99", + path = "usr/bin" + ), + "4.4" = list( + version_min = "4.4.0", version_max = "99.99.99", path = "usr/bin" ), diff --git a/R/rtools-path.R b/R/rtools-path.R index 0861c10..1852383 100644 --- a/R/rtools-path.R +++ b/R/rtools-path.R @@ -14,6 +14,10 @@ scan_path_for_rtools <- function(debug = FALSE) { # We have a candidate install_path install_path <- dirname(dirname(ls_path)) + # ls is one more directory down on recent rtools + if (basename(install_path) == "usr") { + install_path <- dirname(install_path) + } gcc_path <- Sys.which("gcc") if (debug) { diff --git a/R/rtools.R b/R/rtools.R index bd6a5bc..62a403c 100644 --- a/R/rtools.R +++ b/R/rtools.R @@ -40,7 +40,6 @@ has_rtools <- function(debug = FALSE) { rtools_path_set(rtools(rtools44_aarch64_home, "4.4")) return(TRUE) } - return(FALSE) } # R 4.4.0 or later @@ -53,11 +52,11 @@ has_rtools <- function(debug = FALSE) { rtools_path_set(rtools(rtools44_home, "4.4")) return(TRUE) } - return(FALSE) } # R 4.3.0 or later on ARM64 - if (getRversion() >= "4.3.0" && grepl("aarch", R.version$platform)) { + if (getRversion() >= "4.3.0" && getRversion() < "4.4.0" && + grepl("aarch", R.version$platform)) { rtools43_aarch64_home <- Sys.getenv("RTOOLS43_AARCH64_HOME", "C:\rtools43-aarch64") if (file.exists(file.path(rtools43_aarch64_home, "usr", "bin"))) { if (debug) { @@ -66,11 +65,10 @@ has_rtools <- function(debug = FALSE) { rtools_path_set(rtools(rtools43_aarch64_home, "4.3")) return(TRUE) } - return(FALSE) } # R 4.3.0 or later - if (getRversion() >= "4.3.0") { + if (getRversion() >= "4.3.0" && getRversion() < "4.4.0") { rtools43_home <- Sys.getenv("RTOOLS43_HOME", "C:\\rtools43") if (file.exists(file.path(rtools43_home, "usr", "bin"))) { if (debug) { @@ -79,25 +77,26 @@ has_rtools <- function(debug = FALSE) { rtools_path_set(rtools(rtools43_home, "4.3")) return(TRUE) } - return(FALSE) } # R 4.2.x or later and ucrt? - ucrt <- is_ucrt() - if (ucrt) { - rtools42_home <- Sys.getenv("RTOOLS42_HOME", "C:\\rtools42") - if (file.exists(file.path(rtools42_home, "usr", "bin"))) { - if (debug) { - cat("Found in Rtools 4.2 installation folder\n") + if (getRversion() >= "4.2.0" && getRversion() < "4.3.0") { + ucrt <- is_ucrt() + if (ucrt) { + rtools42_home <- Sys.getenv("RTOOLS42_HOME", "C:\\rtools42") + if (file.exists(file.path(rtools42_home, "usr", "bin"))) { + if (debug) { + cat("Found in Rtools 4.2 installation folder\n") + } + rtools_path_set(rtools(rtools42_home, "4.2")) + return(TRUE) } - rtools_path_set(rtools(rtools42_home, "4.2")) - return(TRUE) } } # In R 4.0 we can use RTOOLS40_HOME, recent versions of Rtools40 work fine # with ucrt as well, currently. - if (is_R4()) { + if (getRversion() >= "4.0.0" && getRversion() < "4.3.0") { rtools40_home <- Sys.getenv("RTOOLS40_HOME", "C:\\rtools40") fld <- if (ucrt) "ucrt64" else "usr" if (file.exists(file.path(rtools40_home, fld, "bin"))) {