summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-03-22 18:35:59 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-04-05 07:16:07 +0300
commit4cd9cb4a90550e0c45c85b0b00ca8a72ed13fdb4 (patch)
tree8fd31ac1d5d9ca6179594a5c285588c1cc243793 /utils
parentac7511dc4c594f567ddff27ccc02c30bf6c00bfd (diff)
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/gen-version.sh8
1 files changed, 8 insertions, 0 deletions
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-)