summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <asturm@gentoo.org>2024-12-13 19:00:16 +0100
committerAndreas Sturmlechner <asturm@gentoo.org>2024-12-17 23:14:02 +0100
commit10b4b0976610ae256e6f3bba5181ca57dfad0e08 (patch)
tree382a9b3c19654034c6ed8059e6095fdcdcac7968
parentprofiles: Mask steam-overlay's x11-libs/extest in wd40 feature (diff)
downloadgentoo-10b4b0976610ae256e6f3bba5181ca57dfad0e08.tar.gz
gentoo-10b4b0976610ae256e6f3bba5181ca57dfad0e08.tar.bz2
gentoo-10b4b0976610ae256e6f3bba5181ca57dfad0e08.zip
toolchain-funcs.eclass: Add tc-check-min_ver()
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
-rw-r--r--eclass/toolchain-funcs.eclass44
1 files changed, 44 insertions, 0 deletions
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 2911ed66e63c..0abed5b8d75e 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -647,6 +647,50 @@ _tc-has-openmp() {
return ${ret}
}
+# @FUNCTION: tc-check-min_ver
+# @USAGE: <gcc or clang> <minimum version>
+# @DESCRIPTION:
+# Minimum version of active GCC or Clang to require.
+#
+# You should test for any necessary minimum version in pkg_pretend in order to
+# warn the user of required toolchain changes. You must still check for it at
+# build-time, e.g.
+# @CODE
+# pkg_pretend() {
+# [[ ${MERGE_TYPE} != binary ]] && tc-check-min_ver gcc 13.2.0
+# }
+#
+# pkg_setup() {
+# [[ ${MERGE_TYPE} != binary ]] && tc-check-min_ver gcc 13.2.0
+# }
+# @CODE
+tc-check-min_ver() {
+ do_check() {
+ debug-print "Compiler version check for ${1}"
+ debug-print "Detected: ${2}"
+ debug-print "Required: ${3}"
+ if ver_test ${2} -lt ${3}; then
+ eerror "Your current compiler is too old for this package!"
+ die "Active compiler is too old for this package (found ${1} ${2})."
+ fi
+ }
+
+ case ${1} in
+ gcc)
+ tc-is-gcc || return
+ do_check GCC $(gcc-version) ${2}
+ ;;
+ clang)
+ tc-is-clang || return
+ do_check Clang $(clang-version) ${2}
+ ;;
+ *)
+ eerror "Unknown first parameter for ${FUNCNAME} - must be gcc or clang"
+ die "${FUNCNAME}: Parameter ${1} unknown"
+ ;;
+ esac
+}
+
# @FUNCTION: tc-check-openmp
# @DESCRIPTION:
# Test for OpenMP support with the current compiler and error out with