diff --git a/meson.build b/meson.build index 52e3ebad34..a599c0ca8f 100644 --- a/meson.build +++ b/meson.build @@ -1811,28 +1811,25 @@ version_tag = get_option('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 version_tag == '' and git.found() and fs.exists(project_source_root / '.git') - version_h = vcs_tag( - input : 'src/version/version.h.in', - output : 'version.h', - # If the working tree has no tags (CI builds), the first git-describe will fail - # and we fall back to project_version-commitid instead. - # TODO: Use 'sh' variable with meson >= 0.63.0 - command: ['sh', - '-euc', - '''git -C "$1" describe --abbrev=7 --dirty=^ 2>/dev/null || - echo "$2-$(git -C "$1" describe --always --abbrev=7)" | - sed 's/^v//; s/-rc/~rc/' ''', - '_', - project_source_root, - meson.project_version()]) + # If the working tree has no tags (CI builds), the first git-describe will fail + # and we fall back to project_version-commitid instead. + version_cmd = '''git -C "$1" describe --abbrev=7 --dirty=^ 2>/dev/null || + echo "$2-$(git -C "$1" describe --always --abbrev=7)" | + sed 's/^v//; s/-rc/~rc/' ''' else - vcs_data = configuration_data() - vcs_data.set('VCS_TAG', version_tag == '' ? meson.project_version() : version_tag) - version_h = configure_file(configuration : vcs_data, - input : 'src/version/version.h.in', - output : 'version.h') + version_cmd = '''echo "$2" ''' endif +version_h = vcs_tag( + input : 'src/version/version.h.in', + output : 'version.h', + # TODO: Use 'sh' variable with meson >= 0.63.0 + command: ['sh', '-euc', version_cmd, + '_', + project_source_root, + version_tag == '' ? meson.project_version() : version_tag, + ]) + versiondep = declare_dependency( sources : version_h, include_directories : include_directories('.'),