blob: 4fd014b2287e67073611d0fb04b0c0819b2f978d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# 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
local min_rust_ver= min_rust_source=
# 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 "${WORKDIR}" -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} && -n ${RUST_EDITIONS[${cargo_toml_edition}]} ]]; then
min_rust_ver="${RUST_EDITIONS[${cargo_toml_edition}]}"
min_rust_source="found Cargo.toml file which specifies edition=\"${cargo_toml_edition}\""
fi
# Maximum value for "rust-version" across Cargo.toml files
local cargo_toml_rust_version=$(
find "${WORKDIR}" -name Cargo.toml -exec sed -n -e 's/^\s*rust-version\s*=\s*"\([0-9.]*\)"\s*$/\1/p' {} \+ |
sort -V |
tail -n 1
)
if [[ -n ${cargo_toml_rust_version} ]] && ver_test "${min_rust_ver:-0}" -lt "${cargo_toml_rust_version}"; then
min_rust_ver=${cargo_toml_rust_version}
min_rust_source="found Cargo.toml file which specifies rust-version=\"${cargo_toml_rust_version}\""
fi
if [[ -n ${min_rust_ver} ]] && ver_test "${RUST_MIN_VER:-0}" -lt "${min_rust_ver}"; then
eqawarn
eqawarn "QA Notice: ${min_rust_source}"
eqawarn "which requires RUST_MIN_VER=\"${min_rust_ver}\""
eqawarn
fi
}
cargo_ver_check
: # guarantee successful exit
# vim:ft=sh
|