From: Daan De Meyer Date: Wed, 9 Apr 2025 11:54:22 +0000 (+0200) Subject: meson: Use custom_target() instead of vcs_tag() X-Git-Tag: v258-rc1~858^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2634bde3cdf034253335db750afbfac2f40028c;p=thirdparty%2Fsystemd.git 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. --- diff --git a/meson.build b/meson.build index 2dc16b37adb..bebe1051302 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/tools/vcs-tag.sh b/tools/vcs-tag.sh index 0150d0b50e1..f9575aeced8 100755 --- a/tools/vcs-tag.sh +++ b/tools/vcs-tag.sh @@ -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/"