From 2f6936bd926b6d4f21680e2cdc160fc580c3ecb3 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Tue, 24 Sep 2019 18:31:38 +0200 Subject: util/getversion,meson: Add script to allow version info with Meson Add `util/getversion.sh` that retrieves version information from a `versioninfo.inc` (what we use for releases) if present or uses `util/getrevision.sh` if not. Let Meson use it for flashrom's version. It seems Meson doesn't generate the manual page at all, so the `--man-date` command is currently unused. Change-Id: I401e5638509c4a573bc0cb17ebc5fa76df9700b5 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/flashrom/+/35561 Tested-by: build bot (Jenkins) Reviewed-by: Mario Limonciello Reviewed-by: Richard Hughes Reviewed-by: David Hendricks Reviewed-by: Angel Pons --- meson.build | 2 +- util/getversion.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100755 util/getversion.sh diff --git a/meson.build b/meson.build index d1f663fb1..b63875e23 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('flashromutils', 'c', - version : '1.0', + version : run_command('util/getversion.sh', '-v').stdout().strip(), license : 'GPL-2.0', meson_version : '>=0.47.0', default_options : ['warning_level=2', 'c_std=c99'], diff --git a/util/getversion.sh b/util/getversion.sh new file mode 100755 index 000000000..d3810d29b --- /dev/null +++ b/util/getversion.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# +# This file is part of the flashrom project. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +version() { + if [ -r versioninfo.inc ]; then + v=$(sed -n 's/^VERSION = //p' versioninfo.inc) + else + v=$($(dirname ${0})/getrevision.sh --revision) + if [ $? -ne 0 ]; then + v='unknown' + fi + fi + + echo ${v} +} + +mandate() { + if [ -r versioninfo.inc ]; then + d=$(sed -n 's/^MAN_DATE = //p' versioninfo.inc) + else + d=$($(dirname ${0})/getrevision.sh --date flashrom.8.tmpl) + if [ $? -ne 0 ]; then + d='unknown' + fi + fi + + echo ${d} +} + +show_help() { + echo "Usage: + ${0} + +Commands + -h or --help + this message + -v or --version + return current/release flashrom version + -m or --man-date + return current/release date of the manual page +" +} + +if [ $# -ne 1 ]; then + show_help + echo "Error: Only exactly one command allowed.">&2 + exit 1 +fi + +case $1 in + -h|--help) show_help;; + -m|--man-date) mandate;; + -v|--version) version;; + *) + show_help + echo "Error: Invalid option: $1" + exit 1 + ;; +esac -- cgit v1.2.3