[glib-networking/wip/inigomartinez/meson: 1/2] build: Port to meson build system
- From: Iñigo Martínez <inigomartinez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/wip/inigomartinez/meson: 1/2] build: Port to meson build system
- Date: Thu, 19 Oct 2017 21:41:28 +0000 (UTC)
commit 32d26f70e3e72e8e6982e4963855720268747c9c
Author: Iñigo Martínez <inigomartinez gmail com>
Date: Mon Aug 21 00:53:57 2017 +0200
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
Makefile.am | 12 +++-
check_certs.py | 12 +++
glib-networking.map | 8 ++
meson.build | 160 ++++++++++++++++++++++++++++++++++++++++++++
meson_options.txt | 6 ++
meson_post_install.py | 9 +++
po/meson.build | 1 +
proxy/gnome/Makefile.am | 2 +
proxy/gnome/meson.build | 23 ++++++
proxy/libproxy/Makefile.am | 2 +
proxy/libproxy/meson.build | 62 +++++++++++++++++
proxy/tests/Makefile.am | 4 +-
proxy/tests/meson.build | 39 +++++++++++
template.test.in | 4 +
tls/gnutls/Makefile.am | 2 +
tls/gnutls/meson.build | 43 ++++++++++++
tls/pkcs11/Makefile.am | 2 +
tls/pkcs11/meson.build | 23 ++++++
tls/tests/Makefile.am | 5 +-
tls/tests/meson.build | 104 ++++++++++++++++++++++++++++
20 files changed, 518 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/check_certs.py b/check_certs.py
new file mode 100755
index 0000000..9bc0c04
--- /dev/null
+++ b/check_certs.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import errno
+import os
+import sys
+
+for arg in sys.argv[1:]:
+ if os.path.isfile(arg):
+ sys.stdout.write(arg)
+ sys.exit(0)
+
+sys.exit(errno.ENOENT)
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..7e05d39
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,160 @@
+project(
+ 'glib-networking', 'c',
+ version: '2.54.0',
+ license: 'LGPL2.1+',
+ meson_version: '>= 0.43.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 = []
+
+if host_machine.system().contains('linux')
+ test_ldflag = '-Wl,--version-script,' + symbol_map
+
+ module_ldflags += cc.get_supported_arguments(test_ldflag)
+endif
+
+# *** 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()
+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()
+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: '
+ cert_locations = [
+ get_option('ca_certificates_path'),
+ '/etc/pki/tls/certs/ca-bundle.crt',
+ '/etc/ssl/certs/ca-certificates.crt',
+ '/etc/ssl/ca-bundle.pem'
+ ]
+
+ res = run_command(find_program('check_certs.py'), cert_locations)
+ assert(res.returncode() == 0, msg + ' could not find any TLS certificate. Use -Dca_certificates_path=PATH
to set, or -Dtls_support=no to disable')
+ ca_certificates_path = res.stdout().strip()
+ 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
+
+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..d7a5aba
--- /dev/null
+++ b/proxy/tests/meson.build
@@ -0,0 +1,39 @@
+cflags = [
+ '-DSRCDIR="@0@"'.format(meson.current_source_dir()),
+ '-DTOP_BUILDDIR="@0@"'.format(meson.build_root())
+]
+
+envs = [
+ 'G_TEST_SRCDIR=' + meson.current_source_dir(),
+ 'G_TEST_BUILDDIR=' + meson.current_build_dir()
+]
+
+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,
+ env: envs
+ )
+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..0e428f4
--- /dev/null
+++ b/tls/tests/meson.build
@@ -0,0 +1,104 @@
+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())
+]
+
+envs = [
+ 'G_TEST_SRCDIR=' + meson.current_source_dir(),
+ 'G_TEST_BUILDDIR=' + meson.current_build_dir()
+]
+
+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
+ )
+
+ test(
+ program[0],
+ exe,
+ env: envs
+ )
+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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]