diff --git a/gio/gio-autocleanups.h b/gio/gio-autocleanups.h index 0f341c1cf..15e37d164 100644 --- a/gio/gio-autocleanups.h +++ b/gio/gio-autocleanups.h @@ -19,8 +19,6 @@ * 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 new file mode 100644 index 000000000..5e119a342 --- /dev/null +++ b/gio/gioenumtypes.c.template @@ -0,0 +1,63 @@ +/*** 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 new file mode 100644 index 000000000..c75a3b459 --- /dev/null +++ b/gio/gioenumtypes.h.template @@ -0,0 +1,46 @@ +/*** 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 076dfc07f..07ef31b93 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -765,16 +765,29 @@ gio_headers += settings_headers gio_headers += gdbus_headers install_headers(gio_headers, install_dir : gio_includedir) -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] +# 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]) + gioenumtypes_dep = declare_dependency(sources : [gioenumtypes_h, glib_enumtypes_h, gvisibility_h]) # inotify @@ -827,7 +840,7 @@ else endif libgio = library('gio-2.0', - gioenumtypes, gnetworking_h, gio_sources, + gioenumtypes_h, gioenumtypes_c, 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 new file mode 100644 index 000000000..42f9c341f --- /dev/null +++ b/gobject/glib-enumtypes.c.template @@ -0,0 +1,47 @@ +/*** 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 new file mode 100644 index 000000000..f907d9cae --- /dev/null +++ b/gobject/glib-enumtypes.h.template @@ -0,0 +1,24 @@ +/*** 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 07ad13229..dafc44b09 100644 --- a/gobject/meson.build +++ b/gobject/meson.build @@ -109,32 +109,39 @@ 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', ) -mkenums_body_prefix = ''' - #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS - #define GLIB_DISABLE_DEPRECATION_WARNINGS - #endif - #include "config.h" -''' - -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, +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'), -) -glib_enumtypes_h = glib_enumtypes[1] + install_tag: 'devel', + command : [python, glib_mkenums, + '--template', files('glib-enumtypes.h.template'), + '@INPUT@']) + +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@']) # 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, + gobject_dtrace_obj, gobject_dtrace_hdr, glib_enumtypes_h, glib_enumtypes_c, sources : gobject_sources, version : library_version, soversion : soversion, diff --git a/meson.build b/meson.build index 9b2f296a4..996056f7d 100644 --- a/meson.build +++ b/meson.build @@ -9,8 +9,6 @@ project('glib', 'c', ] ) -gnome = import('gnome') - cc = meson.get_compiler('c') c_standards = {}