From 4cd9cb4a90550e0c45c85b0b00ca8a72ed13fdb4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 22 Mar 2023 18:35:59 +0200 Subject: meson: Really fix git version parsing The previous attempt to fix git version parsing in commit d34cefad1791 ("meson: Fix git version parsing") was too naive, and didn't take into account cases where the libcamera git version contains no or multiple '+' signs. Fixing this is more complex than a one-liner change, as meson doesn't support Python-style slicing of arrays or a length method on strings. The simplest and most versatile option is to patch the version string in the gen-version.sh script. Do so, and clarify the comments related to version handling in meson.build. Fixes: d34cefad1791 ("meson: Fix git version parsing") Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain --- utils/gen-version.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'utils') diff --git a/utils/gen-version.sh b/utils/gen-version.sh index eb7c7268..e1f7ca7b 100755 --- a/utils/gen-version.sh +++ b/utils/gen-version.sh @@ -5,6 +5,7 @@ build_dir="$1" src_dir="$2" +project_version="$3" # If .tarball-version exists, output the version string from the file and exit. # This file is auto-generated on a 'meson dist' command from the run-dist.sh @@ -43,6 +44,13 @@ then fi git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))" +# If a project version is provided, use it to replace the version number. +if [ -n "$project_version" ] +then + version=$(echo "$version" | sed -e 's/^[^-]*-//') + version="v$project_version-$version" +fi + # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from # of the git SHA1 and remove the initial 'v'. version=$(echo "$version" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-) -- cgit v1.2.1