[glib-openssl] build: add initial support for meson
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-openssl] build: add initial support for meson
- Date: Thu, 13 Apr 2017 13:12:26 +0000 (UTC)
commit d23e30c8c085381b623c9f69b708efabd9957294
Author: Patrick Griffis <tingping tingping se>
Date: Tue Mar 7 10:48:05 2017 -0500
build: add initial support for meson
meson.build | 126 ++++++++++++++++++++++++++++++++++++++++++
meson_detect_certificates.py | 16 +++++
meson_options.txt | 1 +
meson_post_install.py | 13 ++++
po/meson.build | 3 +
tls/base/meson.build | 17 ++++++
tls/openssl/meson.build | 41 ++++++++++++++
tls/tests/meson.build | 22 +++++++
8 files changed, 239 insertions(+), 0 deletions(-)
---
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..ea809e7
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,126 @@
+project('glib-openssl', 'c',
+ version: '2.50.2',
+ meson_version: '>= 0.38.0'
+)
+
+cc = meson.get_compiler('c')
+
+glib_req = '2.46.0'
+glib = dependency('glib-2.0', version: '>=' + glib_req)
+gobject = dependency('gobject-2.0', version: '>=' + glib_req)
+gio = dependency('gio-2.0', version: '>=' + glib_req)
+giomoduledir = gio.get_pkgconfig_variable('giomoduledir')
+gio_querymodules = find_program('gio-querymodules')
+
+openssl = dependency('openssl')
+# TODO: Handle finding on Win32
+
+# Compiler flags
+if cc.get_id() == 'msvc'
+ # Make MSVC more pedantic, this is a recommended pragma list
+ # from _Win32_Programming_ by Rector and Newcomer. Taken from
+ # glib's msvc_recommended_pragmas.h--please see that file for
+ # the meaning of the warning codes used here
+ test_cflags = [
+ '-we4002',
+ '-we4003',
+ '-w14010',
+ '-we4013',
+ '-w14016',
+ '-we4020',
+ '-we4021',
+ '-we4027',
+ '-we4029',
+ '-we4033',
+ '-we4035',
+ '-we4045',
+ '-we4047',
+ '-we4049',
+ '-we4053',
+ '-we4071',
+ '-we4150',
+ '-we4819'
+ ]
+else
+ test_cflags = [
+ '-ffast-math',
+ '-fstrict-aliasing',
+ '-Wpointer-arith',
+ '-Wmissing-declarations',
+ '-Wformat=2',
+ '-Wstrict-prototypes',
+ '-Wmissing-prototypes',
+ '-Wnested-externs',
+ '-Wold-style-definition',
+ '-Wdeclaration-after-statement',
+ '-Wunused',
+ '-Wuninitialized',
+ '-Wshadow',
+ '-Wmissing-noreturn',
+ '-Wmissing-format-attribute',
+ '-Wredundant-decls',
+ '-Wlogical-op',
+ '-Wcast-align',
+ '-Wno-unused-local-typedefs',
+ '-Werror=implicit',
+ '-Werror=init-self',
+ '-Werror=main',
+ '-Werror=missing-braces',
+ '-Werror=return-type',
+ '-Werror=array-bounds',
+ '-Werror=write-strings'
+ ]
+endif
+common_flags = []
+foreach cflag: test_cflags
+ if cc.has_argument(cflag)
+ common_flags += [ cflag ]
+ endif
+endforeach
+
+extra_args= []
+# Detect and set symbol visibility
+if cc.get_id() == 'msvc'
+ extra_args += ['-D_GLIB_EXTERN=__declspec (dllexport) extern']
+endif
+
+config_h = configuration_data()
+config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
+config_h.set_quoted('LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir')))
+config_h.set('G_DISABLE_DEPRECATED', true)
+config_h.set_quoted('G_LOG_DOMAIN', 'GLib-OpenSSL')
+
+with_openssl = openssl.found()
+if with_openssl
+ ca_certificates = get_option('with-ca-certificates')
+ if ca_certificates == 'no'
+ message('CA certificates disabled')
+ else
+ if ca_certificates == ''
+ detect_certificates = run_command(join_paths(meson.source_root(), 'meson_detect_certificates.py'))
+
+ if detect_certificates.returncode() == 1
+ error('Could not find certificates. Use --with-ca-certificates=path to set, or
--with-ca-certificates=no to disable it')
+ endif
+
+ ca_certificates = detect_certificates.stdout().strip()
+ endif
+
+ message('CA certificates: ' + ca_certificates)
+
+ config_h.set_quoted('GTLS_SYSTEM_CA_FILE', ca_certificates)
+ endif
+endif
+
+configure_file(
+ output: 'config.h',
+ configuration: config_h,
+)
+config_h_include = include_directories('.')
+
+subdir('tls/base')
+subdir('tls/openssl')
+subdir('tls/tests')
+subdir('po')
+
+meson.add_install_script('meson_post_install.py')
diff --git a/meson_detect_certificates.py b/meson_detect_certificates.py
new file mode 100755
index 0000000..1482554
--- /dev/null
+++ b/meson_detect_certificates.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+import os
+
+certificates = [
+ '/etc/pki/tls/certs/ca-bundle.crt',
+ '/etc/ssl/certs/ca-certificates.crt',
+ '/etc/ssl/ca-bundle.pem',
+]
+
+for cert in certificates:
+ if os.path.isfile(cert):
+ print(cert)
+ exit(0)
+
+exit(1)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..6b1c0f7
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('with-ca-certificates', type : 'string', value : '', description : 'Path to system Certificate
Authority list')
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100755
index 0000000..97b1cc9
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+
+# Packagers handle this
+if 'DESTDIR' not in os.environ:
+ # post install scripts can't pass these so we must check again
+ ret = subprocess.check_output(('pkg-config', '--variable',
+ 'giomoduledir', 'gio-2.0'))
+ moduledir = ret.decode().strip()
+ print('Updating module cache in {}...'.format(moduledir))
+ subprocess.check_call(('gio-querymodules', moduledir))
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..b9d2d48
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,3 @@
+i18n = import('i18n')
+
+i18n.gettext(meson.project_name(), preset: 'glib')
\ No newline at end of file
diff --git a/tls/base/meson.build b/tls/base/meson.build
new file mode 100644
index 0000000..c1a32b5
--- /dev/null
+++ b/tls/base/meson.build
@@ -0,0 +1,17 @@
+tlsbase_sources = [
+ 'gtlsconnection-base.c',
+ 'gtlsinputstream-base.c',
+ 'gtlsoutputstream-base.c',
+]
+
+tlsbase = static_library('tlsbase',
+ tlsbase_sources,
+ dependencies: gio,
+ include_directories: config_h_include,
+)
+
+tlsbase_dep = declare_dependency(
+ link_with: tlsbase,
+ include_directories: include_directories('.'),
+ dependencies: gio,
+)
diff --git a/tls/openssl/meson.build b/tls/openssl/meson.build
new file mode 100644
index 0000000..e5759c3
--- /dev/null
+++ b/tls/openssl/meson.build
@@ -0,0 +1,41 @@
+tlsopenssl_sources = [
+ 'openssl-module.c',
+ 'gtlsbackend-openssl.c',
+ 'gtlscertificate-openssl.c',
+ 'gtlsconnection-openssl.c',
+ 'gtlsserverconnection-openssl.c',
+ 'gtlsclientconnection-openssl.c',
+ 'gtlsdatabase-openssl.c',
+ 'gtlsfiledatabase-openssl.c',
+ 'gtlsbio.c',
+ 'openssl-util.c',
+]
+
+platform_deps = [ openssl, gio, glib, gobject ]
+
+tlsopenssl = static_library('tlsopenssl',
+ tlsopenssl_sources,
+ dependencies: [tlsbase_dep, platform_deps],
+ include_directories: config_h_include,
+)
+
+tlsopenssl_dep = declare_dependency(
+ link_with: tlsopenssl,
+ include_directories: include_directories('.', '../base'),
+ dependencies: platform_deps
+)
+
+gioopenssl = shared_module('gioopenssl',
+ tlsopenssl_sources,
+ dependencies: [tlsopenssl_dep],
+ include_directories: config_h_include,
+ install: true,
+ install_dir: giomoduledir,
+ c_args: [extra_args + common_flags],
+)
+
+# Internal dependency, for tests and benchmarks
+tlsopenssl_inc = include_directories([ '.', '..' ])
+tlsopenssl_dep = declare_dependency(link_with: tlsopenssl,
+ include_directories: [ tlsopenssl_inc, config_h_include ],
+ dependencies: platform_deps)
diff --git a/tls/tests/meson.build b/tls/tests/meson.build
new file mode 100644
index 0000000..0bcbb1d
--- /dev/null
+++ b/tls/tests/meson.build
@@ -0,0 +1,22 @@
+unit_tests = [
+ [ 'certificate', ['certificate.c'] ],
+ [ 'connection', ['connection.c', 'mock-interaction.h', 'mock-interaction.c'] ],
+ [ 'file-database', ['file-database.c'] ],
+]
+
+test_args = [
+ '-DBACKEND="openssl"',
+]
+
+foreach unit: unit_tests
+ exe = executable(unit[0], unit[1],
+ dependencies: tlsopenssl_dep,
+ include_directories: tlsopenssl_inc,
+ c_args: test_args)
+ test(unit[0], exe,
+ args: [ '--tap', '-k' ],
+ env: [
+ 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+ 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+ ])
+endforeach
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]