summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-10-18 10:29:41 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-19 13:14:54 +0300
commit54637a615dcdac20f1f61a017d3bae429aa389e4 (patch)
tree97020ff4dfb5ec24aa88b4e8ba6991b3d5c36e00 /utils
parent40d994778127cc95b0c019017500695e88b4ca44 (diff)
utils: gen-version: Pass the meson source root to the gen-version.sh script
The gen-version.sh script expects to be called from a git repo, and sets its src_root variable accordingly. This may not always be the case if it is built from a tarball source - full support for which is in a future commit. The MESON_SOURCE_ROOT environnement variable does not get set when called from the meson vcs_tag() function, but does when called from the run_command() function, so that cannot be used either. Instead, explicitly pass the meson source root to the gen-version.sh script. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/gen-version.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/utils/gen-version.sh b/utils/gen-version.sh
index b09ad495..d0048179 100755
--- a/utils/gen-version.sh
+++ b/utils/gen-version.sh
@@ -4,10 +4,16 @@
# Generate a version string using git describe
build_dir="$1"
+src_dir="$2"
# Bail out if the directory isn't under git control
-src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
-src_dir=$(readlink -f "$src_dir/..")
+git_dir=$(git rev-parse --git-dir 2>&1) || exit 1
+
+# Derive the source directory from the git directory if not specified.
+if [ -z "$src_dir" ]
+then
+ src_dir=$(readlink -f "$git_dir/..")
+fi
# Get a short description from the tree.
version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)