[PATCH v2] meson: Declare GLIB_VERSION_* macros at configure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So far we have three places where glib version is recorded:
meson.build and then in config.h. The latter is so well hidden
that it's easy to miss when bumping minimal glib version in the
former. With a bit of python^Wmeson string magic
GLIB_VERSION_MIN_REQUIRED and GLIB_VERSION_MAX_ALLOWED macros can
be defined to match glib_version from meson.build.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---

v2 of:

https://listman.redhat.com/archives/libvir-list/2021-April/msg01300.html

diff to v1:
- Introduced new glib_version_str variable per Pavel's suggestion

 config.h    | 10 ----------
 meson.build |  8 ++++++++
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/config.h b/config.h
index ca6720f37d..0eacfd139d 100644
--- a/config.h
+++ b/config.h
@@ -51,13 +51,3 @@
 #else
 # error You either need at least GCC 4.8 or Clang 3.4 or XCode Clang 5.1 to compile libvirt
 #endif
-
-/* Ask for warnings for anything that was marked deprecated in
- * the defined version, or before. It is a candidate for rewrite.
- */
-#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_48
-
-/* Ask for warnings if code tries to use function that did not
- * exist in the defined version. These risk breaking builds
- */
-#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_48
diff --git a/meson.build b/meson.build
index 951da67896..ecbfdb1208 100644
--- a/meson.build
+++ b/meson.build
@@ -949,6 +949,14 @@ endif
 glib_dep = declare_dependency(
   dependencies: [ glib_dep, gobject_dep, gio_dep ],
 )
+glib_version_arr = glib_version.split('.')
+glib_version_str = 'GLIB_VERSION_@0@_@1@'.format(glib_version_arr[0], glib_version_arr[1])
+# Ask for warnings for anything that was marked deprecated in
+# the defined version, or before. It is a candidate for rewrite.
+conf.set('GLIB_VERSION_MIN_REQUIRED', glib_version_str)
+# Ask for warnings if code tries to use function that did not
+# exist in the defined version. These risk breaking builds
+conf.set('GLIB_VERSION_MAX_ALLOWED', glib_version_str)
 
 glusterfs_version = '3.4.1'
 glusterfs_dep = dependency('glusterfs-api', version: '>=' + glusterfs_version, required: get_option('glusterfs'))
-- 
2.26.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux