diff --git a/meson.build b/meson.build index 9f62428..9df7667 100644 --- a/meson.build +++ b/meson.build @@ -13,7 +13,6 @@ buildtype = get_option('buildtype') host_system = host_machine.system() c_args = [ - '-DPROJECT_VERSION="@0@"'.format(meson.project_version()), '-D_GNU_SOURCE', '-fvisibility=hidden', '-DAML_UNSTABLE_API=1', @@ -27,17 +26,20 @@ if buildtype != 'debug' and buildtype != 'debugoptimized' c_args += '-DNDEBUG' endif +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'], check: false) - git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false) - if git_describe.returncode() == 0 and git_branch.returncode() == 0 - c_args += '-DGIT_VERSION="@0@ (@1@)"'.format( - git_describe.stdout().strip(), + git_commit = run_command([git, 'rev-parse', '--short', 'HEAD']) + git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD']) + 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') libdrm_inc = dependency('libdrm').partial_dependency(compile_args: true) diff --git a/src/server.c b/src/server.c index edf0b65..33067b3 100644 --- a/src/server.c +++ b/src/server.c @@ -83,9 +83,7 @@ static bool client_has_encoding(const struct nvnc_client* client, enum rfb_encodings encoding); static void process_fb_update_requests(struct nvnc_client* client); -#if defined(GIT_VERSION) -EXPORT const char nvnc_version[] = GIT_VERSION; -#elif defined(PROJECT_VERSION) +#if defined(PROJECT_VERSION) EXPORT const char nvnc_version[] = PROJECT_VERSION; #else EXPORT const char nvnc_version[] = "UNKNOWN";