meson: Use custom_target() instead of vcs_tag()

vsc_tag() always reruns even if the vcs-tag option is disabled. Let's
use custom_target() instead so that we can only enable build_always_stale
if the vcs-tag option is enabled.
This commit is contained in:
Daan De Meyer
2025-04-09 13:54:22 +02:00
parent ad04dc4116
commit b2634bde3c
2 changed files with 12 additions and 8 deletions

View File

@@ -1988,11 +1988,12 @@ endif
conf.set_quoted('VERSION_TAG', version_tag)
vcs_tag = get_option('vcs-tag')
version_h = vcs_tag(
version_h = custom_target('version',
build_always_stale : vcs_tag,
input : 'src/version/version.h.in',
output : 'version.h',
fallback : '',
command : [vcs_tag ? 'tools/vcs-tag.sh' : 'true', get_option('mode')],
capture : true,
command : ['tools/vcs-tag.sh', '@INPUT@', get_option('mode'), vcs_tag ? '1' : '0'],
)
shared_lib_tag = get_option('shared-lib-tag')

View File

@@ -2,12 +2,13 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
MODE="$1"
INPUT="$1"
MODE="$2"
ENABLED="$3"
if ! [[ -d .git ]] ||
! command -v git >/dev/null ||
git describe --tags --exact-match &>/dev/null
if ! ((ENABLED)) || ! [[ -d .git ]] || ! command -v git >/dev/null || git describe --tags --exact-match &>/dev/null
then
sed "$INPUT" -e "s/@VCS_TAG@//"
exit 0
fi
@@ -17,4 +18,6 @@ else
DIRTY=""
fi
echo "-g$(git describe --abbrev=7 --match="" --always $DIRTY)"
TAG="-g$(git describe --abbrev=7 --match="" --always $DIRTY)"
sed "$INPUT" -e "s/@VCS_TAG@/$TAG/"