From 756b424cce0ea7a0fe93b3a95c3529214ad70551 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Thu, 22 Sep 2022 14:59:52 -0400 Subject: [PATCH] meson: Use gnome.mkenum_simple() Meson now uses find_program() to get glib-mkenum from glib instead of from system. That was already fixed at least in >=0.60 which is our current minimum requirement. --- gio/gio-autocleanups.h | 2 + gio/gioenumtypes.c.template | 63 ------------------------------- gio/gioenumtypes.h.template | 46 ---------------------- gio/meson.build | 35 ++++++----------- gobject/glib-enumtypes.c.template | 47 ----------------------- gobject/glib-enumtypes.h.template | 24 ------------ gobject/meson.build | 37 ++++++++---------- meson.build | 2 + 8 files changed, 30 insertions(+), 226 deletions(-) delete mode 100644 gio/gioenumtypes.c.template delete mode 100644 gio/gioenumtypes.h.template delete mode 100644 gobject/glib-enumtypes.c.template delete mode 100644 gobject/glib-enumtypes.h.template diff --git a/gio/gio-autocleanups.h b/gio/gio-autocleanups.h index 15e37d164..0f341c1cf 100644 --- a/gio/gio-autocleanups.h +++ b/gio/gio-autocleanups.h @@ -19,6 +19,8 @@ * Author: Ryan Lortie */ +#pragma once + #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) #error "Only can be included directly." #endif diff --git a/gio/gioenumtypes.c.template b/gio/gioenumtypes.c.template deleted file mode 100644 index 5e119a342..000000000 --- a/gio/gioenumtypes.c.template +++ /dev/null @@ -1,63 +0,0 @@ -/*** BEGIN file-header ***/ -/* - * Copyright © 2007 Red Hat, Inc. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * Authors: Matthias Clasen - */ - -#ifndef GLIB_DISABLE_DEPRECATION_WARNINGS -#define GLIB_DISABLE_DEPRECATION_WARNINGS -#endif - -#include "config.h" -#include "gioenumtypes.h" -#include - -/*** END file-header ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static gsize static_g_define_type_id = 0; - - if (g_once_init_enter (&static_g_define_type_id)) - { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); - g_once_init_leave (&static_g_define_type_id, g_define_type_id); - } - - return static_g_define_type_id; -} - -/*** END value-tail ***/ diff --git a/gio/gioenumtypes.h.template b/gio/gioenumtypes.h.template deleted file mode 100644 index c75a3b459..000000000 --- a/gio/gioenumtypes.h.template +++ /dev/null @@ -1,46 +0,0 @@ -/*** BEGIN file-header ***/ -/* - * Copyright © 2007 Red Hat, Inc. - * - * SPDX-License-Identifier: LGPL-2.1-or-later - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * Authors: Matthias Clasen - */ - -#ifndef __GIO_ENUM_TYPES_H__ -#define __GIO_ENUM_TYPES_H__ - -#include -#include - -G_BEGIN_DECLS -/*** END file-header ***/ - -/*** BEGIN file-production ***/ - -/* enumerations from "@filename@" */ -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GIO_AVAILABLE_IN_ALL GType @enum_name@_get_type (void) G_GNUC_CONST; -#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) -/*** END value-header ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* __GIO_ENUM_TYPES_H__ */ -/*** END file-tail ***/ diff --git a/gio/meson.build b/gio/meson.build index 07ef31b93..076dfc07f 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -765,29 +765,16 @@ gio_headers += settings_headers gio_headers += gdbus_headers install_headers(gio_headers, install_dir : gio_includedir) -# We can't use gnome.mkenums() because the GNOME module looks for glib-mkenums -# in PATH, which means you can't bootstrap glib with its own glib-mkenums. -gioenumtypes_h = custom_target('gioenumtypes_h', - output : 'gioenumtypes.h', - capture : true, - input : gio_headers, - install : true, - install_dir : gio_includedir, - # FIXME: Not needed with Meson >= 0.64.0 - install_tag: 'devel', - command : [python, glib_mkenums, - '--template', files('gioenumtypes.h.template'), - '@INPUT@', gnetworking_h]) - -gioenumtypes_c = custom_target('gioenumtypes_c', - output : 'gioenumtypes.c', - capture : true, - input : gio_headers, - depends : [gioenumtypes_h], - command : [python, glib_mkenums, - '--template', files('gioenumtypes.c.template'), - '@INPUT@', gnetworking_h]) - +mkenums_header_prefix = '#include ' +gioenumtypes = gnome.mkenums_simple('gioenumtypes', + sources : gio_headers, + decorator : 'GIO_AVAILABLE_IN_ALL', + body_prefix : mkenums_body_prefix, + header_prefix : mkenums_header_prefix, + install_header : true, + install_dir : join_paths(get_option('includedir'), 'glib-2.0/gio'), +) +gioenumtypes_h = gioenumtypes[1] gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, glib_enumtypes_h, gvisibility_h]) # inotify @@ -840,7 +827,7 @@ else endif libgio = library('gio-2.0', - gioenumtypes_h, gioenumtypes_c, gnetworking_h, gio_sources, + gioenumtypes, gnetworking_h, gio_sources, gio_dtrace_hdr, gio_dtrace_obj, version : library_version, soversion : soversion, diff --git a/gobject/glib-enumtypes.c.template b/gobject/glib-enumtypes.c.template deleted file mode 100644 index 42f9c341f..000000000 --- a/gobject/glib-enumtypes.c.template +++ /dev/null @@ -1,47 +0,0 @@ -/*** BEGIN file-header ***/ -#include "config.h" -#include "glib-enumtypes.h" -#include - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -/*** END file-header ***/ - -/*** BEGIN file-tail ***/ - -G_GNUC_END_IGNORE_DEPRECATIONS - -/*** END file-tail ***/ - -/*** BEGIN file-production ***/ -/* enumerations from "@filename@" */ - -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GType -@enum_name@_get_type (void) -{ - static gsize static_g_define_type_id = 0; - - if (g_once_init_enter (&static_g_define_type_id)) - { - static const G@Type@Value values[] = { -/*** END value-header ***/ - -/*** BEGIN value-production ***/ - { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, -/*** END value-production ***/ - -/*** BEGIN value-tail ***/ - { 0, NULL, NULL } - }; - GType g_define_type_id = - g_@type@_register_static (g_intern_static_string ("@EnumName@"), values); - g_once_init_leave (&static_g_define_type_id, g_define_type_id); - } - - return static_g_define_type_id; -} - -/*** END value-tail ***/ diff --git a/gobject/glib-enumtypes.h.template b/gobject/glib-enumtypes.h.template deleted file mode 100644 index f907d9cae..000000000 --- a/gobject/glib-enumtypes.h.template +++ /dev/null @@ -1,24 +0,0 @@ -/*** BEGIN file-header ***/ -#ifndef __GOBJECT_ENUM_TYPES_H__ -#define __GOBJECT_ENUM_TYPES_H__ - -#include - -G_BEGIN_DECLS -/*** END file-header ***/ - -/*** BEGIN file-production ***/ - -/* enumerations from "@filename@" */ -/*** END file-production ***/ - -/*** BEGIN value-header ***/ -GOBJECT_AVAILABLE_IN_2_60 GType @enum_name@_get_type (void) G_GNUC_CONST; -#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) -/*** END value-header ***/ - -/*** BEGIN file-tail ***/ -G_END_DECLS - -#endif /* __GOBJECT_ENUM_TYPES_H__ */ -/*** END file-tail ***/ diff --git a/gobject/meson.build b/gobject/meson.build index dafc44b09..07ad13229 100644 --- a/gobject/meson.build +++ b/gobject/meson.build @@ -109,39 +109,32 @@ endforeach # # For now, we only include gunicode.h here, since GScriptType is needed for # Pango. More headers can be added as needed in future. -# -# We can't use gnome.mkenums() because the GNOME module looks for glib-mkenums -# in PATH, which means you can't bootstrap glib with its own glib-mkenums. glib_enumtypes_input_headers = files( '../glib/gunicode.h', ) -glib_enumtypes_h = custom_target('glib_enumtypes_h', - output : 'glib-enumtypes.h', - capture : true, - input : glib_enumtypes_input_headers, - install : true, - install_dir : join_paths(get_option('includedir'), 'glib-2.0/gobject'), - install_tag: 'devel', - command : [python, glib_mkenums, - '--template', files('glib-enumtypes.h.template'), - '@INPUT@']) +mkenums_body_prefix = ''' + #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS + #define GLIB_DISABLE_DEPRECATION_WARNINGS + #endif + #include "config.h" +''' -glib_enumtypes_c = custom_target('glib_enumtypes_c', - output : 'glib-enumtypes.c', - capture : true, - input : glib_enumtypes_input_headers, - depends : [glib_enumtypes_h], - command : [python, glib_mkenums, - '--template', files('glib-enumtypes.c.template'), - '@INPUT@']) +glib_enumtypes = gnome.mkenums_simple('glib-enumtypes', + sources : glib_enumtypes_input_headers, + decorator : 'GOBJECT_AVAILABLE_IN_2_60', + body_prefix : mkenums_body_prefix, + install_header : true, + install_dir : join_paths(get_option('includedir'), 'glib-2.0/gobject'), +) +glib_enumtypes_h = glib_enumtypes[1] # Expose as variable to be used by gobject-introspection # when it includes GLib as a subproject glib_types_h = files('glib-types.h') libgobject = library('gobject-2.0', - gobject_dtrace_obj, gobject_dtrace_hdr, glib_enumtypes_h, glib_enumtypes_c, + gobject_dtrace_obj, gobject_dtrace_hdr, glib_enumtypes, sources : gobject_sources, version : library_version, soversion : soversion, diff --git a/meson.build b/meson.build index 996056f7d..9b2f296a4 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,8 @@ project('glib', 'c', ] ) +gnome = import('gnome') + cc = meson.get_compiler('c') c_standards = {}