aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-08-08 13:47:10 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commitb739848b6ea4c038610ceb7c0b00984a86d99fa9 (patch)
tree29010c4a34d6800d2f706e0fe93eb297f12bf4bc
parentcd3d9986f40fd4e605ac2e8168512065439173e2 (diff)
downloadserd-b739848b6ea4c038610ceb7c0b00984a86d99fa9.tar.gz
serd-b739848b6ea4c038610ceb7c0b00984a86d99fa9.tar.bz2
serd-b739848b6ea4c038610ceb7c0b00984a86d99fa9.zip
Add version constants to public header
-rw-r--r--.clang-tidy1
-rw-r--r--include/serd/serd.h1
-rw-r--r--include/serd/version.h50
-rw-r--r--meson.build10
-rw-r--r--src/serd_config.h3
-rw-r--r--src/serdi.c8
-rw-r--r--test/headers/.clang-tidy1
7 files changed, 68 insertions, 6 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 92f53054..39e09c64 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -8,6 +8,7 @@ Checks: >
-bugprone-suspicious-realloc-usage,
-clang-diagnostic-unused-macros,
-llvmlibc-*,
+ -modernize-macro-to-enum,
-readability-identifier-length,
FormatStyle: file
HeaderFilterRegex: '.*/serd/.*\.h'
diff --git a/include/serd/serd.h b/include/serd/serd.h
index bf02bc96..70168997 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -19,6 +19,7 @@
*/
#include "serd/attributes.h"
+#include "serd/version.h"
/**
@}
diff --git a/include/serd/version.h b/include/serd/version.h
new file mode 100644
index 00000000..254e79c8
--- /dev/null
+++ b/include/serd/version.h
@@ -0,0 +1,50 @@
+// Copyright 2011-2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef SERD_VERSION_H
+#define SERD_VERSION_H
+
+#include "serd/attributes.h"
+
+SERD_BEGIN_DECLS
+
+/**
+ @defgroup serd_version Version
+ @ingroup serd_library
+
+ Serd uses a single [semantic version number](https://semver.org) which
+ reflects changes to the C library ABI.
+
+ @{
+*/
+
+/**
+ 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 1
+
+/**
+ 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
+
+/**
+ @}
+*/
+
+SERD_END_DECLS
+
+#endif // SERD_VERSION_H
diff --git a/meson.build b/meson.build
index 14abaa0b..30ac2374 100644
--- a/meson.build
+++ b/meson.build
@@ -16,9 +16,11 @@ project(
version: '1.1.1',
)
+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
#######################
@@ -119,6 +121,7 @@ c_headers = files(
'include/serd/string_view.h',
'include/serd/syntax.h',
'include/serd/uri.h',
+ 'include/serd/version.h',
'include/serd/writer.h',
)
@@ -147,6 +150,9 @@ libserd = library(
sources,
c_args: [
'-DSERD_INTERNAL',
+ '-DSERD_MAJOR_VERSION=@0@'.format(serd_major_version),
+ '-DSERD_MICRO_VERSION=@0@'.format(serd_micro_version),
+ '-DSERD_MINOR_VERSION=@0@'.format(serd_minor_version),
'-DSERD_VERSION="@0@"'.format(meson.project_version()),
] + c_suppressions + extra_c_args + platform_c_args,
dependencies: m_dep,
diff --git a/src/serd_config.h b/src/serd_config.h
index e6b3aa4b..909a357d 100644
--- a/src/serd_config.h
+++ b/src/serd_config.h
@@ -35,9 +35,6 @@
#ifndef SERD_SRC_SERD_CONFIG_H
#define SERD_SRC_SERD_CONFIG_H
-// Define version unconditionally so a warning will catch a mismatch
-#define SERD_VERSION "1.1.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 27e6d782..d3ff0813 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -13,6 +13,7 @@
#include "serd/status.h"
#include "serd/syntax.h"
#include "serd/uri.h"
+#include "serd/version.h"
#include "serd/writer.h"
#ifdef _WIN32
@@ -79,11 +80,16 @@ guess_syntax(const char* const filename)
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-2023 David Robillard <d@drobilla.net>.\n"
"License ISC: <https://spdx.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;
}
diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy
index eaf6ac95..2d823c5a 100644
--- a/test/headers/.clang-tidy
+++ b/test/headers/.clang-tidy
@@ -5,6 +5,7 @@ Checks: >
*,
-altera-*,
-llvmlibc-*,
+ -modernize-macro-to-enum,
-readability-identifier-length,
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'