Skip to content
Snippets Groups Projects
Verified Commit 4dad9fb0 authored by Tomas Krizek's avatar Tomas Krizek
Browse files

meson: use features in options

parent 294d49cd
Branches
Tags
1 merge request!771meson build system
......@@ -4,24 +4,34 @@ kresc_src = [
'kresc.c',
]
message('--- kresc dependencies ---')
libedit = dependency('libedit', required: false)
if not libedit.found()
# TODO why call find_library? osx workaround?
libedit = meson.get_compiler('c').find_library('edit')
build_client = false
if not get_option('client').disabled()
message('--- client dependencies ---')
libedit = dependency('libedit', required: false)
if libedit.found()
build_client = true
else
# fallback lib
# TODO why call find_library? osx workaround?
libedit = meson.get_compiler('c').find_library('edit', required: get_option('client'))
if libedit.found()
build_client = true
endif
endif
message('---------------------------')
endif
message('--------------------------')
# build
kresc = executable(
'kresc',
kresc_src,
dependencies: [
contrib_dep,
libkres_dep,
libedit,
],
install: true,
install_dir: get_option('sbindir'),
)
if build_client
kresc = executable(
'kresc',
kresc_src,
dependencies: [
contrib_dep,
libkres_dep,
libedit,
],
install: true,
install_dir: get_option('sbindir'),
)
endif
......@@ -21,16 +21,26 @@ config_tests += [
]
# embed lua to daemon
if get_option('daemon')
message('--- required kresd dependencies ---')
# daemon dependencies
build_daemon = false
if not get_option('daemon').disabled()
message('--- daemon dependencies ---')
xxd = find_program('xxd', required: false)
if not xxd.found()
hexdump = find_program('hexdump')
if xxd.found()
build_daemon = true
else
# fallback
hexdump = find_program('hexdump', required: get_option('daemon'))
if hexdump.found()
build_daemon = true
endif
endif
embed_lua = find_program('../../scripts/embed-lua.sh')
message('--------------------------------------')
endif
# embed lua to daemon
if build_daemon
embed_lua = generator(
embed_lua,
arguments: ['@INPUT@'],
......
......@@ -31,15 +31,19 @@ luajit_has_setfuncs = run_command(
).returncode() == 0 ? '1' : '0'
# daemon CFLAGS
kresd_c_args += [
kresd_c_args = [
'-fPIE', # NOTE this triggers warning, but is needed for compatibility with meson 0.47.0
'-DROOTHINTS="@0@/root.hints"'.format(config.get('etc_dir')),
'-DROOTHINTS="@0@/root.hints"'.format(etc_dir),
'-DLIBEXT="@0@"'.format(lib_suffix),
'-Dlibzscanner_SONAME="@0@"'.format(libzscanner.get_pkgconfig_variable('soname')),
'-Dlibknot_SONAME="@0@"'.format(libknot.get_pkgconfig_variable('soname')),
'-DLUA_HAS_SETFUNCS=@0@'.format(luajit_has_setfuncs),
]
if systemd
kresd_c_args += ['-DHAS_SYSTEMD']
endif
# TODO test build on osx
if host_machine.system() == 'darwin'
# luajit workaround for OS X https://luajit.org/install.html#embed
......@@ -50,8 +54,7 @@ endif
subdir('lua')
if get_option('daemon')
# build
if build_daemon
kresd = executable(
'kresd',
kresd_src, kresd_lua,
......
......@@ -3,7 +3,7 @@
# man page
man_config = configuration_data()
man_config.set('version', meson.project_version())
man_config.set('date', run_command('scripts/get-date.sh', check: true)
man_config.set('date', run_command('../scripts/get-date.sh', check: true).stdout())
man_config.set('keyfile_default', keyfile_default)
man_config.set('modules_dir', modules_dir)
......@@ -19,7 +19,8 @@ man_kresd = configure_file(
install_man(man_kresd)
if get_option('doc') # doxygen + html docs
build_doc = get_option('doc').enabled() # NOTE 'auto' unsupported
if build_doc # doxygen + html docs
message('--- doc dependencies ---')
doxygen = find_program('doxygen')
sphinx_build = find_program('sphinx-build')
......
......@@ -29,7 +29,6 @@ message('------------------------------')
# Variables
libkres_soversion = 9
kresd_c_args = []
## Paths
prefix = get_option('prefix')
......@@ -63,26 +62,27 @@ user = get_option('user')
group = get_option('group')
## Systemd
systemd = get_option('systemd')
if systemd != 'disabled'
opt_systemd = get_option('systemd')
systemd = false
systemd_socket = false
if opt_systemd != 'disabled'
message('--- systemd integration ---')
libsystemd = dependency('libsystemd', version: '>=227', required: systemd == 'enabled')
libsystemd = dependency('libsystemd', version: '>=227',
required: opt_systemd == 'enabled')
if libsystemd.found()
systemd = 'enabled' # with socket activation
systemd = true
systemd_socket = true
else
libsystemd = dependency('libsystemd', required: systemd == 'nosocket')
if libsystemd.found()
systemd = 'nosocket' # without socket activation
else
systemd = 'disabled' # without systemd
systemd = true
systemd_socket = false
endif
endif
if systemd != 'disabled'
kresd_c_args += ['-DHAS_SYSTEMD']
endif
message('---------------------------')
endif
# TODO systemd_user_mode
systemd_user_mode = false
# TODO use var instead
add_global_arguments(
......@@ -140,10 +140,7 @@ subdir('contrib')
subdir('lib')
subdir('daemon')
subdir('modules')
if get_option('client')
subdir('client')
endif
subdir('client')
# tests
......@@ -156,7 +153,47 @@ subdir('doc')
subdir('etc')
# TODO message summary?
message('modules_dir: ' + modules_dir)
message('version: @0@'.format(config.get('version')))
message('date: @0@'.format(config.get('date')))
# summary message
# NOTE: ternary operator in format() not supported
# https://github.com/mesonbuild/meson/issues/2404
summary_managed_ta = managed_ta ? 'enabled' : 'disabled'
summary_systemd = systemd ? 'enabled' : 'disabled'
summary_systemd_socket = systemd_socket ? 'enabled' : 'disabled'
summary_systemd_user_mode = systemd_user_mode ? 'enabled' : 'disabled'
summary_build_client = build_client ? 'enabled' : 'disabled'
summary_build_daemon = build_daemon ? 'enabled' : 'disabled'
summary_build_doc = build_doc ? 'enabled' : 'disabled'
summary_build_extra_tests = build_extra_tests ? 'enabled' : 'disabled'
summary_build_unit_tests = build_unit_tests ? 'enabled' : 'disabled'
message('''
======================= SUMMARY =======================
paths
prefix: @0@'''.format(prefix) + '''
modules_dir: @0@'''.format(modules_dir) + '''
trust_anchors
keyfile_default: @0@'''.format(keyfile_default) + '''
managed_ta: @0@'''.format(summary_managed_ta) + '''
systemd: @0@'''.format(summary_systemd) + '''
socket activation: @0@'''.format(summary_systemd_socket) + '''
user mode: @0@'''.format(summary_systemd_user_mode) + '''
components
client: @0@'''.format(summary_build_client) + '''
daemon: @0@'''.format(summary_build_daemon) + '''
doc: @0@'''.format(summary_build_doc) + '''
extra_tests: @0@'''.format(summary_build_extra_tests) + '''
unit_tests: @0@'''.format(summary_build_unit_tests) + '''
additional
user: @0@'''.format(user) + '''
group: @0@'''.format(group) + '''
install_kresd_conf: @0@'''.format(get_option('install_kresd_conf')) + '''
version: @0@'''.format(meson.project_version()) + '''
=======================================================
''')
......@@ -55,8 +55,8 @@ option(
option(
'systemd_user_mode',
type: 'boolean',
value: false,
type: 'feature',
value: 'disabled',
description: 'use systemd user mode (for debug/testing)',
)
......@@ -64,28 +64,35 @@ option(
# Component options
option(
'client',
type: 'boolean',
value: true,
type: 'feature',
value: 'auto',
description: 'build kresc client binary'
)
option(
'daemon',
type: 'boolean',
value: true,
type: 'feature',
value: 'enabled',
description: 'build kresd daemon binary'
)
option(
'doc',
type: 'boolean',
value: false,
type: 'feature',
value: 'disabled',
description: 'build html documentation'
)
option(
'extra_tests',
type: 'boolean',
value: false,
type: 'feature',
value: 'disabled',
description: 'integration tests with extra dependencies'
)
option(
'unit_tests',
type: 'feature',
value: 'auto',
description: 'cmocka unit tests'
)
......@@ -3,9 +3,11 @@ set -o nounset
cd "$(dirname $0)/.."
# Get date from NEWS if possible (regular release)
head -n1 < NEWS | sed 's/.*(\(.*\)).*/\1/' | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$$'
DATE=$(head -n1 < NEWS | sed 's/.*(\(.*\)).*/\1/' | grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$$')
if [[ $? -ne 0 ]]; then
# or use last modification time of NEWS (dev versions)
date -u -r NEWS +%F
DATE=$(date -u -r NEWS +%F)
fi
echo -n $DATE
# tests
message('--- unit test dependencies ---')
cmocka = dependency('cmocka', required: false)
if cmocka.found()
subdir('unit')
build_unit_tests = false
if not get_option('unit_tests').disabled()
message('--- unit_tests dependencies ---')
cmocka = dependency('cmocka', required: get_option('unit_tests'))
if cmocka.found()
build_unit_tests = true
subdir('unit')
endif
message('-------------------------------')
endif
message('------------------------------')
subdir('config')
if get_option('extra_tests')
build_extra_tests = get_option('extra_tests').enabled() # NOTE 'auto' not supported
if build_extra_tests
message('--- extra_tests dependencies ---')
python3 = find_program('python3')
py3_deps = []
......@@ -20,9 +25,8 @@ if get_option('extra_tests')
foreach py3_dep : py3_deps
py3_import = run_command(python3, '-c', 'import @0@'.format(py3_dep[0]))
if py3_import.returncode() != 0
error('missing python3 dependency: @0@'.format(py3_dep[1]))
message('missing python3 dependency: @0@'.format(py3_dep[1]))
endif
endforeach
message('--------------------------------')
endif
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