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 | |
parent | e96fabfc186510808cee1bf6aaaa28f460f1cea5 (diff) | |
download | NetworkManager-03637ad8b5d21fcc12a536a25caf46445aabde73.tar.gz |
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')
-rw-r--r-- | libnm/fake-typelib/meson.build | 30 | ||||
-rw-r--r-- | libnm/meson.build | 316 | ||||
-rw-r--r-- | libnm/tests/meson.build | 53 |
3 files changed, 399 insertions, 0 deletions
diff --git a/libnm/fake-typelib/meson.build b/libnm/fake-typelib/meson.build new file mode 100644 index 0000000000..c0a779a2fd --- /dev/null +++ b/libnm/fake-typelib/meson.build @@ -0,0 +1,30 @@ +g_ir_compiler = find_program('g-ir-compiler') + +girs = [ + 'NetworkManager', + 'NMClient' +] + +resource_data = [] + +foreach gir: girs + gir_typelib = gir + '.typelib' + + resource_data += custom_target( + gir_typelib, + input: gir + '.gir', + output: gir_typelib, + command: [g_ir_compiler, '@INPUT@', '-o', '@OUTPUT@'] + ) +endforeach + +resource = 'typelibs' + +sources += gnome.compile_resources( + resource, + resource + '.gresource.xml', + source_dir: '.', + dependencies: resource_data, + extra_args: '--manual-register', + export: true +) diff --git a/libnm/meson.build b/libnm/meson.build new file mode 100644 index 0000000000..6abfaf580a --- /dev/null +++ b/libnm/meson.build @@ -0,0 +1,316 @@ +libnm_inc = include_directories('.') + +sources = files('nm-libnm-utils.c') + +if have_fake_typelibs + subdir('fake-typelib') +endif + +incs = [ + top_inc, + shared_inc, + libnm_core_inc +] + +deps = [ + # FIXME: this makes GIR mandatory? + gir_dep, + glib_dep, + libnmdbus_dep +] + +cflags = [ + '-DG_LOG_DOMAIN="libnm"', + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB', + '-DNMRUNDIR="@0@"'.format(nm_pkgrundir) +] + +libnm_utils = static_library( + 'nm-utils', + sources: sources, + include_directories: incs, + dependencies: deps, + c_args: cflags +) + +libnm_headers = files( + 'NetworkManager.h', + 'nm-access-point.h', + 'nm-active-connection.h', + 'nm-checkpoint.h', + 'nm-client.h', + 'nm-device-adsl.h', + 'nm-device-bond.h', + 'nm-device-bridge.h', + 'nm-device-bt.h', + 'nm-device-dummy.h', + 'nm-device-ethernet.h', + 'nm-device-generic.h', + 'nm-device.h', + 'nm-device-infiniband.h', + 'nm-device-ip-tunnel.h', + 'nm-device-macsec.h', + 'nm-device-macvlan.h', + 'nm-device-modem.h', + 'nm-device-olpc-mesh.h', + 'nm-device-ovs-interface.h', + 'nm-device-ovs-port.h', + 'nm-device-ovs-bridge.h', + 'nm-device-ppp.h', + 'nm-device-team.h', + 'nm-device-tun.h', + 'nm-device-vlan.h', + 'nm-device-vxlan.h', + 'nm-device-wifi.h', + 'nm-device-wimax.h', + 'nm-dhcp-config.h', + 'nm-ip-config.h', + 'nm-object.h', + 'nm-remote-connection.h', + 'nm-types.h', + 'nm-vpn-connection.h', + 'nm-vpn-editor.h', + 'nm-wimax-nsp.h' +) + +libnm_headers_nointrospect = files( + 'nm-secret-agent-old.h', + 'nm-vpn-plugin-old.h', + 'nm-vpn-service-plugin.h' +) + +enums_headers = libnm_headers + libnm_headers_nointrospect + [version_header] +enums = 'nm-enum-types' + +libnm_enums_h = gnome.mkenums( + enums + '.h', + sources: enums_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__ */', + 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', + 'nm-checkpoint.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-dummy.c', + 'nm-device-ethernet.c', + 'nm-device-generic.c', + 'nm-device-infiniband.c', + 'nm-device-ip-tunnel.c', + 'nm-device-macsec.c', + 'nm-device-macvlan.c', + 'nm-device-modem.c', + 'nm-device-olpc-mesh.c', + 'nm-device-ovs-interface.c', + 'nm-device-ovs-port.c', + 'nm-device-ovs-bridge.c', + 'nm-device-ppp.c', + 'nm-device-team.c', + 'nm-device-tun.c', + 'nm-device-vlan.c', + 'nm-device-vxlan.c', + 'nm-device-wifi.c', + 'nm-device-wimax.c', + 'nm-dhcp-config.c', + 'nm-dhcp4-config.c', + 'nm-dhcp6-config.c', + 'nm-dns-manager.c', + 'nm-ip-config.c', + 'nm-ip4-config.c', + 'nm-ip6-config.c', + 'nm-manager.c', + 'nm-object.c', + 'nm-remote-connection.c', + 'nm-remote-settings.c', + 'nm-secret-agent-old.c', + 'nm-vpn-connection.c', + 'nm-vpn-plugin-old.c', + 'nm-vpn-editor.c', + 'nm-vpn-service-plugin.c', + 'nm-wimax-nsp.c' +) + +deps = [ + dl_dep, + glib_dep, + libudev_dep, + uuid_dep +] + +symbol_map = join_paths(meson.current_source_dir(), 'libnm.ver') + +ldflags = [] +if have_version_script + ldflags += '-Wl,--version-script,@0@'.format(symbol_map) +endif + +libnm = shared_library( + 'nm', + sources: libnm_sources + libnm_enums, + version: libnm_version, + include_directories: incs + [libnm_core_inc], + dependencies: deps, + c_args: cflags, + link_with: libnm_utils, + link_whole: libnm_core, + link_args: ldflags, + link_depends: symbol_map, + install: true, + install_dir: get_option('libdir') +) + +libnm_dep = declare_dependency( + link_with: libnm, + include_directories: libnm_inc +) + +pkg.generate( + libraries: libnm, + version: nm_version, + name: 'libnm', + description: 'Convenience library for clients of NetworkManager', + filebase: 'libnm', + subdirs: 'libnm', + requires: 'gio-2.0', + variables: [ + 'exec_prefix=${prefix}', + 'vpnservicedir=' + join_paths(nm_pkglibdir, 'VPN') + ], + install_dir: join_paths(nm_libdir, 'pkgconfig') +) + +run_target( + 'check-local-exports-libnm', + command: [check_exports, libnm.full_path(), symbol_map], + depends: libnm +) + +if enable_introspection + gir_sources = libnm_core_enums + libnm_core_headers + libnm_core_sources + libnm_enums + libnm_headers + libnm_headers_nointrospect + libnm_sources + [version_header] + + gir_dir = join_paths(nm_datadir, 'gir-' + nm_gir_version) + typelib_dir = join_paths(nm_libdir, 'girepository-' + nm_gir_version) + + libnm_gir = gnome.generate_gir( + libnm, + sources: gir_sources, + nsversion: nm_gir_version, + namespace: 'NM', + identifier_prefix: nm_id_prefix, + symbol_prefix: nm_id_prefix.to_lower(), + export_packages: 'libnm', + includes: 'Gio-2.0', + extra_args: cflags, + install: true, + install_dir_gir: gir_dir, + install_dir_typelib: typelib_dir + ) + + # FIXME: the script parses the meson.source_root()/Makefile.am file + generate_plugin_docs = join_paths(meson.current_source_dir(), 'generate-plugin-docs.pl') + + name = 'nm-settings-keyfile-docs.xml' + nm_settings_keyfile_docs = custom_target( + name, + input: meson.source_root(), + output: name, + command: [perl, generate_plugin_docs, 'keyfile', '@INPUT@', '@OUTPUT@'] + ) + + name = 'nm-settings-docs-overrides.xml' + nm_settings_docs_overrides = custom_target( + name, + input: meson.source_root(), + output: name, + command: [perl, generate_plugin_docs, 'dbus', '@INPUT@', '@OUTPUT@'] + ) + + if enable_ifcfg_rh + name = 'nm-settings-ifcfg-rh-docs.xml' + nm_settings_ifcfg_rh_docs = custom_target( + name, + input: meson.source_root(), + output: name, + command: [perl, generate_plugin_docs, 'ifcfg-rh', '@INPUT@', '@OUTPUT@'] + ) + endif + + # FIXME: uses the following variables + # GI_TYPELIB_PATH=$(abs_builddir)/libnm$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH};', + # LD_LIBRARY_PATH=$(abs_builddir)/libnm/.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH};', + generate_setting_docs = join_paths(meson.current_source_dir(), 'generate-setting-docs.py') + + name = 'nm-property-docs.xml' + nm_property_docs = custom_target( + name, + input: libnm_gir[0], + output: name, + command: [generate_setting_docs, '--gir', '@INPUT@', '--output', '@OUTPUT@'] + ) + + # FIXME: the makefile command + ''' + # When the python scripts loads libnm and the address sanitizers is + # enabled, we must LD_PRELOAD libasan otherwise it will complain that + # it was not loaded as initial library. + 'nm-property-docs.xml: libnm/generate-setting-docs.py $(libnm_docs_sources) | libnm/NM-1.0.gir libnm/NM-1.0.typelib libnm/libnm.la + $(AM_V_GEN)', + export GI_TYPELIB_PATH=$(abs_builddir)/libnm$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH};', + export LD_LIBRARY_PATH=$(abs_builddir)/libnm/.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH};', + $(call set_sanitizer_env,$(abs_builddir)/libnm/.libs/libnm.so);', + "$(PYTHON)"', + $(srcdir)/libnm/generate-setting-docs.py', + --gir $(builddir)/libnm/NM-1.0.gir', + --output $@ + ''' + + name = 'nm-settings-docs.xml' + nm_settings_docs = custom_target( + name, + input: libnm_gir[0], + output: name, + command: [generate_setting_docs, '--gir', '@INPUT@', '--overrides', nm_settings_docs_overrides, '--output', '@OUTPUT@'] + ) + + # FIXME: the makefile command + ''' + 'nm-settings-docs.xml: libnm/generate-setting-docs.py libnm/nm-settings-docs-overrides.xml $(libnm_docs_sources) | libnm/NM-1.0.gir libnm/NM-1.0.typelib libnm/libnm.la + $(AM_V_GEN)', + export GI_TYPELIB_PATH=$(abs_builddir)/libnm$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH};', + export LD_LIBRARY_PATH=$(abs_builddir)/libnm/.libs$${LD_LIBRARY_PATH:+:$$LD_LIBRARY_PATH};', + $(call set_sanitizer_env,$(abs_builddir)/libnm/.libs/libnm.so);', + "$(PYTHON)"', + $(srcdir)/libnm/generate-setting-docs.py', + --gir $(builddir)/libnm/NM-1.0.gir', + --overrides $(word 2,$^)', + --output $@ + ''' +endif + +if enable_tests + subdir('tests') +endif diff --git a/libnm/tests/meson.build b/libnm/tests/meson.build new file mode 100644 index 0000000000..28f91772f5 --- /dev/null +++ b/libnm/tests/meson.build @@ -0,0 +1,53 @@ +test_units = [ + ['test-general', shared_utils, [libnm_utils]], + # FIXME: these tests fails usually + #['test-nm-client', shared_test_utils, []], + #['test-remote-settings-client', shared_test_utils, []], + #['test-secret-agent', shared_test_utils, []] +] + +incs = [ + top_inc, + shared_inc, + libnm_core_inc +] + +deps = [ + glib_dep, + libnm_dep +] + +cflags = [ + '-DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB', + '-DTEST_NM_SERVICE="@0@"'.format(join_paths(meson.source_root(), 'tools', 'test-networkmanager-service.py')) +] + +foreach test_unit: test_units + name = 'libnm-' + test_unit[0] + + exe = executable( + name, + [test_unit[0] + '.c'] + test_unit[1], + include_directories: incs, + dependencies: deps, + c_args: cflags, + link_with: test_unit[2] + ) + + test(name, exe) +endforeach + +incs = [ + top_inc, + shared_inc, + libnm_core_inc, + libnm_inc +] + +# 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], + include_directories: incs, + dependencies: glib_dep +) |