Bake version info into library

pull/44/head
Andri Yngvason 2020-07-26 11:43:00 +00:00
parent 53db2b8c1b
commit addcc50483
3 changed files with 24 additions and 1 deletions

View File

@ -50,6 +50,8 @@ typedef bool (*nvnc_auth_fn)(const char* username, const char* password,
void* userdata); void* userdata);
typedef void (*nvnc_render_fn)(struct nvnc_display*, struct nvnc_fb*); typedef void (*nvnc_render_fn)(struct nvnc_display*, struct nvnc_fb*);
extern const char nvnc_version[];
struct nvnc* nvnc_open(const char* addr, uint16_t port); struct nvnc* nvnc_open(const char* addr, uint16_t port);
void nvnc_close(struct nvnc* self); void nvnc_close(struct nvnc* self);

View File

@ -1,7 +1,7 @@
project( project(
'neatvnc', 'neatvnc',
'c', 'c',
version: '0.1.0', version: '0.2.0',
license: 'ISC', license: 'ISC',
default_options: [ default_options: [
'c_std=gnu11', 'c_std=gnu11',
@ -12,6 +12,7 @@ buildtype = get_option('buildtype')
host_system = host_machine.system() host_system = host_machine.system()
c_args = [ c_args = [
'-DPROJECT_VERSION="@0@"'.format(meson.project_version()),
'-D_GNU_SOURCE', '-D_GNU_SOURCE',
'-fvisibility=hidden', '-fvisibility=hidden',
'-Wmissing-prototypes', '-Wmissing-prototypes',
@ -21,6 +22,18 @@ if buildtype != 'debug' and buildtype != 'debugoptimized'
c_args += '-DNDEBUG' c_args += '-DNDEBUG'
endif endif
git = find_program('git', native: true, required: false)
if git.found()
git_describe = run_command([git, 'describe', '--tags', '--long'])
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(),
git_branch.stdout().strip(),
)
endif
endif
add_project_arguments(c_args, language: 'c') add_project_arguments(c_args, language: 'c')
cc = meson.get_compiler('c') cc = meson.get_compiler('c')

View File

@ -71,6 +71,14 @@ struct fb_update_work {
int schedule_client_update_fb(struct nvnc_client* client); int schedule_client_update_fb(struct nvnc_client* client);
#if defined(GIT_VERSION)
EXPORT const char nvnc_version[] = GIT_VERSION;
#elif defined(PROJECT_VERSION)
EXPORT const char nvnc_version[] = PROJECT_VERSION;
#else
EXPORT const char nvnc_version[] = "UNKNOWN";
#endif
static void client_close(struct nvnc_client* client) static void client_close(struct nvnc_client* client)
{ {
log_debug("client_close(%p): ref %d\n", client, client->ref); log_debug("client_close(%p): ref %d\n", client, client->ref);