From a0310ff42eff573d039817ea6a4e8ddab9a9dc71 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Thu, 27 Sep 2018 19:16:45 -0500 Subject: [PATCH 1/2] Version the libdeltachat.so file This creates a version scheme extracted from the existing git tagging schema being used. It therefore relies on this schema not changing. Since there appear no way to do all of this reading things from git before the project() call we can sadly not use the correct version in the project itself. --- meson.build | 44 ++++++++++++++++++++++++++++++-------------- src/meson.build | 11 +++++++++++ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 95fda895..7e436a5f 100644 --- a/meson.build +++ b/meson.build @@ -1,10 +1,40 @@ project( 'deltachat-core', 'c', license: 'GPLv3', + version: '0.0.0', # Dummy, see below. subproject_dir: 'libs', meson_version: '>=0.47.2', ) + +## Figure out the version, use this instead of meson.project_version() +# The version schema is: +# - X.Y.Z for tagged releases. +# - X.Y.Z990N for dev releases. +# Where N is the number of commits since the last tag. +git = find_program('git', required: false) +if git.found() + git_desc = run_command(git, 'describe', '--tags') + if git_desc.returncode() == 0 + git_desc_parts = git_desc.stdout().strip().split('-') + version = git_desc_parts[0].split('v')[1] + if git_desc_parts.length() > 1 + version_parts = version.split('.') + version = '.'.join([version_parts[0], + version_parts[1], + version_parts[2] + '990' + git_desc_parts[1]]) + endif + else + version = meson.project_version() + endif +else + version = meson.project_version() +endif +if version == meson.project_version() + warning('Git version not foud, using (dummy) project version') +endif + + # pthreads is not a real dependency pthreads = dependency('threads') @@ -66,17 +96,3 @@ subdir('src') # Build the binaries. subdir('cmdline') - - -version = run_command('git', 'describe', '--tags') -if version.returncode() != 0 - message('git version not found, pkg-config will not be generated') -else - pkg = import('pkgconfig') - pkg.generate(libraries : lib, - version : version.stdout().strip(), - subdirs : ['deltachat'], - name : 'libdeltachat', - filebase : 'deltachat', - description : ' Create your own, email-compatible messenger.') -endif diff --git a/src/meson.build b/src/meson.build index bc7235a2..7a279ad8 100644 --- a/src/meson.build +++ b/src/meson.build @@ -46,12 +46,23 @@ lib = library( 'deltachat', lib_src, dependencies: lib_deps, include_directories: lib_inc, + version: version, install: true, ) dep = declare_dependency( include_directories: lib_inc, dependencies: lib_deps, link_with: [lib], + version: version, ) install_headers(['deltachat.h'], subdir: 'deltachat') + + +pkg = import('pkgconfig') +pkg.generate(libraries : lib, + version : version, + subdirs : ['deltachat'], + name : 'libdeltachat', + filebase : 'deltachat', + description : ' Create your own, email-compatible messenger.') From 27352104f3b5bc6e1e949eb0aacfd14bc2516377 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Thu, 27 Sep 2018 20:22:21 -0500 Subject: [PATCH 2/2] Fix typos and simplify else clauses Thanks @ralphtheninja for the review. --- meson.build | 7 ++----- src/meson.build | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 7e436a5f..9f08eae8 100644 --- a/meson.build +++ b/meson.build @@ -12,6 +12,7 @@ project( # - X.Y.Z for tagged releases. # - X.Y.Z990N for dev releases. # Where N is the number of commits since the last tag. +version = meson.project_version() git = find_program('git', required: false) if git.found() git_desc = run_command(git, 'describe', '--tags') @@ -24,14 +25,10 @@ if git.found() version_parts[1], version_parts[2] + '990' + git_desc_parts[1]]) endif - else - version = meson.project_version() endif -else - version = meson.project_version() endif if version == meson.project_version() - warning('Git version not foud, using (dummy) project version') + warning('Git version not found, using (dummy) project version') endif diff --git a/src/meson.build b/src/meson.build index 7a279ad8..8f311c3e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -65,4 +65,4 @@ pkg.generate(libraries : lib, subdirs : ['deltachat'], name : 'libdeltachat', filebase : 'deltachat', - description : ' Create your own, email-compatible messenger.') + description : 'Create your own, email-compatible messenger.')