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>
This commit is contained in:
parent
40d9947781
commit
54637a615d
3 changed files with 13 additions and 4 deletions
|
@ -17,7 +17,8 @@ project('libcamera', 'c', 'cpp',
|
||||||
# git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from
|
# git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from
|
||||||
# libcamera_git_version.
|
# libcamera_git_version.
|
||||||
libcamera_git_version = run_command('utils/gen-version.sh',
|
libcamera_git_version = run_command('utils/gen-version.sh',
|
||||||
meson.build_root()).stdout().strip()
|
meson.build_root(),
|
||||||
|
meson.source_root()).stdout().strip()
|
||||||
if libcamera_git_version == ''
|
if libcamera_git_version == ''
|
||||||
libcamera_git_version = meson.project_version()
|
libcamera_git_version = meson.project_version()
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -95,7 +95,9 @@ libcamera_sources += control_sources
|
||||||
|
|
||||||
gen_version = meson.source_root() / 'utils' / 'gen-version.sh'
|
gen_version = meson.source_root() / 'utils' / 'gen-version.sh'
|
||||||
|
|
||||||
version_cpp = vcs_tag(command : [gen_version, meson.build_root()],
|
# Use vcs_tag() and not configure_file() or run_command(), to ensure that the
|
||||||
|
# version gets updated with every ninja build and not just at meson setup time.
|
||||||
|
version_cpp = vcs_tag(command : [gen_version, meson.build_root(), meson.source_root()],
|
||||||
input : 'version.cpp.in',
|
input : 'version.cpp.in',
|
||||||
output : 'version.cpp',
|
output : 'version.cpp',
|
||||||
fallback : meson.project_version())
|
fallback : meson.project_version())
|
||||||
|
|
|
@ -4,10 +4,16 @@
|
||||||
# Generate a version string using git describe
|
# Generate a version string using git describe
|
||||||
|
|
||||||
build_dir="$1"
|
build_dir="$1"
|
||||||
|
src_dir="$2"
|
||||||
|
|
||||||
# Bail out if the directory isn't under git control
|
# Bail out if the directory isn't under git control
|
||||||
src_dir=$(git rev-parse --git-dir 2>&1) || exit 1
|
git_dir=$(git rev-parse --git-dir 2>&1) || exit 1
|
||||||
src_dir=$(readlink -f "$src_dir/..")
|
|
||||||
|
# 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.
|
# Get a short description from the tree.
|
||||||
version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
|
version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue