Skip to content

Commit

Permalink
Update embedded pkgbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Nov 15, 2024
1 parent 0e0c0cb commit a0ec42f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/library/pkgbuild/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: pkgbuild
Title: Find Tools Needed to Build R Packages
Version: 1.4.4
Version: 1.4.5
Authors@R: c(
person("Hadley", "Wickham", role = "aut"),
person("Jim", "Hester", role = "aut"),
Expand All @@ -15,18 +15,18 @@ URL: https://github.com/r-lib/pkgbuild, https://pkgbuild.r-lib.org
BugReports: https://github.com/r-lib/pkgbuild/issues
Depends: R (>= 3.5)
Imports: callr (>= 3.2.0), cli (>= 3.4.0), desc, processx, R6
Suggests: covr, cpp11, knitr, mockery, Rcpp, rmarkdown, testthat (>=
3.0.0), withr (>= 2.3.0)
Suggests: covr, cpp11, knitr, Rcpp, rmarkdown, testthat (>= 3.2.0),
withr (>= 2.3.0)
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2024-03-17 14:13:01 UTC; gaborcsardi
Packaged: 2024-10-28 13:41:37 UTC; gaborcsardi
Author: Hadley Wickham [aut],
Jim Hester [aut],
Gábor Csárdi [aut, cre],
Posit Software, PBC [cph, fnd]
Maintainer: Gábor Csárdi <csardi.gabor@gmail.com>
Repository: CRAN
Date/Publication: 2024-03-17 14:40:02 UTC
Date/Publication: 2024-10-28 16:20:02 UTC
8 changes: 8 additions & 0 deletions src/library/pkgbuild/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# pkgbuild 1.4.5

* pkgbuild now does a better job at finding Rtools 4.3 and 4.4 if they
were not installed from an installer.

* pkgbuild now detects Rtools correctly from the Windows registry
again for Rtools 4.3 and 4.4

# pkgbuild 1.4.4

* pkgbuild now supports R 4.4.x and Rtools44 (#183).
Expand Down
5 changes: 5 additions & 0 deletions src/library/pkgbuild/R/rtools-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
),
Expand Down
4 changes: 4 additions & 0 deletions src/library/pkgbuild/R/rtools-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
37 changes: 22 additions & 15 deletions src/library/pkgbuild/R/rtools.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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") {
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"))) {
Expand Down Expand Up @@ -212,6 +211,12 @@ has_rtools <- function(debug = FALSE) {
}

# Otherwise it must be ok :)

# Recently Rtools is versioned properly
from_registry$version <- sub(
"^([0-9]+[.][0-9]+)[.].*$", "\\1",
from_registry$version
)
rtools_path_set(from_registry)
TRUE
}
Expand Down Expand Up @@ -283,7 +288,9 @@ is_compatible <- function(rtools) {
}

stopifnot(is.rtools(rtools))
info <- version_info[[rtools$version]]
version <- rtools$version
version <- sub("^([0-9]+[.][0-9]+)[.].*$", "\\1", version)
info <- version_info[[version]]
if (is.null(info)) {
return(FALSE)
}
Expand Down

0 comments on commit a0ec42f

Please sign in to comment.