diff options
author | Iñigo Martínez <inigomartinez@gmail.com> | 2017-11-25 11:39:06 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-13 15:48:50 +0100 |
commit | 03637ad8b5d21fcc12a536a25caf46445aabde73 (patch) | |
tree | 3330fed2a9ad0f45c0c993a8aac6d3dee42ed101 /libnm-glib | |
parent | e96fabfc186510808cee1bf6aaaa28f460f1cea5 (diff) |
build: add initial support for meson build system
meson is a build system focused on speed an ease of use, which
helps speeding up the software development. This patch adds meson
support along autotools.
[thaller@redhat.com: rebased patch and adjusted for iwd support]
https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00022.html
Diffstat (limited to 'libnm-glib')
-rw-r--r-- | libnm-glib/meson.build | 326 | ||||
-rw-r--r-- | libnm-glib/tests/meson.build | 36 |
2 files changed, 362 insertions, 0 deletions
diff --git a/libnm-glib/meson.build b/libnm-glib/meson.build new file mode 100644 index 000000000..4c3e68937 --- /dev/null +++ b/libnm-glib/meson.build @@ -0,0 +1,326 @@ +dbus_binding_tool = find_program('dbus-binding-tool') + +common_incs = [ + top_inc, + shared_inc +] + +common_deps = [ + dbus_dep, + dbus_glib_dep, + glib_dep +] + +common_cflags = [ + '-DG_LOG_DOMAIN="libnm-glib"', + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY' +] + +libnm_glib_inc = include_directories('.') + +vpn_headers = files( + 'nm-vpn-plugin.h', + 'nm-vpn-plugin-ui-interface.h', + 'nm-vpn-plugin-utils.h' +) + +headers = files( + 'nm-access-point.h', + 'nm-active-connection.h', + 'nm-client.h', + 'nm-device-adsl.h', + 'nm-device-bond.h', + 'nm-device-bridge.h', + 'nm-device-bt.h', + 'nm-device-ethernet.h', + 'nm-device-generic.h', + 'nm-device.h', + 'nm-device-infiniband.h', + 'nm-device-modem.h', + 'nm-device-olpc-mesh.h', + 'nm-device-team.h', + 'nm-device-vlan.h', + 'nm-device-wifi.h', + 'nm-device-wimax.h', + 'nm-dhcp4-config.h', + 'nm-dhcp6-config.h', + 'nm-ip4-config.h', + 'nm-ip6-config.h', + 'nm-object.h', + 'nm-remote-connection.h', + 'nm-remote-settings.h', + 'nm-secret-agent.h', + 'nm-types.h', + 'nm-vpn-connection.h', + 'nm-wimax-nsp.h' +) + +deprecated_headers = files('libnm_glib.h') + +install_headers( + headers + vpn_headers + deprecated_headers, + subdir: 'libnm-glib' +) + +incs = common_incs + [libnm_util_inc] + +cflags = common_cflags + [ + '-Wno-deprecated-declarations', + '-Wno-deprecated' +] + +libdeprecated_nm_glib = static_library( + 'deprecated-nm-glib', + sources: 'libnm_glib.c', + include_directories: incs, + dependencies: common_deps, + c_args: cflags +) + +sources = files( + 'nm-vpn-plugin.c', + 'nm-vpn-plugin-ui-interface.c', + 'nm-vpn-plugin-utils.c' +) + +glue = 'nm-vpn-plugin-glue.h' + +sources += custom_target( + glue, + input: ifaces_vpn_plugin_xml, + output: glue, + command: [dbus_binding_tool, '--prefix=nm_vpn_plugin', '--mode=glib-server', '--output=@OUTPUT@', '@INPUT@'] +) + +enums = 'nm-vpn-enum-types' + +libnm_glib_vpn_enums_h = gnome.mkenums( + enums + '.h', + 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__ */', + 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') + +ldflags = [] +if have_version_script + ldflags += '-Wl,--version-script,@0@'.format(symbol_map) +endif + +libnm_glib_vpn = shared_library( + 'nm-glib-vpn', + sources: sources + libnm_glib_vpn_enums + [libnm_utils_enums_h], + version: libnm_glib_vpn_version, + include_directories: common_incs, + dependencies: deps, + c_args: common_cflags, + link_args: ldflags, + link_depends: symbol_map, + install: true, + install_dir: get_option('libdir') +) + +libnm_glib_vpn_dep = declare_dependency( + link_with: libnm_glib_vpn, + include_directories: libnm_glib_inc +) + +pkg.generate( + libraries: libnm_glib_vpn, + version: nm_version, + name: 'libnm-glib-vpn', + description: 'Convenience library for NetworkManager VPN plugins', + filebase: 'libnm-glib-vpn', + subdirs: 'libnm-glib', + requires: 'NetworkManager >= ' + nm_version + ' glib-2.0 dbus-glib-1', + variables: 'exec_prefix=${prefix}', + install_dir: join_paths(nm_libdir, 'pkgconfig') +) + +sources = shared_udev_utils + files( + 'nm-access-point.c', + 'nm-active-connection.c', + 'nm-client.c', + 'nm-dbus-helpers.c', + 'nm-device-adsl.c', + 'nm-device-bond.c', + 'nm-device-bridge.c', + 'nm-device-bt.c', + 'nm-device.c', + 'nm-device-ethernet.c', + 'nm-device-generic.c', + 'nm-device-infiniband.c', + 'nm-device-olpc-mesh.c', + 'nm-device-modem.c', + 'nm-device-team.c', + 'nm-device-vlan.c', + 'nm-device-wifi.c', + 'nm-device-wimax.c', + 'nm-dhcp4-config.c', + 'nm-dhcp6-config.c', + 'nm-ip4-config.c', + 'nm-ip6-config.c', + 'nm-object.c', + 'nm-object-cache.c', + 'nm-remote-connection.c', + 'nm-remote-settings.c', + 'nm-secret-agent.c', + 'nm-types.c', + 'nm-vpn-connection.c', + 'nm-wimax-nsp.c' +) + +glue = 'nm-secret-agent-glue.h' + +nm_secret_agent_glue = custom_target( + glue, + input: ifaces_secret_agent_xml, + output: glue, + command: [dbus_binding_tool, '--prefix=nm_secret_agent', '--mode=glib-server', '--output=@OUTPUT@', '@INPUT@'] +) + +enums = 'nm-glib-enum-types' + +libnm_glib_enums_h = gnome.mkenums( + enums + '.h', + 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__ */', + 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 +] + +cflags = common_cflags + ['-DNMRUNDIR="@0@"'.format(nm_pkgrundir)] + +symbol_map = join_paths(meson.current_source_dir(), 'libnm-glib.ver') + +ldflags = [] +if have_version_script + ldflags += '-Wl,--version-script,@0@'.format(symbol_map) +endif + +libnm_glib = shared_library( + 'nm-glib', + sources: sources + libnm_glib_enums + [nm_secret_agent_glue, libnm_utils_enums_h], + version: libnm_glib_version, + include_directories: common_incs, + dependencies: deps, + c_args: cflags, + link_with: libdeprecated_nm_glib, + link_args: ldflags, + link_depends: symbol_map, + install: true, + install_dir: get_option('libdir') +) + +libnm_glib_dep = declare_dependency( + link_with: libnm_glib, + include_directories: libnm_glib_inc +) + +pkg.generate( + libraries: libnm_glib, + version: nm_version, + name: 'libnm-glib', + description: 'Convenience library for clients of NetworkManager', + filebase: 'libnm-glib', + subdirs: 'libnm-glib', + requires: 'libnm-util >= ' + nm_version + ' NetworkManager >= ' + nm_version + ' gobject-2.0 dbus-glib-1', + variables: 'exec_prefix=${prefix}', + install_dir: join_paths(nm_libdir, 'pkgconfig') +) + +if enable_introspection + gir_sources = sources + headers + libnm_glib_enums + + deps = [ + dbus_glib_dep, + libnm_glib_dep, + libnm_util_gir_dep + ] + + gir_includes = [ + 'DBusGLib-1.0', + 'Gio-2.0' + ] + + gir_dir = join_paths(nm_datadir, 'gir-' + nm_gir_version) + typelib_dir = join_paths(nm_libdir, 'girepository-' + nm_gir_version) + + libnm_glib_gir = gnome.generate_gir( + libnm_glib, + sources: gir_sources, + dependencies: deps, + nsversion: nm_gir_version, + namespace: 'NMClient', + identifier_prefix: nm_id_prefix, + symbol_prefix: nm_id_prefix.to_lower(), + export_packages: ['libnm-glib', 'libnm-glib-vpn'], + includes: gir_includes, + extra_args: common_cflags + ['--include-uninstalled=' + libnm_util_gir[0].full_path()], + install: true, + install_dir_gir: gir_dir, + install_dir_typelib: typelib_dir + ) +endif + +name = 'libnm-glib-test' + +deps = common_deps + [libnm_util_dep] + +executable( + name, + [name + '.c', libnm_utils_enums_h], + include_directories: common_incs, + dependencies: deps, + c_args: common_cflags, + link_with: libnm_glib +) + +run_target( + 'check-local-exports-libnm-glib', + command: [check_exports, libnm_glib.full_path(), symbol_map], + depends: libnm_glib +) + +if enable_tests + subdir('tests') +endif diff --git a/libnm-glib/tests/meson.build b/libnm-glib/tests/meson.build new file mode 100644 index 000000000..8e0fc7bb1 --- /dev/null +++ b/libnm-glib/tests/meson.build @@ -0,0 +1,36 @@ +incs = [ + top_inc, + shared_inc +] + +deps = [ + dbus_dep, + dbus_glib_dep, + glib_dep, + libnm_glib_dep, + libnm_util_dep +] + +cflags = [ + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY', + '-DTEST_NM_SERVICE="@0@"'.format(join_paths(meson.source_root(), 'tools', 'test-networkmanager-service.py')) +] + +test_units = [ + 'test-nm-client', + 'test-remote-settings-client' +] + +foreach test_unit: test_units + name = 'libnm-glib-' + test_unit + + exe = executable( + name, + [test_unit + '.c', libnm_utils_enums_h] + shared_test_utils, + include_directories: incs, + dependencies: deps, + c_args: cflags + ) + + test(name, exe) +endforeach |