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')
# 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
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/"