2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 09:57:41 +00:00

[#3730] Add other meson targets

- add-changelog-entry
- coverage (.lcovrc)
- cppcheck, cppcheck-report
- doc (renamed from docs)
- grammar
- mes-doc
- uml
- update-python-dependencies
- valgrind (add_test_setup instead of custom target)
This commit is contained in:
Andrei Pavel 2025-02-21 15:06:10 +02:00
parent ac5c781575
commit 8e0783550a
No known key found for this signature in database
GPG Key ID: D4E804481939CB21
15 changed files with 202 additions and 99 deletions

1
.lcovrc Normal file
View File

@ -0,0 +1 @@
ignore_errors = gcov,inconsistent,mismatch,source

View File

@ -1393,10 +1393,6 @@ AC_ARG_ENABLE(logger-checks,
AM_CONDITIONAL(ENABLE_LOGGER_CHECKS, test x$enable_logger_checks != xno)
AM_COND_IF([ENABLE_LOGGER_CHECKS], [AC_DEFINE([ENABLE_LOGGER_CHECKS], [1], [Check logger messages?])])
# Check for asciidoc
AC_PATH_PROG(ASCIIDOC, asciidoc, no)
AM_CONDITIONAL(HAVE_ASCIIDOC, test "x$ASCIIDOC" != "xno")
# Check for plantuml
AC_PATH_PROG(PLANTUML, plantuml, no)
AM_CONDITIONAL(HAVE_PLANTUML, test "x$PLANTUML" != "xno")

View File

@ -13,4 +13,4 @@ configure_file(
configuration: make_devel_conf_data,
)
make_devel = f'@current_build_dir@/make-devel.sh'
run_target('make-devel', command: [CD_AND_RUN, current_source_dir, make_devel])
MAKE_DEVEL = run_target('make-devel', command: [CD_AND_RUN, current_source_dir, make_devel])

21
doc/make-grammar.sh.in Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# Expressions don't expand in single quotes, use double quotes for that. [SC2016]
# shellcheck disable=SC2016
set -euv
cd @TOP_SOURCE_DIR@
mkdir -p doc/sphinx/grammar
./tools/extract_bnf.sh src/bin/dhcp4/dhcp4_parser \
--markdown ':ref:`dhcp4`' > doc/sphinx/grammar/grammar-dhcp4-parser.rst
./tools/extract_bnf.sh src/bin/dhcp6/dhcp6_parser \
--markdown ':ref:`dhcp6`' > doc/sphinx/grammar/grammar-dhcp6-parser.rst
./tools/extract_bnf.sh src/bin/d2/d2_parser \
--markdown ':ref:`dhcp-ddns-server`' > doc/sphinx/grammar/grammar-d2-parser.rst
./tools/extract_bnf.sh src/bin/agent/agent_parser \
--markdown ':ref:`kea-ctrl-agent`' > doc/sphinx/grammar/grammar-ca-parser.rst
./tools/extract_bnf.sh src/bin/netconf/netconf_parser \
--markdown ':ref:`netconf`' > doc/sphinx/grammar/grammar-netconf-parser.rst

View File

@ -78,13 +78,11 @@ examples = [
'examples/netconf/comments.json',
'examples/netconf/simple-dhcp4.json',
'examples/netconf/simple-dhcp6.json',
'examples/template-power-user-home/info.md',
'examples/template-power-user-home/kea-ca-1.conf',
'examples/template-power-user-home/kea-ca-2.conf',
'examples/template-power-user-home/kea-dhcp4-1.conf',
'examples/template-power-user-home/kea-dhcp4-2.conf',
'examples/template-ha-mt-tls/info.md',
'examples/template-ha-mt-tls/kea-ca-1.conf',
'examples/template-ha-mt-tls/kea-ca-2.conf',
@ -93,4 +91,9 @@ examples = [
]
install_data(examples, preserve_path: true, install_dir: 'share/doc/kea')
# grammar target
make_grammar = configure_file(
input: 'make-grammar.sh.in',
output: 'make-grammar.sh',
configuration: {'TOP_SOURCE_DIR': TOP_SOURCE_DIR},
)
MAKE_GRAMMAR = run_target('make-grammar', command: [make_grammar])

18
doc/sphinx/make-mes-doc.sh.in Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
set -euv
cd @TOP_SOURCE_DIR@
# api-files.txt
find src/share/api -type f -name '[a-z]*.json' | sort -V > "@srcdir@/api-files.txt"
# mes-files.txt
find . -type f -name '*.mes' | sort -V | sed 's#^./##g' > "@srcdir@/mes-files.txt"
# debug-messages.rst
@PYTHON@ ./tools/check-messages.py --generate-debug-messages-page
# kea-messages.rst
cd @srcdir@
@PYTHON@ ./mes2doc.py -o kea-messages.rst

26
doc/sphinx/make-uml.sh.in Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
set -euv
cd @srcdir@
if test "@HAVE_PLANTUML@" != "no" ; then
# uml-to-png
# shellcheck disable=SC2043
for uml in @umls@; do @PLANTUML@ -tpng "$uml"; done
# uml-to-svg
# shellcheck disable=SC2043
for uml in @umls@; do @PLANTUML@ -tsvg "$uml"; done
# format-svgs
if test "@HAVE_XMLLINT" != "no" ; then
# shellcheck disable=SC2043
for svg in @svgs@; do xmllint --format "$svg" > tmp; mv tmp "$svg"; done
else
printf 'WARNING: xmllint not found. SVGs not formatted.\n'
fi
# uml-to-txt
# shellcheck disable=SC2043
for uml in @tumls@; do @PLANTUML@ -ttxt "$uml"; done
# shellcheck disable=SC2043
for txt in @txts@; do sed 's/ *$//g' "$txt" > tmp; mv tmp "$txt"; done
fi

View File

@ -0,0 +1,10 @@
#!/bin/sh
set -euv
cd @srcdir@
if test "@HAVE_PIP_COMPILE@" != "no" ; then
rm -f ./src/requirements.txt
pip-compile -r ./src/requirements.in
fi

View File

@ -120,23 +120,36 @@ mandir = get_option('mandir')
mandir8 = f'@PREFIX@/@mandir@/man8/'
make_conf_data.set('mandir8', mandir8)
MAKE_DOC = disabler()
if sphinx_exe.found()
make_doc = configure_file(
input: 'make-doc.sh.in',
output: 'make-doc.sh',
configuration: make_conf_data,
)
run_target('make-doc', command: [make_doc])
MAKE_DOC = run_target('make-doc', command: [make_doc])
endif
regen_doc = configure_file(
input: 'regen-doc.sh.in',
output: 'regen-doc.sh',
configuration: make_conf_data,
)
make_install = configure_file(
input: 'make-install.sh.in',
output: 'make-install.sh',
configuration: make_conf_data,
)
run_target('regen-doc', command: [regen_doc])
make_mes_doc = configure_file(
input: 'make-mes-doc.sh.in',
output: 'make-mes-doc.sh',
configuration: make_conf_data,
)
make_uml = configure_file(
input: 'make-uml.sh.in',
output: 'make-uml.sh',
configuration: make_conf_data,
)
make_update_python_dependencies = configure_file(
input: 'make-update-python-dependencies.sh.in',
output: 'make-update-python-dependencies.sh',
configuration: make_conf_data,
)
meson.add_install_script(make_install)
MAKE_MES_DOC = run_target('make-mes-doc', command: [make_mes_doc])
MAKE_UML = run_target('make-uml', command: [make_uml])
MAKE_UPDATE_PYTHON_DEPENDENCIES = run_target('make-update-python-dependencies', command: [make_update_python_dependencies])

View File

@ -1,48 +0,0 @@
#!/bin/sh
set -v
set -e
cd @srcdir@
# mes-files.txt
cd @TOP_SOURCE_DIR@
find . -type f -name '*.mes' | sort -V | sed 's#^./##g' > @srcdir@/mes-files.txt
# debug-messages.rst
@PYTHON@ @TOP_SOURCE_DIR@/tools/check-messages.py --generate-debug-messages-page
# kea-messages.rst
@PYTHON@ @srcdir@/mes2doc.py -o @srcdir@/kea-messages.rst
# api-files.txt
cd @TOP_SOURCE_DIR@
find src/share/api -type f -name '[a-z]*.json' | sort -V > @srcdir@/api-files.txt
cd @srcdir@
if test "@HAVE_PLANTUML@" != "no" ; then
# uml-to-png
# shellcheck disable=SC2043
for uml in @umls@; do @PLANTUML@ -tpng "$uml"; done
# uml-to-svg
# shellcheck disable=SC2043
for uml in @umls@; do @PLANTUML@ -tsvg "$uml"; done
# format-svgs
if test "@HAVE_XMLLINT" != "no" ; then
# shellcheck disable=SC2043
for svg in @svgs@; do xmllint --format "$svg" > tmp; mv tmp "$svg"; done
else
printf 'WARNING: xmllint not found. SVGs not formatted.\n'
fi
# uml-to-txt
# shellcheck disable=SC2043
for uml in @tumls@; do @PLANTUML@ -ttxt "$uml"; done
# shellcheck disable=SC2043
for txt in @txts@; do sed 's/ *$//g' "$txt" > tmp; mv tmp "$txt"; done
fi
cd @srcdir@
if test "@HAVE_PIP_COMPILE@" != "no" ; then
rm -f ./src/requirements.txt
pip-compile -r ./src/requirements.in
fi

View File

@ -162,7 +162,6 @@ awk_exe = find_program('gawk', 'awk', required: false)
doxygen_exe = find_program('doxygen', required: false)
sphinx_exe = find_program('sphinx-build', 'sphinx-build-3', required: false)
pdflatex_exe = find_program('pdflatex', required: false)
asciidoc_exe = find_program('asciidoc', required: false)
plantuml_exe = find_program('plantuml', required: false)
xmllint_exe = find_program('xmllint', required: false)
pip_compile_exe = find_program('pip-compile', required: false)
@ -436,26 +435,6 @@ else
conf_data.set('PREMIUM_EXTENDED_VERSION', '"no"')
endif
#### Configuration Files
# TODO: Change to config.h.in when autotools are removed.
configure_file(
input: 'meson-config.h.in',
output: 'config.h',
configuration: conf_data,
install: true,
install_dir: 'include/kea',
)
# TODO: Change to kea_version.h.in when autotools are removed.
configure_file(
input: 'meson-kea_version.h.in',
output: 'kea_version.h',
configuration: conf_data,
install: true,
install_dir: 'include/kea',
)
#### Default Includes
INCLUDES = [
@ -669,18 +648,94 @@ else
report_conf_data.set('GTEST_LIBDIR', 'unknown')
endif
#### Configuration Files
config_report_sh = configure_file(
input: 'config-report.sh.in',
output: 'config-report.sh',
configuration: report_conf_data,
)
config_report = custom_target(
'config.report',
# TODO: Change to config.h.in when autotools are removed.
configure_file(
input: 'meson-config.h.in',
output: 'config.h',
configuration: conf_data,
install: true,
install_dir: 'include/kea',
)
# TODO: Change to kea_version.h.in when autotools are removed.
configure_file(
input: 'meson-kea_version.h.in',
output: 'kea_version.h',
configuration: conf_data,
install: true,
install_dir: 'include/kea',
)
#### Custom Targets
run_target(
'add-changelog-entry',
command: ['changelog_unreleased/.add-entry.sh'],
)
CONFIG_REPORT = custom_target(
output: 'config.report',
depend_files: config_report_sh,
depend_files: [config_report_sh],
command: [f'@TOP_BUILD_DIR@/config-report.sh'],
)
run_target(
'cppcheck',
command: [
'cppcheck',
'-I.',
'-I./src/lib',
'-I./src/bin',
'--error-exitcode=1',
'--inline-suppr',
'--quiet',
'--max-configs=256',
f'--suppressions-list=@TOP_SOURCE_DIR@/src/cppcheck-suppress.lst',
'--template={file}:{line}: check_fail: {message} ({severity},{id})',
'--xml',
'--xml-version=2',
'.',
'>',
'cppcheck-result.xml',
'2>&1',
],
)
run_target(
'cppcheck-report',
command: [
'cppcheck-htmlreport',
'--file',
'./cppcheck-result.xml',
'--report-dir',
'./report',
'--title',
'"cppcheck report"',
],
)
add_test_setup(
'valgrind',
exe_wrapper: [
valgrind_exe,
'--child-silent-after-fork=yes',
'--fullpath-after=',
'--leak-check=full',
'--num-callers=64',
'--quiet',
'--show-leak-kinds=all',
'--suppressions=src/valgrind.supp',
],
)
#### Build Starts Here
LIBS_BUILT_SO_FAR = []
@ -694,18 +749,26 @@ if have_premium
subdir('premium')
endif
alias_target('messages', TARGETS_GEN_MESSAGES)
alias_target('parser', TARGETS_GEN_PARSER)
top_docs = [
'AUTHORS',
'CONTRIBUTING.md',
'COPYING',
'ChangeLog',
'README',
'CONTRIBUTING.md',
'SECURITY.md',
'platforms.rst',
'code_of_conduct.md',
'platforms.rst',
]
install_data(top_docs, install_dir: 'share/doc/kea')
install_emptydir('var/run/kea')
#### More Custom Targets
alias_target('doc', MAKE_DOC)
alias_target('devel', MAKE_DEVEL)
alias_target('grammar', MAKE_GRAMMAR)
alias_target('messages', TARGETS_GEN_MESSAGES)
alias_target('mes-doc', MAKE_MES_DOC)
alias_target('parser', TARGETS_GEN_PARSER)
alias_target('uml', MAKE_UML)
alias_target('update-python-dependencies', MAKE_UPDATE_PYTHON_DEPENDENCIES)

View File

@ -1,4 +1,4 @@
// File created from ../../../src/bin/netconf/netconf_messages.mes
// File created from src/bin/netconf/netconf_messages.mes
#include <cstddef>
#include <log/message_types.h>

View File

@ -1,4 +1,4 @@
// File created from ../../../src/bin/netconf/netconf_messages.mes
// File created from src/bin/netconf/netconf_messages.mes
#ifndef NETCONF_MESSAGES_H
#define NETCONF_MESSAGES_H

View File

@ -36,25 +36,25 @@ kea_log_init_tests = executable(
)
test('kea-log-init-tests', kea_log_init_tests, protocol: 'gtest')
logger_example = executable(
executable(
'logger_example',
'logger_example.cc',
include_directories: [include_directories('.')] + INCLUDES,
link_with: [kea_util_unittests_lib] + LIBS_BUILT_SO_FAR,
)
init_logger_test = executable(
executable(
'init_logger_test',
'init_logger_test.cc',
include_directories: [include_directories('.')] + INCLUDES,
link_with: [kea_util_unittests_lib] + LIBS_BUILT_SO_FAR,
)
buffer_logger_test = executable(
executable(
'buffer_logger_test',
'buffer_logger_test.cc',
include_directories: [include_directories('.')] + INCLUDES,
link_with: [kea_util_unittests_lib] + LIBS_BUILT_SO_FAR,
)
logger_lock_test = executable(
executable(
'logger_lock_test',
'logger_lock_test.cc',
'log_test_messages.cc',

View File

@ -1,6 +1,6 @@
mk_cfgrpt = f'@TOP_SOURCE_DIR@/tools/mk_cfgrpt.sh'
config_report_cc = custom_target(
input: config_report,
input: CONFIG_REPORT,
output: 'config_report.cc',
command: [mk_cfgrpt, '@INPUT@', '@OUTPUT@'],
)