summaryrefslogtreecommitdiff
path: root/metadata/install-qa-check.d
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2025-04-18 16:49:41 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2025-04-18 18:22:05 +0300
commit990824fd6ce441a4be967f621caa30f39313e2c1 (patch)
tree2cb5c720eb1b1361fa58e9c3173e3870e8ba892a /metadata/install-qa-check.d
parent6f4cda80856f9d0a6f817a5e72d4451bce525a6c (diff)
downloadgentoo-990824fd6ce441a4be967f621caa30f39313e2c1.tar.gz
gentoo-990824fd6ce441a4be967f621caa30f39313e2c1.tar.bz2
gentoo-990824fd6ce441a4be967f621caa30f39313e2c1.zip
metadata/install-qa-check.d: Check for missing RUST_MIN_VER for edition=2024
Closes: https://github.com/gentoo/gentoo/pull/41578 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'metadata/install-qa-check.d')
-rw-r--r--metadata/install-qa-check.d/60cargo-eclass36
1 files changed, 36 insertions, 0 deletions
diff --git a/metadata/install-qa-check.d/60cargo-eclass b/metadata/install-qa-check.d/60cargo-eclass
new file mode 100644
index 000000000000..a80d53449a9d
--- /dev/null
+++ b/metadata/install-qa-check.d/60cargo-eclass
@@ -0,0 +1,36 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# QA check: ensure cargo based ebuilds define correct RUST_MIN_VER
+# Maintainer: Rust Project <rust@gentoo.org>
+
+cargo_ver_check() {
+ has cargo ${INHERITED} || return
+
+ # First version of Rust to support that edition
+ declare -A RUST_EDITIONS=(
+ [2024]="1.85.0"
+ #[2021]="1.56.0" # our oldest rust version is 1.74.0
+ )
+
+ # Maximum value for "edition" across Cargo.toml files
+ local cargo_toml_edition=$(
+ find "${S}" -name Cargo.toml -exec sed -n -e 's/^\s*edition\s*=\s*"\([0-9]*\)"\s*$/\1/p' {} \+ |
+ sort -n |
+ tail -n 1
+ )
+ if [[ -n ${cargo_toml_edition} ]]; then
+ local min_rust_ver="${RUST_EDITIONS[${cargo_toml_edition}]}"
+ if [[ -n ${min_rust_ver} ]] && ver_test "${RUST_MIN_VER:-0}" -lt "${min_rust_ver}"; then
+ eqawarn
+ eqawarn "QA Notice: found Cargo.toml file which specifies edition=\"${cargo_toml_edition}\""
+ eqawarn "which requires RUST_MIN_VER=\"${min_rust_ver}\""
+ eqawarn
+ fi
+ fi
+}
+
+cargo_ver_check
+: # guarantee successful exit
+
+# vim:ft=sh