]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Use custom_target() instead of vcs_tag()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 9 Apr 2025 11:54:22 +0000 (13:54 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 9 Apr 2025 14:21:08 +0000 (16:21 +0200)
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.

meson.build
tools/vcs-tag.sh

index 2dc16b37adb0292ff4d878c5d458ef0977e1b4b4..bebe10513027d8ff72d10a9e18da14644c3312f4 100644 (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')
index 0150d0b50e1755dfdfff991ca77f12b853505930..f9575aeced8f677dd9c53d6f92d583be70cffdcf 100755 (executable)
@@ -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/"