Commit aed5fb0c authored by Iñigo Martínez's avatar Iñigo Martínez Committed by Michael Catanzaro

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
parent 8ea35179
......@@ -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)
#!/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)
{
global:
g_io_module_load;
g_io_module_unload;
g_io_module_query;
local:
*;
};
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)
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')
#!/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]])
i18n.gettext(meson.project_name(), preset: 'glib')
......@@ -14,3 +14,5 @@ libgiognomeproxy_la_LDFLAGS = $(module_flags)
libgiognomeproxy_la_LIBADD = \
$(GLIB_LIBS) \
$(NULL)
EXTRA_DIST += meson.build
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]]
......@@ -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
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]]
......@@ -19,4 +19,6 @@ if HAVE_LIBPROXY
test_programs += libproxy
endif
EXTRA_DIST += common.c
EXTRA_DIST += \
common.c \
meson.build
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
[Test]
Type=session
Exec=@installed_tests_dir@/@program@ --tap
Output=TAP
......@@ -58,3 +58,5 @@ libgiognutls_la_LIBADD = \
$(GLIB_LIBS) \
$(GNUTLS_LIBS) \
$(NULL)
EXTRA_DIST += meson.build
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
)
......@@ -22,3 +22,5 @@ libgiopkcs11_la_LIBADD = \
AM_CPPFLAGS += \
$(PKCS11_CFLAGS) \
-DG_DISABLE_DEPRECATED
EXTRA_DIST += meson.build
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('.')
)
......@@ -72,4 +72,7 @@ testfilesdir = $(installed_testdir)/files
testfiles_DATA = $(testfiles_data)
endif
EXTRA_DIST += $(testfiles_data)
EXTRA_DIST += \
$(testfiles_data) \
meson.build \
$(NULL)
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment