Skip to content

Commit

Permalink
Detect GDate autoptr when available.
Browse files Browse the repository at this point in the history
The GDate autoptr cleanup was finally officially added in
GLib 2.63.3--which is now available in Fedora Rawhide--so stop
defining it ourselves.

https://gitlab.gnome.org/GNOME/glib/merge_requests/1256

Fixes: #414

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
  • Loading branch information
mmathesius authored and sgallagher committed Jan 6, 2020
1 parent 6902421 commit 784f275
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
17 changes: 16 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ with_libmagic = get_option('libmagic')
rpm = dependency('rpm', required : with_rpmio)
magic = cc.find_library('magic', required : with_libmagic)

glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix')
glib = dependency('glib-2.0')
glib_prefix = glib.get_pkgconfig_variable('prefix')

sh = find_program('sh')
sed = find_program('sed')
Expand All @@ -81,6 +82,20 @@ if with_docs
endif
endif


# Check whether this version of glib has the GDate autoptr defined
gdate_check = '''#include <glib.h>
int main (int argc, char **argv)
{
g_autoptr(GDate) date = NULL;
return 0;
}
'''
has_gdate_autoptr = cc.compiles(
gdate_check,
dependencies : [ glib ],
name : 'g_autoptr(GDate)')

python_name = get_option('python_name')

if python_name != ''
Expand Down
9 changes: 8 additions & 1 deletion modulemd/include/private/glib-extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
* For more information on free software, see <https://www.gnu.org/philosophy/free-sw.en.html>.
*/

#pragma once

#include <glib.h>

G_DEFINE_AUTOPTR_CLEANUP_FUNC (GDate, g_date_free);
#include "config.h"

/* GDate autoptr cleanup was finally added in GLib 2.63.3. */
#ifndef HAVE_GDATE_AUTOPTR
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GDate, g_date_free)
#endif
1 change: 1 addition & 0 deletions modulemd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ cdata = configuration_data()
cdata.set_quoted('LIBMODULEMD_VERSION', libmodulemd_version)
cdata.set('HAVE_RPMIO', rpm.found())
cdata.set('HAVE_LIBMAGIC', magic.found())
cdata.set('HAVE_GDATE_AUTOPTR', has_gdate_autoptr)
configure_file(
output : 'config.h',
configuration : cdata
Expand Down

0 comments on commit 784f275

Please sign in to comment.