From: Fred Morcos Date: Fri, 4 Aug 2023 11:42:04 +0000 (+0200) Subject: Meson: Code coverage X-Git-Tag: rec-5.1.0-alpha1~80^2~299 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81ef52107f1d1f975613995f1b25516d26cdcd0b;p=thirdparty%2Fpdns.git Meson: Code coverage --- diff --git a/meson.build b/meson.build index a2a307b582..5351dd54fe 100644 --- a/meson.build +++ b/meson.build @@ -66,6 +66,7 @@ subdir('meson/gss-tsig') # GSS-TSIG subdir('meson/auth-tools') # Tools subdir('meson/ixfrdist') # Ixfrdist subdir('meson/systemd') # Systemd and unit file handling +subdir('meson/code-coverage') # Code coverage # Find or generate pdns/dnslabeltext.cc if not ragel.found() and not fs.exists('pdns/dnslabeltext.cc') diff --git a/meson/code-coverage/meson.build b/meson/code-coverage/meson.build new file mode 100644 index 0000000000..7baf3a87cc --- /dev/null +++ b/meson/code-coverage/meson.build @@ -0,0 +1,20 @@ +# Code coverage +# Inputs: deps + +code_coverage_deps = [] +code_coverage = get_option('code-coverage') + +if code_coverage + args = ['-U_FORTIFY_SOURCE', '-g', '-O0', '-fprofile-arcs', '-ftest-coverage'] + + foreach arg: args + if not cxx.has_argument(arg) + error('Compiler does not support ' + arg + ', which is needed for code coverage') + break + endif + + code_coverage_deps += declare_dependency(compile_args: [arg]) + endforeach +endif + +summary('Code Coverage', code_coverage, bool_yn: true, section: 'Configuration') diff --git a/meson_options.txt b/meson_options.txt index 2a6f6728c0..a824379211 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -46,3 +46,4 @@ option('ixfrdist', type: 'boolean', value: false, description: 'Build ixfrdist') option('lua-records', type: 'boolean', value: true, description: 'Build support for Lua records') option('systemd-service-user', type: 'string', value: 'pdns', description: 'User to run the systemd pdns service as. Only the setuid setting and User field in the systemd unit file are affected, the user is not created') option('systemd-service-group', type: 'string', value: 'pdns', description: 'Group to run the systemd pdns service under. Only the setgid setting and Group field in the systemd unit file are affected, the group is not created') +option('code-coverage', type: 'boolean', value: false, description: 'Enable code coverage')