From 60c56be85fed2fffa4bce2828ac9203aeb3f8c93 Mon Sep 17 00:00:00 2001 From: Felix Singer Date: Sun, 17 Oct 2021 14:54:12 +0200 Subject: [PATCH] util/crossgcc/buildgcc: Allow printing only the version In preperation to CB:58396, add the parameter `-W|--print-version`, which allows printing the content of `CROSSGCC_VERSION`. In combination with CB:58396, this can be used to pre-set the variable in case of the git history is not accessible. Change-Id: I9a205ca0ecb0ece47eb5d8fa73706478354512ff Signed-off-by: Felix Singer Reviewed-on: https://review.coreboot.org/c/coreboot/+/58395 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber --- util/crossgcc/buildgcc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index f9fff89b38..a3d9cad4bb 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -557,6 +557,7 @@ myhelp() printf " $0 [-h|--help]\n\n" printf "Options:\n" + printf " [-W|--print-version Print machine readable version\n" printf " [-V|--version] print version number and exit\n" printf " [-h|--help] print this help and exit\n" printf " [-c|--clean] remove temporary files before build\n" @@ -926,12 +927,12 @@ getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c getoptbrand="$(getopt -V 2>/dev/null | sed -e '1!d' -e 's,^\(......\).*,\1,')" if [ "${getoptbrand}" = "getopt" ]; then # Detected GNU getopt that supports long options. - args=$(getopt -l version,help,clean,directory:,bootstrap,bootstrap-only,platform:,languages:,package:,jobs:,destdir:,savetemps,scripting,ccache,supported:,urls,nocolor -o Vhcd:bBp:l:P:j:D:tSys:un -- "$@") + args=$(getopt -l print-version,version,help,clean,directory:,bootstrap,bootstrap-only,platform:,languages:,package:,jobs:,destdir:,savetemps,scripting,ccache,supported:,urls,nocolor -o WVhcd:bBp:l:P:j:D:tSys:un -- "$@") getopt_ret=$? eval set -- "$args" else # Detected non-GNU getopt - args=$(getopt Vhcd:bBp:l:P:j:D:tSys:un $*) + args=$(getopt WVhcd:bBp:l:P:j:D:tSys:un $*) getopt_ret=$? # shellcheck disable=SC2086 set -- $args @@ -944,6 +945,7 @@ fi while true ; do case "$1" in + -W|--print-version) shift; echo $CROSSGCC_VERSION; exit 0;; -V|--version) shift; myversion; exit 0;; -h|--help) shift; myhelp; exit 0;; -c|--clean) shift; clean=1;;