]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: drop short script to generate vcs tag
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 13:41:43 +0000 (22:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 19:54:03 +0000 (04:54 +0900)
meson.build
tools/meson-vcs-tag.sh [deleted file]

index 26deafd562c8f2f7b4db90728719dcf526b99cef..9efb0bd778c8094af949c6158d5c8b9061a0d284 100644 (file)
@@ -631,34 +631,6 @@ endif
 
 #####################################################################
 
-version_tag = get_option('version-tag')
-if version_tag != ''
-        vcs_data = configuration_data()
-        vcs_data.set('VCS_TAG', version_tag)
-        version_h = configure_file(configuration : vcs_data,
-                                   input : 'src/version/version.h.in',
-                                   output : 'version.h')
-else
-        vcs_tagger = [
-                project_source_root + '/tools/meson-vcs-tag.sh',
-                project_source_root,
-                meson.project_version()]
-
-        version_h = vcs_tag(
-                input : 'src/version/version.h.in',
-                output : 'version.h',
-                command: vcs_tagger)
-endif
-
-versiondep = declare_dependency(
-        sources: version_h,
-        include_directories : include_directories('.'))
-
-shared_lib_tag = get_option('shared-lib-tag')
-if shared_lib_tag == ''
-        shared_lib_tag = meson.project_version()
-endif
-
 sh = find_program('sh')
 echo = find_program('echo')
 sed = find_program('sed')
@@ -2145,6 +2117,42 @@ xml_helper_py = find_program('tools/xml_helper.py')
 
 ############################################################
 
+version_tag = get_option('version-tag')
+if version_tag == ''
+        # Check that we have either .git/ (a normal clone) or a .git file (a work-tree) and that we don't
+        # get confused if a tarball is extracted in a higher-level git repository.
+        if git.found() and fs.exists(project_source_root / '.git')
+                # Apparently git describe has a bug where it always considers the work-tree dirty when
+                # invoked with --git-dir (even though 'git status' is happy). Work around this issue by
+                # cd-ing to the source directory.
+                version_tag = run_command(
+                        sh, '-c',
+                        'cd "$MESON_SOURCE_ROOT"; git describe --abbrev=7 --dirty=^ 2>/dev/null | sed "s/^v//; s/-rc/~rc/"',
+                        check : true,
+                ).stdout().strip()
+        else
+                version_tag = meson.project_version()
+        endif
+endif
+
+vcs_data = configuration_data()
+vcs_data.set('VCS_TAG', version_tag)
+version_h = configure_file(configuration : vcs_data,
+                           input : 'src/version/version.h.in',
+                           output : 'version.h')
+
+versiondep = declare_dependency(
+        sources : version_h,
+        include_directories : include_directories('.'),
+)
+
+shared_lib_tag = get_option('shared-lib-tag')
+if shared_lib_tag == ''
+        shared_lib_tag = meson.project_version()
+endif
+
+############################################################
+
 if get_option('b_coverage')
         userspace_c_args += ['-include', 'src/basic/coverage.h']
 endif
diff --git a/tools/meson-vcs-tag.sh b/tools/meson-vcs-tag.sh
deleted file mode 100755 (executable)
index 3964a8e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-set -eu
-set -o pipefail
-
-dir="${1:?}"
-fallback="${2:?}"
-
-# Apparently git describe has a bug where it always considers the work-tree
-# dirty when invoked with --git-dir (even though 'git status' is happy). Work
-# around this issue by cd-ing to the source directory.
-cd "$dir"
-# Check that we have either .git/ (a normal clone) or a .git file (a work-tree)
-# and that we don't get confused if a tarball is extracted in a higher-level
-# git repository.
-[ -e .git ] && \
-    git describe --abbrev=7 --dirty=^ 2>/dev/null | sed 's/^v//; s/-rc/~rc/' || \
-    echo "$fallback"