meson: Fix version.h when building from tarball

meson.build always assumed running from git source tree,
resulting in GIT_VERSION with value "" (empty string).

This commit makes meson use the tarballed version.h,
for the cases when not building from git source tree.
This commit is contained in:
Nedko Arnaudov 2024-03-27 16:55:38 +02:00
parent cdad426401
commit 5102838329
2 changed files with 19 additions and 6 deletions

1
NEWS
View File

@ -2,6 +2,7 @@
* Apply downstream patches from FreeBSD
* meson: Fix project license field (MIT->GPL-2.0-only)
* meson: Fix version.h when building from tarball
= Version 1.1 on 2023-11-26 =

View File

@ -7,13 +7,25 @@ locale_dir = get_option('prefix') / 'share' / 'locale'
dbus_name_base = 'org.ladish'
dbus_base_path = '/org/ladish'
git_version = run_command(['git', 'rev-parse', '--short', 'HEAD']).stdout().strip()
fs = import('fs')
if fs.is_dir(f'.git')
# This block handles building from git source tree
# version.h is generated during build
git_version = run_command(['git', 'rev-parse', '--short', 'HEAD']).stdout().strip()
configure_file(output : 'version.h',
configuration : {
'GIT_VERSION' : '"@0@"'.format(git_version)
}
)
configure_file(output : 'version.h',
configuration : {
'GIT_VERSION' : '"@0@"'.format(git_version)
}
)
else
# Tarballs already have version.h,
# Just copy the file in this case
configure_file(output : 'version.h',
input : 'version.h',
copy: true
)
endif
configure_file(output : 'config.h',
configuration : {