diff options
author | Iñigo Martínez <inigomartinez@gmail.com> | 2017-08-21 00:53:57 +0200 |
---|---|---|
committer | Iñigo Martínez <inigomartinez@gmail.com> | 2017-10-19 08:10:37 +0200 |
commit | fb288c6b10ba5a8d3e50251faeac327677380a81 (patch) | |
tree | e1eb4c9a937c86f2f59cd6ef848230b409060005 | |
parent | 35a4038f799804686c24911e759e43617bcb9d78 (diff) | |
download | glib-networking-fb288c6b10ba5a8d3e50251faeac327677380a81.tar.gz |
build: Port to 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.
https://bugzilla.gnome.org/show_bug.cgi?id=786639
-rw-r--r-- | Makefile.am | 12 | ||||
-rw-r--r-- | glib-networking.map | 8 | ||||
-rw-r--r-- | meson.build | 178 | ||||
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | meson_post_install.py | 9 | ||||
-rw-r--r-- | po/meson.build | 1 | ||||
-rw-r--r-- | proxy/gnome/Makefile.am | 2 | ||||
-rw-r--r-- | proxy/gnome/meson.build | 23 | ||||
-rw-r--r-- | proxy/libproxy/Makefile.am | 2 | ||||
-rw-r--r-- | proxy/libproxy/meson.build | 62 | ||||
-rw-r--r-- | proxy/tests/Makefile.am | 4 | ||||
-rw-r--r-- | proxy/tests/meson.build | 30 | ||||
-rw-r--r-- | template.test.in | 4 | ||||
-rw-r--r-- | tls/gnutls/Makefile.am | 2 | ||||
-rw-r--r-- | tls/gnutls/meson.build | 43 | ||||
-rw-r--r-- | tls/pkcs11/Makefile.am | 2 | ||||
-rw-r--r-- | tls/pkcs11/meson.build | 23 | ||||
-rw-r--r-- | tls/tests/Makefile.am | 5 | ||||
-rw-r--r-- | tls/tests/meson.build | 98 |
19 files changed, 509 insertions, 5 deletions
diff --git a/Makefile.am b/Makefile.am index a9826c0..d5f3ddd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,7 +34,13 @@ uninstall-hook: $(GIO_QUERYMODULES) $(GIO_MODULE_DIR) ; \ fi -EXTRA_DIST += \ - tap-driver.sh \ - tap-test \ +EXTRA_DIST += \ + tap-driver.sh \ + tap-test \ + meson.build \ + meson_options.txt \ + meson_post_install.py \ + glib-networking.map \ + template.test.in \ + po/meson.build \ $(NULL) diff --git a/glib-networking.map b/glib-networking.map new file mode 100644 index 0000000..43ed5a7 --- /dev/null +++ b/glib-networking.map @@ -0,0 +1,8 @@ +{ +global: + g_io_module_load; + g_io_module_unload; + g_io_module_query; +local: + *; +}; diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..f491a6e --- /dev/null +++ b/meson.build @@ -0,0 +1,178 @@ +project( + 'glib-networking', 'c', + version: '2.54.0', + license: 'LGPL2.1+', + meson_version: '>= 0.41.0' +) + +prefix = get_option('prefix') +datadir = join_paths(prefix, get_option('datadir')) +libdir = join_paths(prefix, get_option('libdir')) +libexecdir = join_paths(prefix, get_option('libexecdir')) +localedir = join_paths(prefix, get_option('localedir')) + +installed_tests_metadir = join_paths(datadir, 'installed-tests', meson.project_name()) +installed_tests_execdir = join_paths(libexecdir, 'installed-tests', meson.project_name()) + +cc = meson.get_compiler('c') + +config_h = configuration_data() + +config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name()) + +# compiler flags +common_flags = [ + '-DHAVE_CONFIG_H', + '-DG_LOG_DOMAIN="GLib-Net"', + '-DLOCALE_DIR="@0@"'.format(localedir), + '-DG_DISABLE_DEPRECATED', + '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_46' +] + +add_project_arguments(common_flags, language: 'c') + +symbol_map = join_paths(meson.current_source_dir(), meson.project_name() + '.map') + +module_ldflags = [ + '-Wl,--no-undefined', + '-Wl,--version-script,' + symbol_map +] + +# *** Check GLib GIO *** +glib_dep = dependency('glib-2.0', version: '>= 2.46.0') +gio_dep = dependency('gio-2.0') + +gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir') +assert(gio_module_dir != '', 'GIO_MODULE_DIR is missing from gio-2.0.pc') + +# *** Checks for LibProxy *** +have_libproxy = false + +enable_libproxy = get_option('libproxy_backend') +if enable_libproxy != 'no' + libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1', required: (enable_libproxy == 'yes')) + have_libproxy = libproxy_dep.found() + config_h.set('HAVE_LIBPROXY', have_libproxy) +endif + +# *** Checks for GNOME proxy backend *** +have_gnome_proxy = false + +enable_gnome_proxy = get_option('gnome_proxy_backend') +if enable_gnome_proxy != 'no' + gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', required: (enable_gnome_proxy == 'yes')) + have_gnome_proxy = gsettings_desktop_schemas_dep.found() + config_h.set('HAVE_GNOME_PROXY', have_gnome_proxy) +endif + +# *** Checks for GNUTLS *** +tls_support = [] + +enable_tls_support = get_option('tls_support') +if enable_tls_support + gnutls_dep = dependency('gnutls', version: '>= 3.0') + tls_support += ['gnutls'] + pkcs_support = [] + + msg = 'location of system Certificate Authority list: ' + ca_certificates_path = get_option('ca_certificates_path').strip() + test_cmd = find_program('test') + + if ca_certificates_path == '' + cert_file = '/etc/pki/tls/certs/ca-bundle.crt' + res = run_command(test_cmd, '-e', cert_file) + + if res.returncode() != 0 + cert_file = '/etc/ssl/certs/ca-certificates.crt' + res = run_command(test_cmd, '-e', cert_file) + + if res.returncode() != 0 + cert_file = '/etc/ssl/ca-bundle.pem' + res = run_command(test_cmd, '-e', cert_file) + + assert(res.returncode() != 0, msg + 'could not find. Use -Dca_certificates_path=PATH to set, or -Dtls_support=no to disable') + ca_certificates_path = cert_file + else + ca_certificates_path = cert_file + endif + else + ca_certificates_path = cert_file + endif + else + res = run_command(test_cmd, '-e', ca_certificates_path) + assert(res.returncode() != 0, msg + ca_certificates_path + ' does not exist. Use -Dca_certificates_path=PATH to set, or -Dtls_support=no to disable') + endif + message(msg + ca_certificates_path) + + # *** Checks for pkcs11 *** + have_pkcs11 = false + + enable_pkcs11_support = get_option('pkcs11_support') + if enable_pkcs11_support != 'no' + pkcs11_dep = dependency('p11-kit-1', version: '>= 0.8', required: (enable_pkcs11_support == 'yes')) + have_pkcs11 = pkcs11_dep.found() + if have_pkcs11 + tls_support += ['gnutls-pkcs11'] + pkcs_support += ['p11-kit'] + endif + + config_h.set('HAVE_PKCS11', have_pkcs11, + description: 'Building with PKCS#11 support') + endif +endif + +config_h.set('HAVE_GNUTLS', enable_tls_support) + +configure_file( + output: 'config.h', + configuration: config_h +) + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') + +po_dir = join_paths(meson.source_root(), 'po') + +top_inc = include_directories('.') + +subdir('po') + +enable_installed_tests = get_option('installed-tests') +test_template = files('template.test.in') + +if have_libproxy or have_gnome_proxy + test_programs = [] + + if have_libproxy + subdir('proxy/libproxy') + endif + + if have_gnome_proxy + subdir('proxy/gnome') + endif + + subdir('proxy/tests') +endif + +if enable_tls_support + if have_pkcs11 + tls_inc = include_directories('tls') + + subdir('tls/pkcs11') + endif + + subdir('tls/gnutls') + subdir('tls/tests') +endif + +meson.add_install_script('meson_post_install.py', gio_module_dir) + +output = '\n\n Proxy support: ' + have_libproxy.to_string() + '\n' +output += ' TLS support: ' + ' '.join(tls_support) + '\n' + +if tls_support.length() > 0 + output += ' PKCS#11 Support: ' + ' '.join(pkcs_support) + '\n' + output += ' TLS CA file: ' + ca_certificates_path + '\n' +endif +message(output) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..e59f50f --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option('libproxy_backend', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'support for libproxy') +option('gnome_proxy_backend', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'support for GNOME proxy configuration') +option('tls_support', type: 'boolean', value: true, description: 'support for GNUTLS') +option('ca_certificates_path', type: 'string', value: '', description: 'path to system Certificate Authority list') +option('pkcs11_support', type: 'combo', choices: ['yes', 'no', 'auto'], value: 'auto', description: 'support for pkcs11') +option('installed-tests', type: 'boolean', value: false, description: 'enable installed unit tests') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100644 index 0000000..3082d42 --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +if not os.environ.get('DESTDIR'): + print('GIO module cache creation...') + subprocess.call(['gio-querymodules', sys.argv[1]]) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..e9b77d7 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(meson.project_name(), preset: 'glib') diff --git a/proxy/gnome/Makefile.am b/proxy/gnome/Makefile.am index 458a8a8..8403580 100644 --- a/proxy/gnome/Makefile.am +++ b/proxy/gnome/Makefile.am @@ -14,3 +14,5 @@ libgiognomeproxy_la_LDFLAGS = $(module_flags) libgiognomeproxy_la_LIBADD = \ $(GLIB_LIBS) \ $(NULL) + +EXTRA_DIST += meson.build diff --git a/proxy/gnome/meson.build b/proxy/gnome/meson.build new file mode 100644 index 0000000..d6fbf1a --- /dev/null +++ b/proxy/gnome/meson.build @@ -0,0 +1,23 @@ +sources = files( + 'gproxyresolvergnome.c', + 'gnome-proxy-module.c' +) + +deps = [ + gio_dep, + glib_dep, + gsettings_desktop_schemas_dep +] + +shared_module( + 'giognomeproxy', + sources: sources, + include_directories: top_inc, + dependencies: deps, + link_args: module_ldflags, + link_depends: symbol_map, + install: true, + install_dir: gio_module_dir +) + +test_programs += [['gnome', deps]] diff --git a/proxy/libproxy/Makefile.am b/proxy/libproxy/Makefile.am index a386827..4550329 100644 --- a/proxy/libproxy/Makefile.am +++ b/proxy/libproxy/Makefile.am @@ -50,3 +50,5 @@ CLEANFILES += $(systemd_user_DATA) glib-pacrunner.service: glib-pacrunner.service.in Makefile $(AM_V_GEN) sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@ + +EXTRA_DIST += meson.build diff --git a/proxy/libproxy/meson.build b/proxy/libproxy/meson.build new file mode 100644 index 0000000..ca5a84e --- /dev/null +++ b/proxy/libproxy/meson.build @@ -0,0 +1,62 @@ +service_conf = configuration_data() +service_conf.set('libexecdir', libexecdir) + +service = 'org.gtk.GLib.PACRunner.service' + +configure_file( + input: service + '.in', + output: service, + install: true, + install_dir: join_paths(datadir, 'dbus-1', 'services'), + configuration: service_conf +) + +service = 'glib-pacrunner.service' + +configure_file( + input: service + '.in', + output: service, + install: true, + install_dir: join_paths(libdir, 'systemd', 'user'), + configuration: service_conf +) + +sources = files( + 'glibproxyresolver.c', + 'libproxy-module.c' +) + +deps = [ + gio_dep, + glib_dep, + libproxy_dep +] + +shared_module( + 'giolibproxy', + sources: sources, + include_directories: top_inc, + dependencies: deps, + c_args: '-DGLIBPROXY_MODULE', + link_args: module_ldflags, + link_depends: symbol_map, + install: true, + install_dir: gio_module_dir +) + +sources = files( + 'glibproxyresolver.c', + 'glibpacrunner.c' +) + +executable( + 'glib-pacrunner', + sources, + include_directories: top_inc, + dependencies: deps, + c_args: '-DGLIBPROXY_PACRUNNER', + install: true, + install_dir: libexecdir +) + +test_programs += [['libproxy', deps]] diff --git a/proxy/tests/Makefile.am b/proxy/tests/Makefile.am index 8155bce..db7bfff 100644 --- a/proxy/tests/Makefile.am +++ b/proxy/tests/Makefile.am @@ -19,4 +19,6 @@ if HAVE_LIBPROXY test_programs += libproxy endif -EXTRA_DIST += common.c +EXTRA_DIST += \ + common.c \ + meson.build diff --git a/proxy/tests/meson.build b/proxy/tests/meson.build new file mode 100644 index 0000000..15af703 --- /dev/null +++ b/proxy/tests/meson.build @@ -0,0 +1,30 @@ +cflags = [ + '-DSRCDIR="@0@"'.format(meson.current_source_dir()), + '-DTOP_BUILDDIR="@0@"'.format(meson.build_root()) +] + +foreach program: test_programs + test_conf = configuration_data() + test_conf.set('installed_tests_dir', installed_tests_execdir) + test_conf.set('program', program[0]) + + configure_file( + input: test_template, + output: program[0] + '.test', + install: enable_installed_tests, + install_dir: installed_tests_metadir, + configuration: test_conf + ) + + exe = executable( + program[0], + program[0] + '.c', + include_directories: top_inc, + dependencies: program[1], + c_args: cflags, + install: enable_installed_tests, + install_dir: installed_tests_execdir + ) + + test(program[0], exe) +endforeach diff --git a/template.test.in b/template.test.in new file mode 100644 index 0000000..6adf73f --- /dev/null +++ b/template.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Exec=@installed_tests_dir@/@program@ --tap +Output=TAP diff --git a/tls/gnutls/Makefile.am b/tls/gnutls/Makefile.am index 2fb482f..8e5b542 100644 --- a/tls/gnutls/Makefile.am +++ b/tls/gnutls/Makefile.am @@ -58,3 +58,5 @@ libgiognutls_la_LIBADD = \ $(GLIB_LIBS) \ $(GNUTLS_LIBS) \ $(NULL) + +EXTRA_DIST += meson.build diff --git a/tls/gnutls/meson.build b/tls/gnutls/meson.build new file mode 100644 index 0000000..f6eeb1a --- /dev/null +++ b/tls/gnutls/meson.build @@ -0,0 +1,43 @@ +sources = files( + 'gnutls-module.c', + 'gtlsbackend-gnutls.c', + 'gtlscertificate-gnutls.c', + 'gtlsclientconnection-gnutls.c', + 'gtlsconnection-gnutls.c', + 'gtlsdatabase-gnutls.c', + 'gtlsfiledatabase-gnutls.c', + 'gtlsinputstream-gnutls.c', + 'gtlsoutputstream-gnutls.c', + 'gtlsserverconnection-gnutls.c' +) + +incs = [top_inc] + +deps = [ + gio_dep, + glib_dep, + gnutls_dep +] + +if have_pkcs11 + sources += files( + 'gtlsbackend-gnutls-pkcs11.c', + 'gtlscertificate-gnutls-pkcs11.c', + 'gtlsdatabase-gnutls-pkcs11.c' + ) + + incs += tls_inc + + deps += libgiopkcs11_dep +endif + +shared_module( + 'giognutls', + sources: sources, + include_directories: incs, + dependencies: deps, + link_args: module_ldflags, + link_depends: symbol_map, + install: true, + install_dir: gio_module_dir +) diff --git a/tls/pkcs11/Makefile.am b/tls/pkcs11/Makefile.am index 036207c..92b7825 100644 --- a/tls/pkcs11/Makefile.am +++ b/tls/pkcs11/Makefile.am @@ -22,3 +22,5 @@ libgiopkcs11_la_LIBADD = \ AM_CPPFLAGS += \ $(PKCS11_CFLAGS) \ -DG_DISABLE_DEPRECATED + +EXTRA_DIST += meson.build diff --git a/tls/pkcs11/meson.build b/tls/pkcs11/meson.build new file mode 100644 index 0000000..76cabae --- /dev/null +++ b/tls/pkcs11/meson.build @@ -0,0 +1,23 @@ +sources = files( + 'gpkcs11array.c', + 'gpkcs11pin.c', + 'gpkcs11slot.c', + 'gpkcs11util.c' +) + +deps = [ + glib_dep, + pkcs11_dep +] + +libgiopkcs11 = static_library( + 'giopkcs11', + sources: sources, + include_directories: top_inc, + dependencies: deps +) + +libgiopkcs11_dep = declare_dependency( + link_with: libgiopkcs11, + include_directories: include_directories('.') +) diff --git a/tls/tests/Makefile.am b/tls/tests/Makefile.am index dc80ffd..35412b4 100644 --- a/tls/tests/Makefile.am +++ b/tls/tests/Makefile.am @@ -72,4 +72,7 @@ testfilesdir = $(installed_testdir)/files testfiles_DATA = $(testfiles_data) endif -EXTRA_DIST += $(testfiles_data) +EXTRA_DIST += \ + $(testfiles_data) \ + meson.build \ + $(NULL) diff --git a/tls/tests/meson.build b/tls/tests/meson.build new file mode 100644 index 0000000..4f3494b --- /dev/null +++ b/tls/tests/meson.build @@ -0,0 +1,98 @@ +incs = [top_inc] + +deps = [ + gio_dep, + glib_dep, + gnutls_dep +] + +cflags = [ + '-DSRCDIR="@0@"'.format(meson.current_source_dir()), + '-DTOP_BUILDDIR="@0@"'.format(meson.build_root()) +] + +test_programs = [ + ['certificate', [], deps], + ['file-database', [], deps], + ['connection', ['mock-interaction.c'], deps] +] + +if have_pkcs11 + incs += tls_inc + + pkcs11_deps = deps + [ + libgiopkcs11_dep, + pkcs11_dep + ] + + test_programs += [ + ['pkcs11-util', [], pkcs11_deps], + ['pkcs11-array', [], pkcs11_deps], + ['pkcs11-pin', [], pkcs11_deps], + ['pkcs11-slot', ['mock-interaction.c', 'mock-pkcs11.c'], pkcs11_deps] + ] +endif + +foreach program: test_programs + test_conf = configuration_data() + test_conf.set('installed_tests_dir', installed_tests_execdir) + test_conf.set('program', program[0]) + + configure_file( + input: test_template, + output: program[0] + '.test', + install: enable_installed_tests, + install_dir: installed_tests_metadir, + configuration: test_conf + ) + + exe = executable( + program[0], + [program[0] + '.c'] + program[1], + include_directories: incs, + dependencies: program[2], + c_args: cflags, + install: enable_installed_tests, + install_dir: installed_tests_execdir + ) + + # FIXME: it fails to locate data files because they are copied only on install time and not in compile time + # ./tap-driver.sh --test-name connection --log-file connection.log --trs-file connection.trs --color-tests yes --enable-hard-errors yes --expect-failure no -- ./tap-test _build/tls/tests/connection + # ./tap-test /tmp/gn/libexec/installed-tests/glib-networking/file-database + #test(program[0], exe, args: ['-k', '--tap']) +endforeach + +if enable_installed_tests + test_data = files( + 'files/ca-alternative.pem', + 'files/ca-key.pem', + 'files/ca.pem', + 'files/ca-roots-bad.pem', + 'files/ca-roots.pem', + 'files/ca-verisign-sha1.pem', + 'files/chain.pem', + 'files/chain-with-verisign-md2.pem', + 'files/client2-and-key.pem', + 'files/client2-key.pem', + 'files/client2.pem', + 'files/client-and-key.pem', + 'files/client-future.pem', + 'files/client-past.pem', + 'files/client.pem', + 'files/intermediate-ca.pem', + 'files/non-ca.pem', + 'files/server-and-key.pem', + 'files/server.der', + 'files/server-intermediate-key.pem', + 'files/server-intermediate.pem', + 'files/server-key.der', + 'files/server-key.pem', + 'files/server.pem', + 'files/server-self.pem' + ) + + install_data( + test_data, + install_dir: join_paths(installed_tests_execdir, 'files') + ) +endif |