From f67686256f3128cd5a4eba4cb93283012529f065 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Jan 2018 16:05:17 +0100 Subject: [PATCH 1/6] config: fix using the right nm-version for the match specification We can disable/enable configuration snippets per NetworkManager version. But we must compare it against the current version that we build, not the current API version. --- src/nm-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nm-config.c b/src/nm-config.c index 118a50ca72..ab839b83e7 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -553,7 +553,7 @@ nm_config_create_keyfile () /* this is an external variable, to make loading testable. Other then that, * no code is supposed to change this. */ -guint _nm_config_match_nm_version = NM_VERSION_CUR_STABLE; +guint _nm_config_match_nm_version = NM_VERSION; char *_nm_config_match_env = NULL; static gboolean From 8a040c6883936e9d76ef072424659fa969c3f945 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Jan 2018 15:19:12 +0100 Subject: [PATCH 2/6] version: combine NM_VERSION_CUR_STABLE and NM_VERSION_NEXT_STABLE We don't need to have two version defines "CUR" and "NEXT". The main purpose of these macros (if not their only), is to make NM_AVAILABLE_IN_* and NM_DEPRECATED_IN_* macros work. 1) At the precise commit of a release, "CUR" and "NEXT" must be identical, because whenever the user configures NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED, then they both compare against the current version, at which point "CUR" == "NEXT". 2) Every other commit aside the release, is a development version that leads up the the next coming release. But as far as versioning is concerned, such a development version should be treated like that future release. It's unstable API and it may or may not be close to later API of the release. But we shall treat it as that version. Hence, also in this case, we want to set both "NM_VERSION_CUR_STABLE" and again NEXT to the future version. This makes NM_VERSION_NEXT_STABLE redundant. Previously, the separation between current and next version would for example allow that NM_VERSION_CUR_STABLE is the previously release stable API, and NM_VERSION_NEXT_STABLE is the version of the next upcoming stable API. So, we could allow "examples" to make use of development API, but other(?) internal code still restrict to unstable API. But it's unclear which other code would want to avoid current development. Also, the points 1) and 2) were badly understood. Note that for our previousy releases, we usually didn't bump the macros at the stable release (and if we did, we didn't set them to be the same). While using two macros might be more powerful, it is hard to grok and easy to forget to bump the macros a the right time. One macro shall suffice. All this also means, that *immediately* after making a new release, we shall bump the version number in `configure.ac` and "NM_VERSION_CUR_STABLE". --- Makefile.examples | 2 +- docs/libnm-glib/Makefile.am | 2 +- docs/libnm-util/Makefile.am | 2 +- docs/libnm/Makefile.am | 2 +- examples/C/glib/meson.build | 2 +- libnm-core/nm-version.h | 4 ++-- libnm-util/nm-version.h | 4 ++-- shared/nm-default.h | 2 +- shared/nm-version-macros.h.in | 6 ++++-- 9 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile.examples b/Makefile.examples index d58fd22a22..efbbe289f5 100644 --- a/Makefile.examples +++ b/Makefile.examples @@ -10,7 +10,7 @@ examples_C_glib_cppflags = \ -I$(top_srcdir)/libnm \ -I$(top_builddir)/libnm \ $(GLIB_CFLAGS) \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE + -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE examples_C_glib_cppflags_gdbus = $(examples_C_glib_cppflags) examples_C_glib_cppflags_libnm = $(examples_C_glib_cppflags) diff --git a/docs/libnm-glib/Makefile.am b/docs/libnm-glib/Makefile.am index 5273148a94..e733f76502 100644 --- a/docs/libnm-glib/Makefile.am +++ b/docs/libnm-glib/Makefile.am @@ -56,7 +56,7 @@ GTKDOC_CFLAGS = \ -I$(top_builddir)/libnm-util \ -I$(top_srcdir)/libnm-glib \ -I$(top_builddir)/libnm-glib \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ + -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) diff --git a/docs/libnm-util/Makefile.am b/docs/libnm-util/Makefile.am index 75badb7791..eb16d7601e 100644 --- a/docs/libnm-util/Makefile.am +++ b/docs/libnm-util/Makefile.am @@ -50,7 +50,7 @@ extra_files = # if $(DOC_MODULE).types is non-empty. GTKDOC_CFLAGS = \ -I$(top_srcdir)/libnm-util \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ + -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) diff --git a/docs/libnm/Makefile.am b/docs/libnm/Makefile.am index 3ab55a8c43..362a434455 100644 --- a/docs/libnm/Makefile.am +++ b/docs/libnm/Makefile.am @@ -71,7 +71,7 @@ GTKDOC_CFLAGS = \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/libnm \ -I$(top_builddir)/libnm \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE \ + -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \ $(GLIB_CFLAGS) diff --git a/examples/C/glib/meson.build b/examples/C/glib/meson.build index 0a4694dd52..acc1e71237 100644 --- a/examples/C/glib/meson.build +++ b/examples/C/glib/meson.build @@ -15,6 +15,6 @@ foreach example: examples [example[0] + '.c'] + example[1], include_directories: example[2], dependencies: [nm_core_dep] + example[3], - c_args: '-DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE' + c_args: '-DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE' ) endforeach diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h index 968fa66384..37d8ea729b 100644 --- a/libnm-core/nm-version.h +++ b/libnm-core/nm-version.h @@ -38,8 +38,8 @@ #endif /* sanity checks */ -#if NM_VERSION_MIN_REQUIRED > NM_VERSION_NEXT_STABLE -#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_NEXT_STABLE" +#if NM_VERSION_MIN_REQUIRED > NM_VERSION_CUR_STABLE +#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_CUR_STABLE" #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED #error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED" diff --git a/libnm-util/nm-version.h b/libnm-util/nm-version.h index 7173bc6ba3..5f3bd022a1 100644 --- a/libnm-util/nm-version.h +++ b/libnm-util/nm-version.h @@ -38,8 +38,8 @@ #endif /* sanity checks */ -#if NM_VERSION_MIN_REQUIRED > NM_VERSION_NEXT_STABLE -#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_NEXT_STABLE" +#if NM_VERSION_MIN_REQUIRED > NM_VERSION_CUR_STABLE +#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_CUR_STABLE" #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED #error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED" diff --git a/shared/nm-default.h b/shared/nm-default.h index 2e205a957e..0ddad504ce 100644 --- a/shared/nm-default.h +++ b/shared/nm-default.h @@ -115,7 +115,7 @@ /* for internal compilation we don't want the deprecation macros * to be in effect. Define the widest range of versions to effectively * disable deprecation checks */ -#define NM_VERSION_MAX_ALLOWED NM_VERSION_NEXT_STABLE +#define NM_VERSION_MAX_ALLOWED NM_VERSION_CUR_STABLE #define NM_VERSION_MIN_REQUIRED NM_VERSION_0_9_8 #ifndef NM_MORE_ASSERTS diff --git a/shared/nm-version-macros.h.in b/shared/nm-version-macros.h.in index 3efa350cd5..0cbd1b0bdd 100644 --- a/shared/nm-version-macros.h.in +++ b/shared/nm-version-macros.h.in @@ -74,8 +74,10 @@ #define NM_VERSION_1_10 (NM_ENCODE_VERSION (1, 10, 0)) #define NM_VERSION_1_12 (NM_ENCODE_VERSION (1, 12, 0)) -#define NM_VERSION_CUR_STABLE NM_VERSION_1_10 -#define NM_VERSION_NEXT_STABLE NM_VERSION_1_12 +#define NM_VERSION_CUR_STABLE NM_VERSION_1_12 + +/* deprecated define. */ +#define NM_VERSION_NEXT_STABLE NM_VERSION_CUR_STABLE #define NM_VERSION NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION) From 9ef17869b5fa775bd7f1da14471f52775efe1017 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Jan 2018 15:42:43 +0100 Subject: [PATCH 3/6] version: drop NM_VERSION_MAX_ALLOWED defines for internal build It already defaults to the right value. We only need to define NM_VERSION_MIN_REQUIRED, so that parts of our internal build can make use of deprecated API. --- Makefile.examples | 3 +-- docs/libnm-glib/Makefile.am | 1 - docs/libnm-util/Makefile.am | 1 - docs/libnm/Makefile.am | 1 - examples/C/glib/meson.build | 1 - shared/nm-default.h | 1 - 6 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile.examples b/Makefile.examples index efbbe289f5..d49db6ce86 100644 --- a/Makefile.examples +++ b/Makefile.examples @@ -9,8 +9,7 @@ examples_C_glib_cppflags = \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/libnm \ -I$(top_builddir)/libnm \ - $(GLIB_CFLAGS) \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE + $(GLIB_CFLAGS) examples_C_glib_cppflags_gdbus = $(examples_C_glib_cppflags) examples_C_glib_cppflags_libnm = $(examples_C_glib_cppflags) diff --git a/docs/libnm-glib/Makefile.am b/docs/libnm-glib/Makefile.am index e733f76502..8a868d0e9c 100644 --- a/docs/libnm-glib/Makefile.am +++ b/docs/libnm-glib/Makefile.am @@ -56,7 +56,6 @@ GTKDOC_CFLAGS = \ -I$(top_builddir)/libnm-util \ -I$(top_srcdir)/libnm-glib \ -I$(top_builddir)/libnm-glib \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) diff --git a/docs/libnm-util/Makefile.am b/docs/libnm-util/Makefile.am index eb16d7601e..1d417894b2 100644 --- a/docs/libnm-util/Makefile.am +++ b/docs/libnm-util/Makefile.am @@ -50,7 +50,6 @@ extra_files = # if $(DOC_MODULE).types is non-empty. GTKDOC_CFLAGS = \ -I$(top_srcdir)/libnm-util \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \ $(GLIB_CFLAGS) \ $(DBUS_CFLAGS) diff --git a/docs/libnm/Makefile.am b/docs/libnm/Makefile.am index 362a434455..288a595e64 100644 --- a/docs/libnm/Makefile.am +++ b/docs/libnm/Makefile.am @@ -71,7 +71,6 @@ GTKDOC_CFLAGS = \ -I$(top_builddir)/libnm-core \ -I$(top_srcdir)/libnm \ -I$(top_builddir)/libnm \ - -DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE \ -DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_8 \ $(GLIB_CFLAGS) diff --git a/examples/C/glib/meson.build b/examples/C/glib/meson.build index acc1e71237..edc4dbb142 100644 --- a/examples/C/glib/meson.build +++ b/examples/C/glib/meson.build @@ -15,6 +15,5 @@ foreach example: examples [example[0] + '.c'] + example[1], include_directories: example[2], dependencies: [nm_core_dep] + example[3], - c_args: '-DNM_VERSION_MAX_ALLOWED=NM_VERSION_CUR_STABLE' ) endforeach diff --git a/shared/nm-default.h b/shared/nm-default.h index 0ddad504ce..8dab263be0 100644 --- a/shared/nm-default.h +++ b/shared/nm-default.h @@ -115,7 +115,6 @@ /* for internal compilation we don't want the deprecation macros * to be in effect. Define the widest range of versions to effectively * disable deprecation checks */ -#define NM_VERSION_MAX_ALLOWED NM_VERSION_CUR_STABLE #define NM_VERSION_MIN_REQUIRED NM_VERSION_0_9_8 #ifndef NM_MORE_ASSERTS From 165fe65eef720dcc494c9afa2d787325e0a08053 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Jan 2018 15:57:13 +0100 Subject: [PATCH 4/6] version: calculate NM_VERSION_CUR_STABLE based on the version numbers We have a well defined versioning scheme and a defined way how the version number indicates a stable version. We can simply calculate NM_VERSION_CUR_STABLE based on the version numbers. --- shared/nm-version-macros.h.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/nm-version-macros.h.in b/shared/nm-version-macros.h.in index 0cbd1b0bdd..40104f5f35 100644 --- a/shared/nm-version-macros.h.in +++ b/shared/nm-version-macros.h.in @@ -74,7 +74,10 @@ #define NM_VERSION_1_10 (NM_ENCODE_VERSION (1, 10, 0)) #define NM_VERSION_1_12 (NM_ENCODE_VERSION (1, 12, 0)) -#define NM_VERSION_CUR_STABLE NM_VERSION_1_12 +#define NM_VERSION_CUR_STABLE \ + (((NM_MINOR_VERSION % 2) == 1) \ + ? NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION + 1, 0 ) \ + : NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION , ((NM_MICRO_VERSION + 1) / 2) * 2)) /* deprecated define. */ #define NM_VERSION_NEXT_STABLE NM_VERSION_CUR_STABLE From 4da1480cfd50fcc44ddc934db56a02f696e1bc52 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Jan 2018 16:01:49 +0100 Subject: [PATCH 5/6] version: rename macro NM_VERSION_CUR_STABLE to NM_API_VERSION NM_API_VERSION is a better name. It's not the current stable version, but the version number of the API which the current NM_VERSION provides. In practice, NM_API_VERSION is either identical to NM_VERSION (in case of a release) or NM_VERSION is a development version leading up the the upcoming NM_API_VERSION. For example, with the new name the check #if NM_VERSION != NM_API_VERSION # warning this is an development version #endif makes more sense. --- libnm-core/nm-version.h | 8 ++++---- libnm-util/nm-version.h | 8 ++++---- shared/nm-version-macros.h.in | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libnm-core/nm-version.h b/libnm-core/nm-version.h index 37d8ea729b..0412bc8e94 100644 --- a/libnm-core/nm-version.h +++ b/libnm-core/nm-version.h @@ -29,17 +29,17 @@ #if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) # undef NM_VERSION_MIN_REQUIRED -# define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE) +# define NM_VERSION_MIN_REQUIRED (NM_API_VERSION) #endif #if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0) # undef NM_VERSION_MAX_ALLOWED -# define NM_VERSION_MAX_ALLOWED (NM_VERSION_CUR_STABLE) +# define NM_VERSION_MAX_ALLOWED (NM_API_VERSION) #endif /* sanity checks */ -#if NM_VERSION_MIN_REQUIRED > NM_VERSION_CUR_STABLE -#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_CUR_STABLE" +#if NM_VERSION_MIN_REQUIRED > NM_API_VERSION +#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION" #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED #error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED" diff --git a/libnm-util/nm-version.h b/libnm-util/nm-version.h index 5f3bd022a1..f56c3944dd 100644 --- a/libnm-util/nm-version.h +++ b/libnm-util/nm-version.h @@ -29,17 +29,17 @@ #if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) # undef NM_VERSION_MIN_REQUIRED -# define NM_VERSION_MIN_REQUIRED (NM_VERSION_CUR_STABLE) +# define NM_VERSION_MIN_REQUIRED (NM_API_VERSION) #endif #if !defined (NM_VERSION_MAX_ALLOWED) || (NM_VERSION_MAX_ALLOWED == 0) # undef NM_VERSION_MAX_ALLOWED -# define NM_VERSION_MAX_ALLOWED (NM_VERSION_CUR_STABLE) +# define NM_VERSION_MAX_ALLOWED (NM_API_VERSION) #endif /* sanity checks */ -#if NM_VERSION_MIN_REQUIRED > NM_VERSION_CUR_STABLE -#error "NM_VERSION_MIN_REQUIRED must be <= NM_VERSION_CUR_STABLE" +#if NM_VERSION_MIN_REQUIRED > NM_API_VERSION +#error "NM_VERSION_MIN_REQUIRED must be <= NM_API_VERSION" #endif #if NM_VERSION_MAX_ALLOWED < NM_VERSION_MIN_REQUIRED #error "NM_VERSION_MAX_ALLOWED must be >= NM_VERSION_MIN_REQUIRED" diff --git a/shared/nm-version-macros.h.in b/shared/nm-version-macros.h.in index 40104f5f35..8d07fc82ba 100644 --- a/shared/nm-version-macros.h.in +++ b/shared/nm-version-macros.h.in @@ -74,13 +74,23 @@ #define NM_VERSION_1_10 (NM_ENCODE_VERSION (1, 10, 0)) #define NM_VERSION_1_12 (NM_ENCODE_VERSION (1, 12, 0)) -#define NM_VERSION_CUR_STABLE \ +/* For releases, NM_API_VERSION is equal to NM_VERSION. + * + * For development builds, NM_API_VERSION is the next + * stable API after NM_VERSION. When you run a development + * version, you are already using the future API, even if + * it is not yet release. Hence, the currently used API + * version is the future one. */ +#define NM_API_VERSION \ (((NM_MINOR_VERSION % 2) == 1) \ ? NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION + 1, 0 ) \ : NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION , ((NM_MICRO_VERSION + 1) / 2) * 2)) -/* deprecated define. */ -#define NM_VERSION_NEXT_STABLE NM_VERSION_CUR_STABLE +/* deprecated. */ +#define NM_VERSION_CUR_STABLE NM_API_VERSION + +/* deprecated. */ +#define NM_VERSION_NEXT_STABLE NM_API_VERSION #define NM_VERSION NM_ENCODE_VERSION (NM_MAJOR_VERSION, NM_MINOR_VERSION, NM_MICRO_VERSION) From c7ff37967a051730d2015199b4f6260287ec0abf Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Jan 2018 16:08:13 +0100 Subject: [PATCH 6/6] version: add reminder comment for adding version macros to configure.ac --- configure.ac | 5 +++++ meson.build | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/configure.ac b/configure.ac index 55d9cebb36..d594c6b64e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,11 @@ AC_PREREQ([2.63]) dnl The NM version number +dnl +dnl XXX: When incrementing version also: +dnl - add corresponding NM_VERSION_x_y_z macros in +dnl "shared/nm-version-macros.h.in" +dnl - update number in meson.build m4_define([nm_major_version], [1]) m4_define([nm_minor_version], [11]) m4_define([nm_micro_version], [1]) diff --git a/meson.build b/meson.build index 9b2c1cc232..9786288a44 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,9 @@ project( 'NetworkManager', 'c', +# XXX: When incrementing version also: +# - add corresponding NM_VERSION_x_y_z macros in +# "shared/nm-version-macros.h.in" +# - update number in configure.ac version: '1.11.1', license: 'GPL2+', default_options: [