From 510283832905ba4476a559f5295ec886dfb20b1c Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Wed, 27 Mar 2024 16:55:38 +0200 Subject: [PATCH] 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. --- NEWS | 1 + meson.build | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 97a6732b..7a269375 100644 --- a/NEWS +++ b/NEWS @@ -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 = diff --git a/meson.build b/meson.build index 219e32f5..f7bdf6cf 100644 --- a/meson.build +++ b/meson.build @@ -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 : {