1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

meson: drop short script to generate vcs tag

This commit is contained in:
Yu Watanabe 2023-07-29 22:41:43 +09:00
parent ae85704760
commit e95acdfe1d
2 changed files with 36 additions and 47 deletions

View 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

View File

@ -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"