diff options
author | Iñigo Martínez <inigomartinez@gmail.com> | 2017-12-16 14:59:37 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-18 11:25:06 +0100 |
commit | 0735b35dd0fe87285f85c0040dfcb53cec2d1bd9 (patch) | |
tree | 91f9836bba6c365a24846869317bec15f427c0ac /libnm-glib | |
parent | a58cde8d2c9595941067be7c79e03ad34463d63a (diff) |
build: use template files for enum types' sources generation
Source files for enum types are generated by passing segments of the
source code of the files to the `glib-mkenums` command.
This patch removes those parameters where source code is used from
meson build files by moving those segmeents to template files.
https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00057.html
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/meson.build | 54 | ||||
-rw-r--r-- | libnm-glib/nm-glib-enum-types.c.template | 62 | ||||
-rw-r--r-- | libnm-glib/nm-glib-enum-types.h.template | 21 | ||||
-rw-r--r-- | libnm-glib/nm-vpn-enum-types.c.template | 37 | ||||
-rw-r--r-- | libnm-glib/nm-vpn-enum-types.h.template | 21 | ||||
-rw-r--r-- | libnm-glib/tests/meson.build | 2 |
6 files changed, 156 insertions, 41 deletions
diff --git a/libnm-glib/meson.build b/libnm-glib/meson.build index 4c3e68937..c8b2d8451 100644 --- a/libnm-glib/meson.build +++ b/libnm-glib/meson.build @@ -92,31 +92,18 @@ sources += custom_target( command: [dbus_binding_tool, '--prefix=nm_vpn_plugin', '--mode=glib-server', '--output=@OUTPUT@', '@INPUT@'] ) -enums = 'nm-vpn-enum-types' +enum_types = 'nm-vpn-enum-types' -libnm_glib_vpn_enums_h = gnome.mkenums( - enums + '.h', +libnm_glib_vpn_enum = gnome.mkenums( + enum_types, sources: vpn_headers, identifier_prefix: nm_id_prefix, - fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_VPN_ENUM_TYPES_H__\n#define __NM_VPN_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n', - vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())\n', - ftail: 'G_END_DECLS\n\n#endif /* __NM_VPN_ENUM_TYPES_H__ */', + c_template: enum_types + '.c.template', + h_template: enum_types + '.h.template', install_header: true, install_dir: libnm_glib_pkgincludedir ) -libnm_glib_vpn_enums_c = gnome.mkenums( - enums + '.c', - sources: vpn_headers, - identifier_prefix: nm_id_prefix, - fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include "nm-vpn-enum-types.h"\n\n#include "nm-vpn-plugin.h" \n#include "nm-vpn-plugin-ui-interface.h" \n#include "nm-vpn-plugin-utils.h"\n\n', - vhead: 'GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n\n if (g_once_init_enter (&g_define_type_id__volatile))\n {\n static const G@Type@Value values[] = {\n', - vprod: ' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n', - vtail: ' { 0, NULL, NULL }\n };\n GType g_define_type_id =\n g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n\n return g_define_type_id__volatile;\n}\n' -) - -libnm_glib_vpn_enums = [libnm_glib_vpn_enums_c, libnm_glib_vpn_enums_h] - deps = common_deps + [libnm_util_dep] symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib-vpn.ver') @@ -128,7 +115,7 @@ endif libnm_glib_vpn = shared_library( 'nm-glib-vpn', - sources: sources + libnm_glib_vpn_enums + [libnm_utils_enums_h], + sources: sources + libnm_glib_vpn_enum + [libnm_utils_enum[1]], version: libnm_glib_vpn_version, include_directories: common_incs, dependencies: deps, @@ -198,31 +185,18 @@ nm_secret_agent_glue = custom_target( command: [dbus_binding_tool, '--prefix=nm_secret_agent', '--mode=glib-server', '--output=@OUTPUT@', '@INPUT@'] ) -enums = 'nm-glib-enum-types' +enum_types = 'nm-glib-enum-types' -libnm_glib_enums_h = gnome.mkenums( - enums + '.h', +libnm_glib_enum = gnome.mkenums( + enum_types, sources: headers, identifier_prefix: nm_id_prefix, - fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_GLIB_ENUM_TYPES_H__\n#define __NM_GLIB_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n', - vhead: 'GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())\n', - ftail: 'G_END_DECLS\n\n#endif /* __NM_GLIB_ENUM_TYPES_H__ */', + c_template: enum_types + '.c.template', + h_template: enum_types + '.h.template', install_header: true, install_dir: libnm_glib_pkgincludedir ) -libnm_glib_enums_c = gnome.mkenums( - enums + '.c', - sources: headers, - identifier_prefix: nm_id_prefix, - fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include "nm-glib-enum-types.h"\n\n#include "nm-object.h" \n#include "nm-client.h" \n#include "nm-device.h" \n#include "nm-device-ethernet.h" \n#include "nm-device-infiniband.h" \n#include "nm-device-adsl.h" \n#include "nm-device-wifi.h" \n#include "nm-device-bt.h" \n#include "nm-device-olpc-mesh.h" \n#include "nm-device-bond.h" \n#include "nm-device-team.h" \n#include "nm-device-bridge.h" \n#include "nm-device-vlan.h" \n#include "nm-device-generic.h" \n#include "nm-access-point.h" \n#include "nm-ip4-config.h" \n#include "nm-device-modem.h" \n#include "nm-vpn-connection.h" \n#include "nm-types.h" \n#include "nm-active-connection.h" \n#include "nm-dhcp4-config.h" \n#include "nm-ip6-config.h" \n#include "nm-dhcp6-config.h" \n#include "nm-remote-connection.h" \n#include "nm-remote-settings.h" \n#include "nm-secret-agent.h" \n#include "nm-device-wimax.h" \n#include "nm-wimax-nsp.h"\n\n', - vhead: 'GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n\n if (g_once_init_enter (&g_define_type_id__volatile))\n {\n static const G@Type@Value values[] = {\n', - vprod: ' { @VALUENAME@, "@VALUENAME@", "@valuenick@" },\n', - vtail: ' { 0, NULL, NULL }\n };\n GType g_define_type_id =\n g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n\n return g_define_type_id__volatile;\n}\n' -) - -libnm_glib_enums = [libnm_glib_enums_c, libnm_glib_enums_h] - deps = common_deps + [ libudev_dep, libnm_util_dep @@ -239,7 +213,7 @@ endif libnm_glib = shared_library( 'nm-glib', - sources: sources + libnm_glib_enums + [nm_secret_agent_glue, libnm_utils_enums_h], + sources: sources + libnm_glib_enum + [nm_secret_agent_glue, libnm_utils_enum[1]], version: libnm_glib_version, include_directories: common_incs, dependencies: deps, @@ -269,7 +243,7 @@ pkg.generate( ) if enable_introspection - gir_sources = sources + headers + libnm_glib_enums + gir_sources = sources + headers + libnm_glib_enum deps = [ dbus_glib_dep, @@ -308,7 +282,7 @@ deps = common_deps + [libnm_util_dep] executable( name, - [name + '.c', libnm_utils_enums_h], + [name + '.c', libnm_utils_enum[1]], include_directories: common_incs, dependencies: deps, c_args: common_cflags, diff --git a/libnm-glib/nm-glib-enum-types.c.template b/libnm-glib/nm-glib-enum-types.c.template new file mode 100644 index 000000000..8bd4732e0 --- /dev/null +++ b/libnm-glib/nm-glib-enum-types.c.template @@ -0,0 +1,62 @@ +/*** BEGIN file-header ***/ +#include "config.h" + +#include "nm-glib-enum-types.h" + +#include "nm-object.h" +#include "nm-client.h" +#include "nm-device.h" +#include "nm-device-ethernet.h" +#include "nm-device-infiniband.h" +#include "nm-device-adsl.h" +#include "nm-device-wifi.h" +#include "nm-device-bt.h" +#include "nm-device-olpc-mesh.h" +#include "nm-device-bond.h" +#include "nm-device-team.h" +#include "nm-device-bridge.h" +#include "nm-device-vlan.h" +#include "nm-device-generic.h" +#include "nm-access-point.h" +#include "nm-ip4-config.h" +#include "nm-device-modem.h" +#include "nm-vpn-connection.h" +#include "nm-types.h" +#include "nm-active-connection.h" +#include "nm-dhcp4-config.h" +#include "nm-ip6-config.h" +#include "nm-dhcp6-config.h" +#include "nm-remote-connection.h" +#include "nm-remote-settings.h" +#include "nm-secret-agent.h" +#include "nm-device-wimax.h" +#include "nm-wimax-nsp.h" +/*** END file-header ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + 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 (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + +/*** END value-tail ***/ diff --git a/libnm-glib/nm-glib-enum-types.h.template b/libnm-glib/nm-glib-enum-types.h.template new file mode 100644 index 000000000..c0699560b --- /dev/null +++ b/libnm-glib/nm-glib-enum-types.h.template @@ -0,0 +1,21 @@ +/*** BEGIN file-header ***/ +#ifndef __NM_GLIB_ENUM_TYPES_H__ +#define __NM_GLIB_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/*** END file-header ***/ + +/*** BEGIN enumeration-production ***/ +GType @enum_name@_get_type (void) G_GNUC_CONST; +#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) + +/*** END enumeration-production ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +#endif /* __NM_GLIB_ENUM_TYPES_H__ */ +/*** END file-tail ***/ diff --git a/libnm-glib/nm-vpn-enum-types.c.template b/libnm-glib/nm-vpn-enum-types.c.template new file mode 100644 index 000000000..8aa02ff7e --- /dev/null +++ b/libnm-glib/nm-vpn-enum-types.c.template @@ -0,0 +1,37 @@ +/*** BEGIN file-header ***/ +#include "config.h" + +#include "nm-vpn-enum-types.h" + +#include "nm-vpn-plugin.h" +#include "nm-vpn-plugin-ui-interface.h" +#include "nm-vpn-plugin-utils.h" +/*** END file-header ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (&g_define_type_id__volatile)) + { + 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 (&g_define_type_id__volatile, g_define_type_id); + } + + return g_define_type_id__volatile; +} + +/*** END value-tail ***/ diff --git a/libnm-glib/nm-vpn-enum-types.h.template b/libnm-glib/nm-vpn-enum-types.h.template new file mode 100644 index 000000000..47fd96bea --- /dev/null +++ b/libnm-glib/nm-vpn-enum-types.h.template @@ -0,0 +1,21 @@ +/*** BEGIN file-header ***/ +#ifndef __NM_VPN_ENUM_TYPES_H__ +#define __NM_VPN_ENUM_TYPES_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +/*** END file-header ***/ + +/*** BEGIN enumeration-production ***/ +GType @enum_name@_get_type (void) G_GNUC_CONST; +#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ()) + +/*** END enumeration-production ***/ + +/*** BEGIN file-tail ***/ +G_END_DECLS + +#endif /* __NM_VPN_ENUM_TYPES_H__ */ +/*** END file-tail ***/ diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build index 525c3b321..c655f5fd9 100644 --- a/libnm-glib/tests/meson.build +++ b/libnm-glib/tests/meson.build @@ -24,7 +24,7 @@ test_units = [ foreach test_unit: test_units exe = executable( test_unit, - [test_unit + '.c', libnm_utils_enums_h] + shared_test_utils, + [test_unit + '.c', libnm_utils_enum[1]] + shared_test_utils, include_directories: incs, dependencies: deps, c_args: cflags |