From 4364bf8f380f93f3bad68e976da1b90a374d2193 Mon Sep 17 00:00:00 2001 From: alexhroom Date: Wed, 11 Sep 2024 19:21:01 +0100 Subject: [PATCH 1/4] improved rust check --- src/library/tools/R/check.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index d06b43e557b..10c5990dd5f 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3925,15 +3925,16 @@ add_dummies <- function(dir, Log) check_rust <- function() { - ## It is impossible to tell definiitively if a package - ## compiles rust code. SystemRequirements in DESCRIPTION is - ## fres-format, and only advisory. So we look at the - ## installation log, which we found in check_src() + ## A Cargo.toml file is used to identify a rust package, + ## so check for Cargo.toml under src to see if rust code + ## is compiled in the crate if (is.na(InstLog)) return (NA) + srcd <- file.path(pkgdir, "src") + if (length(Sys.glob(paste0(srcd, "/**/Cargo.toml"))) == 0) return (NA) ##message("InstLog = ", InstLog) lines <- readLines(InstLog, warn = FALSE) l1 <- grep("(cargo build| Compiling )", lines) - if(!length(l1)) return(NA) + if(!length(l1)) return (NA) l2 <- grep(" Compiling ", lines) checkingLog(Log, "Rust compilation") msg <- character(); OK <- TRUE From cb4a62f517ba0714abd578c2a135c950bdd1537c Mon Sep 17 00:00:00 2001 From: "Alex H. Room" <69592136+alexhroom@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:00:35 +0100 Subject: [PATCH 2/4] Update src/library/tools/R/check.R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lluís Revilla --- src/library/tools/R/check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 10c5990dd5f..f7983f5aab0 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3930,7 +3930,7 @@ add_dummies <- function(dir, Log) ## is compiled in the crate if (is.na(InstLog)) return (NA) srcd <- file.path(pkgdir, "src") - if (length(Sys.glob(paste0(srcd, "/**/Cargo.toml"))) == 0) return (NA) + if (length(list.files(path = srcd, pattern = "Cargo.toml", recursive = TRUE))) == 0) return (NA) ##message("InstLog = ", InstLog) lines <- readLines(InstLog, warn = FALSE) l1 <- grep("(cargo build| Compiling )", lines) From 17722c6924878b1a66ab0d9fb6ed6e8ad752d691 Mon Sep 17 00:00:00 2001 From: alexhroom Date: Fri, 13 Sep 2024 18:16:29 +0100 Subject: [PATCH 3/4] added checks for rustc and cargo in DESCRIPTION --- src/library/tools/R/check.R | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index f7983f5aab0..86929ce576d 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3925,15 +3925,15 @@ add_dummies <- function(dir, Log) check_rust <- function() { - ## A Cargo.toml file is used to identify a rust package, + ## A Cargo.toml file is used to identify a rust package, ## so check for Cargo.toml under src to see if rust code ## is compiled in the crate if (is.na(InstLog)) return (NA) srcd <- file.path(pkgdir, "src") - if (length(list.files(path = srcd, pattern = "Cargo.toml", recursive = TRUE))) == 0) return (NA) + if (length(list.files(path = srcd, pattern = "Cargo.toml", recursive = TRUE)) == 0) return (NA) ##message("InstLog = ", InstLog) lines <- readLines(InstLog, warn = FALSE) - l1 <- grep("(cargo build| Compiling )", lines) + l1 <- grep(r"(cargo\N+build| Compiling )", lines) if(!length(l1)) return (NA) l2 <- grep(" Compiling ", lines) checkingLog(Log, "Rust compilation") @@ -3950,6 +3950,22 @@ add_dummies <- function(dir, Log) msg <- c(msg, "No rustc version reported prior to compilation") ## print(lines) } + desc <- .read_description("DESCRIPTION") + sysreqs <- parse_description_field(desc, "SystemRequirements", default = FALSE) + if(!sysreqs) { + OK <- FALSE + msg <- c(msg, "Package compiles Rust but SystemRequirements not provided") + } + rustc_desc <- any(grep("rustc", sysreqs, ignore.case = TRUE)) + cargo_desc <- any(grep("cargo", sysreqs, ignore.case = TRUE)) + if(!rustc_desc) { + OK <- FALSE + msg <- c(msg, "Package compiles Rust but rustc not in DESCRIPTION") + } + if(!cargo_desc) { + OK <- FALSE + msg <- c(msg, "Package compiles Rust but cargo not in DESCRIPTION") + } if(OK) resultLog(Log, "OK") else { From 139b910852c26e813dbe22c2761afde9d1fe176c Mon Sep 17 00:00:00 2001 From: "Alex H. Room" <69592136+alexhroom@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:06:11 +0100 Subject: [PATCH 4/4] add fixed to grep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lluís Revilla --- src/library/tools/R/check.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/library/tools/R/check.R b/src/library/tools/R/check.R index 86929ce576d..1f3fad89824 100644 --- a/src/library/tools/R/check.R +++ b/src/library/tools/R/check.R @@ -3956,8 +3956,8 @@ add_dummies <- function(dir, Log) OK <- FALSE msg <- c(msg, "Package compiles Rust but SystemRequirements not provided") } - rustc_desc <- any(grep("rustc", sysreqs, ignore.case = TRUE)) - cargo_desc <- any(grep("cargo", sysreqs, ignore.case = TRUE)) + rustc_desc <- any(grep("rustc", sysreqs, ignore.case = TRUE, fixed = TRUE)) + cargo_desc <- any(grep("cargo", sysreqs, ignore.case = TRUE, fixed = TRUE)) if(!rustc_desc) { OK <- FALSE msg <- c(msg, "Package compiles Rust but rustc not in DESCRIPTION")