diff options
author | David Robillard <d@drobilla.net> | 2021-08-08 13:47:10 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-28 21:57:07 -0500 |
commit | 411b2ffac686478f3312c4a0c5cf20a230a3f728 (patch) | |
tree | 32070da3c5bd7245da2a66a344232ce5178e117f | |
parent | 5a39e907a9a1fad87c35a94ea1e534deeb2316f9 (diff) | |
download | serd-411b2ffac686478f3312c4a0c5cf20a230a3f728.tar.gz serd-411b2ffac686478f3312c4a0c5cf20a230a3f728.tar.bz2 serd-411b2ffac686478f3312c4a0c5cf20a230a3f728.zip |
Add version constants to public header
-rw-r--r-- | include/serd/serd.h | 23 | ||||
-rw-r--r-- | meson.build | 11 | ||||
-rw-r--r-- | src/serd_config.h | 3 | ||||
-rw-r--r-- | src/serdi.c | 10 |
4 files changed, 39 insertions, 8 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h index 790dfde0..3655f0b4 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -87,6 +87,29 @@ extern "C" { @{ */ +/** + The major version number of the serd library. + + Semver: Increments when incompatible API changes are made. +*/ +#define SERD_MAJOR_VERSION 1 + +/** + The minor version number of the serd library. + + Semver: Increments when functionality is added in a backwards compatible + manner. +*/ +#define SERD_MINOR_VERSION 0 + +/** + The micro version number of the serd library. + + Semver: Increments when changes are made that do not affect the API, such as + performance improvements or bug fixes. +*/ +#define SERD_MICRO_VERSION 1 + /// Flags that describe the details of a node typedef enum { SERD_IS_LONG = 1u << 0u, ///< Literal node should be triple-quoted diff --git a/meson.build b/meson.build index 9ae07fa1..21cbb3ed 100644 --- a/meson.build +++ b/meson.build @@ -10,9 +10,11 @@ project('serd', ['c'], 'warning_level=2', ]) +serd_major_version = meson.project_version().split('.')[0] +serd_minor_version = meson.project_version().split('.')[1] +serd_micro_version = meson.project_version().split('.')[2] serd_src_root = meson.current_source_dir() -major_version = meson.project_version().split('.')[0] -version_suffix = '-@0@'.format(major_version) +version_suffix = '-@0@'.format(serd_major_version) versioned_name = 'serd' + version_suffix # Load build tools @@ -160,6 +162,11 @@ else ] endif +# Define version constants to trigger a warning if those in the code don't mwatch +library_args += ['-DSERD_MAJOR_VERSION=@0@'.format(serd_major_version), + '-DSERD_MINOR_VERSION=@0@'.format(serd_minor_version), + '-DSERD_MICRO_VERSION=@0@'.format(serd_micro_version)] + exess_dep = dependency('exess-0', version: '>= 0.0.1', fallback: ['exess', 'exess_dep']) diff --git a/src/serd_config.h b/src/serd_config.h index 53378a48..90888c39 100644 --- a/src/serd_config.h +++ b/src/serd_config.h @@ -28,9 +28,6 @@ #ifndef SERD_CONFIG_H #define SERD_CONFIG_H -// Define version unconditionally so a warning will catch a mismatch -#define SERD_VERSION "1.0.1" - #if !defined(SERD_NO_DEFAULT_CONFIG) // We need unistd.h to check _POSIX_VERSION diff --git a/src/serdi.c b/src/serdi.c index 2de41ce7..d84e3663 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -1,5 +1,5 @@ /* - Copyright 2011-2020 David Robillard <d@drobilla.net> + Copyright 2011-2021 David Robillard <d@drobilla.net> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -14,7 +14,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "serd_config.h" #include "system.h" #include "serd/serd.h" @@ -47,11 +46,16 @@ typedef struct { static int print_version(void) { - printf("serdi " SERD_VERSION " <http://drobilla.net/software/serd>\n"); + printf("serdi %d.%d.%d <http://drobilla.net/software/serd>\n", + SERD_MAJOR_VERSION, + SERD_MINOR_VERSION, + SERD_MICRO_VERSION); + printf("Copyright 2011-2021 David Robillard <d@drobilla.net>.\n" "License: <http://www.opensource.org/licenses/isc>\n" "This is free software; you are free to change and redistribute it." "\nThere is NO WARRANTY, to the extent permitted by law.\n"); + return 0; } |