From c1281dad601e5e38bdbd7799460913d5327b250a Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Mon, 9 Oct 2023 22:57:36 +0000 Subject: [PATCH] Don't use tag for git version --- meson.build | 13 ++++++++----- src/util.c | 4 +--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 70b1e58..61dac4b 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,6 @@ host_system = host_machine.system() prefix = get_option('prefix') c_args = [ - '-DPROJECT_VERSION="@0@"'.format(meson.project_version()), '-D_GNU_SOURCE', '-DAML_UNSTABLE_API=1', @@ -22,18 +21,22 @@ c_args = [ '-Wno-missing-field-initializers', ] +version = '"@0@"'.format(meson.project_version()) git = find_program('git', native: true, required: false) if git.found() - git_describe = run_command([git, 'describe', '--tags', '--long']) + git_commit = run_command([git, 'rev-parse', '--short', 'HEAD']) git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD']) - if git_describe.returncode() == 0 and git_branch.returncode() == 0 - c_args += '-DGIT_VERSION="@0@ (@1@)"'.format( - git_describe.stdout().strip(), + if git_commit.returncode() == 0 and git_branch.returncode() == 0 + version = '"v@0@-@1@ (@2@)"'.format( + meson.project_version(), + git_commit.stdout().strip(), git_branch.stdout().strip(), ) endif endif +add_project_arguments('-DPROJECT_VERSION=@0@'.format(version), language: 'c') + if buildtype != 'debug' and buildtype != 'debugoptimized' c_args += '-DNDEBUG' endif diff --git a/src/util.c b/src/util.c index c7fbfa9..c948244 100644 --- a/src/util.c +++ b/src/util.c @@ -23,9 +23,7 @@ #include "util.h" const char* wayvnc_version = -#if defined(GIT_VERSION) - GIT_VERSION; -#elif defined(PROJECT_VERSION) +#if defined(PROJECT_VERSION) PROJECT_VERSION; #else "UNKNOWN";