summaryrefslogtreecommitdiff
path: root/libnm
diff options
context:
space:
mode:
authorIñigo Martínez <inigomartinez@gmail.com>2017-12-16 14:59:37 +0100
committerThomas Haller <thaller@redhat.com>2017-12-18 11:25:06 +0100
commit0735b35dd0fe87285f85c0040dfcb53cec2d1bd9 (patch)
tree91f9836bba6c365a24846869317bec15f427c0ac /libnm
parenta58cde8d2c9595941067be7c79e03ad34463d63a (diff)
downloadNetworkManager-0735b35dd0fe87285f85c0040dfcb53cec2d1bd9.tar.gz
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')
-rw-r--r--libnm/meson.build31
-rw-r--r--libnm/nm-enum-types.c.template76
-rw-r--r--libnm/nm-enum-types.h.template22
-rw-r--r--libnm/tests/meson.build2
4 files changed, 108 insertions, 23 deletions
diff --git a/libnm/meson.build b/libnm/meson.build
index 24e0fb0bf7..f286faa805 100644
--- a/libnm/meson.build
+++ b/libnm/meson.build
@@ -81,32 +81,19 @@ install_headers(
subdir: 'libnm'
)
-enums_headers = libnm_headers + [version_header]
-enums = 'nm-enum-types'
+enum_headers = libnm_headers + [version_header]
+enum_types = 'nm-enum-types'
-libnm_enums_h = gnome.mkenums(
- enums + '.h',
- sources: enums_headers,
+libnm_enum = gnome.mkenums(
+ enum_types,
+ sources: enum_headers,
identifier_prefix: nm_id_prefix,
- fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#ifndef __NM_ENUM_TYPES_H__\n#define __NM_ENUM_TYPES_H__\n\n#include <nm-core-enum-types.h>\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_ENUM_TYPES_H__ */',
+ c_template: enum_types + '.c.template',
+ h_template: enum_types + '.h.template',
install_header: true,
install_dir: libnm_pkgincludedir
)
-libnm_enums_c = gnome.mkenums(
- enums + '.c',
- sources: enums_headers,
- identifier_prefix: nm_id_prefix,
- fhead: '/* Generated by glib-mkenums. Do not edit */\n\n#include "config.h"\n\n#include "nm-enum-types.h"\n#include "nm-default.h"\n\n#include "nm-version-macros.h" \n#include "NetworkManager.h" \n#include "nm-access-point.h" \n#include "nm-active-connection.h" \n#include "nm-checkpoint.h" \n#include "nm-client.h" \n#include "nm-device-adsl.h" \n#include "nm-device-bond.h" \n#include "nm-device-bridge.h" \n#include "nm-device-bt.h" \n#include "nm-device-dummy.h" \n#include "nm-device-ethernet.h" \n#include "nm-device-generic.h" \n#include "nm-device-infiniband.h" \n#include "nm-device-ip-tunnel.h" \n#include "nm-device-macsec.h" \n#include "nm-device-macvlan.h" \n#include "nm-device-modem.h" \n#include "nm-device-olpc-mesh.h" \n#include "nm-device-ovs-interface.h" \n#include "nm-device-ovs-port.h" \n#include "nm-device-ovs-bridge.h" \n#include "nm-device-ppp.h" \n#include "nm-device-team.h" \n#include "nm-device-tun.h" \n#include "nm-device-vlan.h" \n#include "nm-device-vxlan.h" \n#include "nm-device-wifi.h" \n#include "nm-device-wimax.h" \n#include "nm-device.h" \n#include "nm-dhcp-config.h" \n#include "nm-ip-config.h" \n#include "nm-object.h" \n#include "nm-remote-connection.h" \n#include "nm-types.h" \n#include "nm-vpn-connection.h" \n#include "nm-vpn-editor.h" \n#include "nm-wimax-nsp.h" \n#include "nm-secret-agent-old.h" \n#include "nm-vpn-plugin-old.h" \n#include "nm-vpn-service-plugin.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_enums = [libnm_enums_c, libnm_enums_h]
-
libnm_sources = files(
'nm-access-point.c',
'nm-active-connection.c',
@@ -172,7 +159,7 @@ endif
libnm = shared_library(
'nm',
- sources: libnm_sources + libnm_enums,
+ sources: libnm_sources + libnm_enum,
version: libnm_version,
include_directories: incs + [libnm_core_inc],
dependencies: deps,
@@ -212,7 +199,7 @@ run_target(
)
if enable_introspection
- gir_sources = libnm_core_enums + libnm_core_headers + libnm_core_sources + libnm_enums + libnm_headers + libnm_sources + [version_header]
+ gir_sources = libnm_core_enum + libnm_core_headers + libnm_core_sources + libnm_enum + libnm_headers + libnm_sources + [version_header]
gir_dir = join_paths(nm_datadir, 'gir-' + nm_gir_version)
typelib_dir = join_paths(nm_libdir, 'girepository-' + nm_gir_version)
diff --git a/libnm/nm-enum-types.c.template b/libnm/nm-enum-types.c.template
new file mode 100644
index 0000000000..5abd5c794c
--- /dev/null
+++ b/libnm/nm-enum-types.c.template
@@ -0,0 +1,76 @@
+/*** BEGIN file-header ***/
+#include "config.h"
+
+#include "nm-enum-types.h"
+#include "nm-default.h"
+
+#include "nm-version-macros.h"
+#include "NetworkManager.h"
+#include "nm-access-point.h"
+#include "nm-active-connection.h"
+#include "nm-checkpoint.h"
+#include "nm-client.h"
+#include "nm-device-adsl.h"
+#include "nm-device-bond.h"
+#include "nm-device-bridge.h"
+#include "nm-device-bt.h"
+#include "nm-device-dummy.h"
+#include "nm-device-ethernet.h"
+#include "nm-device-generic.h"
+#include "nm-device-infiniband.h"
+#include "nm-device-ip-tunnel.h"
+#include "nm-device-macsec.h"
+#include "nm-device-macvlan.h"
+#include "nm-device-modem.h"
+#include "nm-device-olpc-mesh.h"
+#include "nm-device-ovs-interface.h"
+#include "nm-device-ovs-port.h"
+#include "nm-device-ovs-bridge.h"
+#include "nm-device-ppp.h"
+#include "nm-device-team.h"
+#include "nm-device-tun.h"
+#include "nm-device-vlan.h"
+#include "nm-device-vxlan.h"
+#include "nm-device-wifi.h"
+#include "nm-device-wimax.h"
+#include "nm-device.h"
+#include "nm-dhcp-config.h"
+#include "nm-ip-config.h"
+#include "nm-object.h"
+#include "nm-remote-connection.h"
+#include "nm-types.h"
+#include "nm-vpn-connection.h"
+#include "nm-vpn-editor.h"
+#include "nm-wimax-nsp.h"
+#include "nm-secret-agent-old.h"
+#include "nm-vpn-plugin-old.h"
+#include "nm-vpn-service-plugin.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/nm-enum-types.h.template b/libnm/nm-enum-types.h.template
new file mode 100644
index 0000000000..bd9ce40b25
--- /dev/null
+++ b/libnm/nm-enum-types.h.template
@@ -0,0 +1,22 @@
+/*** BEGIN file-header ***/
+#ifndef __NM_ENUM_TYPES_H__
+#define __NM_ENUM_TYPES_H__
+
+#include <nm-core-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_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build
index 57791cedea..fa7470f980 100644
--- a/libnm/tests/meson.build
+++ b/libnm/tests/meson.build
@@ -45,7 +45,7 @@ incs = [
# just test, that we can build "nm-vpn-plugin-utils.c"
libnm_vpn_plugin_utils_test = static_library(
'nm-vpn-plugin-utils-test',
- sources: shared_vpn_plugin_utils + [libnm_enums_h],
+ sources: shared_vpn_plugin_utils + [libnm_enum[1]],
include_directories: incs,
dependencies: glib_dep
)