Skip to content
Snippets Groups Projects
Commit 78435b47 authored by Niels De Graef's avatar Niels De Graef :grin:
Browse files

Port to the Meson build system

parent abe2ae4d
No related branches found
No related tags found
1 merge request!13Port to the Meson build system
configure_file(
input: 'version.xml.in',
output: '@BASENAME@',
configuration: {
'UHM_VERSION_MAJOR': uhm_major_version,
'UHM_VERSION_MINOR': uhm_minor_version,
'UHM_VERSION_MICRO': uhm_micro_version,
},
)
gnome.gtkdoc('libuhttpmock',
module_version: uhm_api_version,
main_xml: 'libuhttpmock-0.0-docs.xml',
src_dir: include_directories('../'),
scan_args: [
'--rebuild-types',
'--deprecated-guards="LIBUHTTPMOCK_DISABLE_DEPRECATED"',
],
dependencies: libuhm_internal_dep,
)
{
global:
uhm_*;
local:
*;
};
libuhm_sources = files(
'uhm-resolver.c',
'uhm-server.c',
)
libuhm_source_headers = files(
'uhm-resolver.h',
'uhm-server.h',
)
libuhm_headers = [
libuhm_source_headers,
uhm_version_h,
files('uhm.h'),
]
install_headers(libuhm_headers,
subdir: 'libuhttpmock-@0@'.format(uhm_api_version) / 'uhttpmock',
)
libuhm_public_deps = [
glib_dep,
gio_dep,
soup_dep,
]
libuhm_private_deps = [
]
libuhm = library('uhttpmock-@0@'.format(uhm_api_version),
libuhm_sources,
dependencies: libuhm_public_deps + libuhm_private_deps,
c_args: [
'-DG_LOG_DOMAIN="libuhttpmock"',
],
link_args: cc.get_supported_link_arguments(
'-Wl,--version-script,@0@'.format(meson.current_source_dir() / 'libuhttpmock.map'),
),
include_directories: config_h_inc,
soversion: uhm_soversion,
version: uhm_lib_version,
install: true,
)
libuhm_internal_dep = declare_dependency(
link_with: libuhm,
dependencies: libuhm_public_deps,
include_directories: include_directories('.'),
)
# pkg-config
pkgconfig.generate(libuhm,
name: 'libuhttpmock',
filebase: 'libuhttpmock-@0@'.format(uhm_api_version),
description: 'HTTP web service mocking library',
subdirs: 'libuhttpmock-@0@'.format(uhm_api_version),
requires: libuhm_public_deps,
)
# Introspection
if get_option('introspection')
libuhm_gir = gnome.generate_gir(libuhm,
sources: [ libuhm_sources, libuhm_source_headers, uhm_version_h, ],
namespace: 'Uhm',
nsversion: uhm_api_version,
includes: [ 'GObject-2.0', 'Soup-2.4' ],
header: 'uhttpmock/uhm.h',
export_packages: 'libuhttpmock',
install: true,
)
if get_option('vapi')
libuhm_vapi = gnome.generate_vapi('libuhttpmock-@0@'.format(uhm_api_version),
sources: libuhm_gir[0],
metadata_dirs: meson.current_source_dir(),
packages: [ 'gio-2.0', 'libsoup-2.4', 'libxml-2.0' ],
install: true,
)
endif
endif
subdir('tests')
if get_option('gtk_doc')
subdir('docs')
endif
uhm_test_cflags = [
'-DTEST_FILE_DIR="@0@/"'.format(meson.current_source_dir()),
'-DG_LOG_DOMAIN="libuhttpmock-tests"',
'-DLIBUHTTPMOCK_DISABLE_DEPRECATED',
]
uhm_tests = [
'server',
'resolver',
]
foreach _test : uhm_tests
test_bin = executable(_test,
sources: _test + '.c',
c_args: uhm_test_cflags,
dependencies: libuhm_internal_dep,
)
test(_test, test_bin)
endforeach
project('uhttpmock', 'c',
version: '0.5.3',
default_options: [
'warning_level=2',
'c_std=gnu99',
],
)
# Modules
gnome = import('gnome')
pkgconfig = import('pkgconfig')
# Compiler
cc = meson.get_compiler('c')
add_project_arguments([
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
], language: 'c')
# Versioning
uhm_version_split = meson.project_version().split('.')
uhm_major_version = uhm_version_split[0].to_int()
uhm_minor_version = uhm_version_split[1].to_int()
uhm_micro_version = uhm_version_split[2].to_int()
uhm_api_version = '0.0'
uhm_soversion = 0
# Before making a release, uhm_lib_version should be modified.
# The string is of the form X.Y.Z
# - If the interface is the same as the previous version, change to X.Y.Z+1
# - If interfaces have been changed or added, but binary compatibility has
# been preserved, change to X.Y+1.0
# - If binary compatibility has been broken (eg removed or changed interfaces)
# change to X+1.0.0
uhm_lib_version = '@0@.2.3'.format(uhm_soversion)
uhm_version_h = configure_file(
input: 'libuhttpmock/uhm-version.h.in',
output: '@BASENAME@',
configuration: {
'UHM_VERSION_MAJOR': uhm_major_version,
'UHM_VERSION_MINOR': uhm_minor_version,
'UHM_VERSION_MICRO': uhm_micro_version,
},
)
# Dependencies
glib_dep = dependency('glib-2.0', version: '>= 2.38')
gio_dep = dependency('gio-2.0', version: '>= 2.38')
soup_dep = dependency('libsoup-2.4', version: '>= 2.37.91')
# config.h
config_h = configuration_data()
config_h.set('HAVE_LIBSOUP_2_47_3', soup_dep.version().version_compare('>= 2.47.3'))
configure_file(output: 'config.h', configuration: config_h)
config_h_inc = include_directories('.')
subdir('libuhttpmock')
option('introspection',
type: 'boolean',
value: true,
description: 'Whether to build GObject Introspection (GIR) files',
)
option('vapi',
type: 'boolean',
value: true,
description: 'Whether to build Vala bindings (requires introspection)',
)
option('gtk_doc',
type: 'boolean',
value: true,
description: 'Whether to render the reference documentation (requires gtk-doc)',
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment